Skip to content

Commit

Permalink
adding lunar tests for travis (#59)
Browse files Browse the repository at this point in the history
* adding lunar tests for travis

* improved the case when we do not have distro installed, or when we want to use install_isolated space.
remove lunar tests, since docker is not available yet

* fixing distro install path to be absolute
  • Loading branch information
asmodehn committed Apr 14, 2019
1 parent c7aeb7e commit a83561a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 24 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ env:
- ROS_DISTRO=jade PYTHON=3.4

- ROS_DISTRO=kinetic PYTHON=2.7
- ROS_DISTRO=kinetic PYTHON=3.4
- ROS_DISTRO=kinetic PYTHON=3.5

# docker image not available yet
#- ROS_DISTRO=lunar PYTHON=2.7
#- ROS_DISTRO=lunar PYTHON=3.5
# TODO : pypy + pypy3

before_install:
Expand Down
4 changes: 3 additions & 1 deletion pyros_setup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
from pyros_config import ConfigHandler

#: Smart Default distro detection (as early as possible)
if os.path.exists('/opt/ros/kinetic'):
if os.path.exists('/opt/ros/lunar'):
DETECTED_DISTRO = 'lunar'
elif os.path.exists('/opt/ros/kinetic'):
DETECTED_DISTRO = 'kinetic'
elif os.path.exists('/opt/ros/jade'):
DETECTED_DISTRO = 'jade'
Expand Down
54 changes: 32 additions & 22 deletions pyros_setup/ros_setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import, print_function

# A very special ROS hack that emulate a ros environment when imported from python
# Useful for using all python tools ( tests, IDE, etc. ) without having to do all the ROS setup beforehand
Expand Down Expand Up @@ -43,27 +44,33 @@ def ROS_setup_rosdistro_env(default_distro=None):
# The goal is to minimize code and simplify maintenance.

default_distro = default_distro or 'indigo'
# Setting env var like ROS would

if os.environ.get('ROS_MASTER_URI', None) is None:
os.environ['ROS_MASTER_URI'] = 'http://localhost:11311'

# TODO : find the proper place in ros where this is set and use it instead
if os.environ.get('ROS_DISTRO', None) is None:
os.environ['ROS_DISTRO'] = default_distro
os.environ['ROS_DISTRO'] = default_distro

distro = os.environ['ROS_DISTRO']
if os.environ.get('ROS_ROOT', None) is None:
os.environ['ROS_ROOT'] = '/opt/ros/' + distro + '/share/ros'

if os.environ.get('ROS_PACKAGE_PATH', None) is None:
os.environ['ROS_PACKAGE_PATH'] = ':'.join(['/opt/ros/' + distro + '/share',
'/opt/ros/' + distro + '/stacks'])
# Setting env var like ROS would from install
distro_install_path = os.path.join(os.path.sep, 'opt', 'ros', distro)
if os.path.exists(distro_install_path):

if os.environ.get('ROS_MASTER_URI', None) is None:
os.environ['ROS_MASTER_URI'] = 'http://localhost:11311'
if os.environ.get('ROS_ROOT', None) is None:
os.environ['ROS_ROOT'] = os.path.join(distro_install_path, 'share', 'ros')

if os.environ.get('ROS_ETC_DIR', None) is None:
os.environ['ROS_ETC_DIR'] = '/opt/ros/' + distro + '/etc/ros'
if os.environ.get('ROS_PACKAGE_PATH', None) is None:
os.environ['ROS_PACKAGE_PATH'] = ':'.join([os.path.join(distro_install_path, 'share'),
os.path.join(distro_install_path, 'stacks')])
if os.environ.get('ROS_ETC_DIR', None) is None:
os.environ['ROS_ETC_DIR'] = os.path.join(distro_install_path, 'etc', 'ros')

# we return here the workspace for the distro
return '/opt/ros/' + distro
# we return here the workspace for the distro
return distro_install_path
else:
return None


def ROS_setup_ros_package_path(workspace):
Expand All @@ -76,13 +83,13 @@ def ROS_setup_ros_package_path(workspace):

# prepending current path for ros package discovery
_logger.debug("Checking {0} exists and is named 'devel'".format(workspace))
if os.path.basename(workspace) == 'devel': # special case of devel -> we can find src
if os.path.basename(workspace) in ['devel']: # special case of devel -> we can find src
# note : devel_isolated has multiple package path, so isolated package spaces need to be specified one by one
src_path = os.path.join(os.path.dirname(workspace), 'src')
_logger.debug("Checking {0} exists".format(src_path))
if src_path is not None and os.path.exists(src_path):
_logger.warning("Prepending path {workspace_src} to ROS_PACKAGE_PATH".format(workspace_src=src_path))
os.environ['ROS_PACKAGE_PATH'] = src_path + ':' + os.environ['ROS_PACKAGE_PATH']

else:
stacks_path = os.path.join(workspace, 'stacks')
_logger.debug("Checking {0} exists".format(stacks_path))
Expand Down Expand Up @@ -187,12 +194,12 @@ def readdpackage(sitedir, name):
sys.path.remove(dir)
sys.path.insert(1, dir)
except Exception as err:
print >> sys.stderr, "Error processing line {:d} of {}:\n".format(
n + 1, fullname)
print("Error processing line {:d} of {}:\n".format(
n + 1, fullname), file=sys.stderr)
for record in traceback.format_exception(*sys.exc_info()):
for line in record.splitlines():
print >> sys.stderr, ' ' + line
print >> sys.stderr, "\nRemainder of file ignored"
print(' ' + line, file=sys.stderr)
print("\nRemainder of file ignored", file=sys.stderr)
break

# Note : virtualenvs are a much better solution to this problem,
Expand Down Expand Up @@ -242,11 +249,13 @@ def ROS_find_workspaces(distro, base_path):
workspace_paths = cmake_env_path.split(':')

if not cmake_env_path: # empty string : we failed looking for it in environment
install_isolated_ws = os.path.abspath(os.path.join(base_path, 'install_isolated'))
install_ws = os.path.abspath(os.path.join(base_path, 'install'))
devel_ws = os.path.abspath(os.path.join(base_path, 'devel'))
# note : we do not want to deal with devel_isolated here, too complex to grab all package spaces.
workspace_paths = []
# setting cmake prefix path - rosout needs this
for k, p in zip(['devel', 'install'], [devel_ws, install_ws]):
for k, p in zip(['devel', 'install', 'install_isolated'], [devel_ws, install_ws, install_isolated_ws]):
if os.path.exists(p) and p not in os.environ.get("CMAKE_PREFIX_PATH", []):
_logger.warning("Appending {key} space to CMake prefix path".format(key=k))
os.environ["CMAKE_PREFIX_PATH"] = p + ':' + os.environ.get("CMAKE_PREFIX_PATH", '')
Expand All @@ -271,8 +280,9 @@ def ROS_emulate_setup(distro=None, *workspaces):
distro = distro or 'indigo' # TODO : investigate if we should use /usr/bin/rosversion to determine default ?
distro_path = ROS_setup_rosdistro_env(default_distro=distro)

# adding distro_path to the workspace list
workspaces = list(workspaces) + [distro_path]
if distro_path:
# adding distro_path to the workspace list
workspaces = list(workspaces) + [distro_path]

# we need to reverse the order because we prepend in all these functions
for w in reversed(workspaces):
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
envlist = py27
# Test fails ! requires pyros_config >1.2
#, py34
#, py35

#, pypy
#, pypy3
Expand All @@ -12,6 +13,7 @@ envlist = py27

# This requires pyros_config >1.2
#3.4 = py34
# TODO : link ROS distro and python3 version...

# not tested yet
#pypy = pypy
Expand Down

0 comments on commit a83561a

Please sign in to comment.