Skip to content

Commit

Permalink
removing ROS specific files. adding tox and requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
asmodehn committed Apr 17, 2018
1 parent 0a16323 commit ae8e350
Show file tree
Hide file tree
Showing 23 changed files with 159 additions and 264 deletions.
98 changes: 35 additions & 63 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,48 @@
sudo: required
language: generic
services:
- docker
language: python

branches:
except:
- gh-pages

env:
global:
- CONTAINER_NAME=rostful_docker
# This will check any ROS distro with any python interpreter supported on this OS
# checking devel and install separately so that they don't influence each other (dependencies, path, env, etc.)
matrix:
- ROS_DISTRO=indigo ROS_FLOW=devel
# Rostful is released as a pip package as well as a ros deb package : dependencies should work from install space as well
- ROS_DISTRO=indigo ROS_FLOW=install
- ROS_DISTRO=indigo PYTHON=2.7
- ROS_DISTRO=indigo PYTHON=3.4

- ROS_DISTRO=kinetic ROS_FLOW=devel
# Rostful is released as a pip package as well as a ros deb package : dependencies should work from install space as well
- ROS_DISTRO=kinetic ROS_FLOW=install
- ROS_DISTRO=kinetic PYTHON=2.7
- ROS_DISTRO=kinetic PYTHON=3.4

# TODO : pypy + pypy3


# We need to get a ROS distro to be able to test rostful
# from different ros environments, or
# from different virtualenv using site-packages.
before_install:
# Getting docker ros image
- docker pull ros:${ROS_DISTRO}-ros-core
# Running as daemon
- docker run --name ${CONTAINER_NAME} -d -t ros:${ROS_DISTRO}-ros-core /bin/bash | tee container.id
# Switching to use ros shadow fixed packages
- docker exec -ti ${CONTAINER_NAME} /bin/bash -c "sed -i.bak -e s,packages.ros.org/ros/ubuntu,packages.ros.org/ros-shadow-fixed/ubuntu, /etc/apt/sources.list.d/ros-latest.list"
# Checking current container
- docker ps -a
- docker exec -ti ${CONTAINER_NAME} hostname
- docker exec -ti ${CONTAINER_NAME} uname -a
- docker exec -ti ${CONTAINER_NAME} cat /etc/lsb-release
env:
# These will be used to determine the proper version of our dependencies
# We will NOT rely on a full ROS installation.
- ROS_DISTRO=indigo
- ROS_DISTRO=kinetic TOX_PARAMS="--hypothesis-profile travis"

# to get latest dependencies (not released in a ROS distro yet)
- ROS_DISTRO=latest TOX_PARAMS="--hypothesis-profile travis"

python:
- 2.7
# NOT READY FOR PY3 YET... (see pyzmp)
#- 3.4
#- 3.5
#- 3.6
#- pypy
#- pypy3

# Add specific python3 versions
matrix:
include:
# explicitely matching python version to the version on the ubuntu distro supported by the ROS LTS distro
#TODO - python: 3.4
# env: ROS_DISTRO=indigo
#TODO - python: 3.5
# env: ROS_DISTRO=kinetic TOX_PARAMS="--hypothesis-profile travis"
exclude:
# explicitely exclude python3 version not supported by matching linux distro
#- python: 3.6
# env: ROS_DISTRO=indigo
#- python: 3.6
# env: ROS_DISTRO=kinetic TOX_PARAMS="--hypothesis-profile travis"

install:
# refreshing packages
- docker exec -ti ${CONTAINER_NAME} apt-get update
- docker exec -ti ${CONTAINER_NAME} rosdep update
# TMP Patch because rosdep doesnt declare a dependency to sudo yet (2016-08-25) and it doesnt come with xenial
- docker exec -ti ${CONTAINER_NAME} apt-get install sudo -y
# Install python and required packages on system if needed
- docker exec -ti ${CONTAINER_NAME} apt-get install python${PYTHON} virtualenvwrapper -y
# copying local clone to the running container (volume is currently broken)
- docker cp . ${CONTAINER_NAME}:/git_clone
# Installing package dependencies
- docker exec -ti ${CONTAINER_NAME} rosdep install --default-yes --from-paths /git_clone --rosdistro $ROS_DISTRO
# getting virtualenv setup with dependencies if we need to work with pure python setup
- if [ ! -z ${PYTHON+undef} ]; then docker exec -ti ${CONTAINER_NAME} /bin/bash -c "source /usr/share/virtualenvwrapper/virtualenvwrapper.sh && mkvirtualenv --system-site-packages -i /git_clone -a /git_clone -q python_${PYTHON}_ros"; fi

- pip install tox tox-travis

script:
- CONTAINER_ID=$(cat container.id)
- docker ps -a
- if [ -z ${PYTHON+undef} ]; then (docker exec -ti ${CONTAINER_NAME} /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash && rospack profile"); fi
# Passing env vars here since passing in docker run currently breaks (2016-08-25)
- if [ -z ${PYTHON+undef} ]; then (docker exec -ti ${CONTAINER_NAME} /bin/bash -c "export ROS_DISTRO=$ROS_DISTRO && export ROS_FLOW=$ROS_FLOW && /git_clone/travis_checks.bash"); fi
# TODO : we need to call nose with --exe here to NOT SKIP tests (but will need to guarantee process isolation)
- if [ ! -z ${PYTHON+undef} ]; then (docker exec -ti ${CONTAINER_NAME} /bin/bash -c "source /usr/share/virtualenvwrapper/virtualenvwrapper.sh && workon python_${PYTHON}_ros && pip install -e /git_clone && /git_clone/travis_checks.bash"); fi

- docker stop "${CONTAINER_ID}"

- tox -- $TOX_PARAMS

notifications:
email: false
38 changes: 0 additions & 38 deletions CMakeLists.txt

This file was deleted.

64 changes: 0 additions & 64 deletions package.xml

This file was deleted.

16 changes: 0 additions & 16 deletions requirements.txt

This file was deleted.

10 changes: 10 additions & 0 deletions requirements/ROS/indigo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Requirements for running on top of indigo

# trusty packages versions to validate behavior with these versions for a potential ROS package for rostful
pytest==2.5.1
pytest-xdist==1.8 # for --boxed
hypothesis==3.0.1 # backported to indigo as https://github.com/asmodehn/hypothesis-rosrelease
numpy>=1.8.1



8 changes: 8 additions & 0 deletions requirements/ROS/kinetic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Requirements for running on top of kinetic

# xenial packages versions to validate behavior with these versions for a potential ROS package for rostful
pytest==2.8.7
pytest-xdist==1.8 # for --boxed
hypothesis==3.0.1
numpy==1.11.0

5 changes: 5 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Requirements to get specific development version fo various dependencies

# -e git+https://github.com/pyros-dev/pyros-common.git#egg=pyros_common
# -e git+https://github.com/pyros-dev/pyros.git@fix_exceptions#egg=pyros

5 changes: 5 additions & 0 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# latest version to validate behavior on pure python env
pytest
pytest-xdist # for --boxed
hypothesis
numpy
3 changes: 3 additions & 0 deletions requirements/tools.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# for release, version doesnt matter, we always work in virtualenv
gitchangelog
twine
2 changes: 0 additions & 2 deletions rosdoc.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion rostful/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import os

# Reference for package structure since this is a flask app : http://flask.pocoo.org/docs/0.10/patterns/packages/
from .context import set_pyros_client, get_pyros_client

# HACK for ROS
from .flaskapp import create_app, setup_app_routes
from .exceptions import WrongMessageFormat, ServiceNotFound, ServiceTimeout, NoPyrosClient
from .context import set_pyros_client, get_pyros_client



### TODO This package also contains a Client
Expand Down
13 changes: 9 additions & 4 deletions rostful/api_0_1/flask_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys

# Reference for package structure since this is a flask app : http://flask.pocoo.org/docs/0.10/patterns/packages/
from rostful import context
from rostful import get_pyros_client

import time

Expand All @@ -26,7 +26,12 @@ def get_suffix(path):
import simplejson
import tblib

from StringIO import StringIO
try:
# Python 2
from cStringIO import StringIO
except ImportError:
# Python 3
from io import StringIO


ROS_MSG_MIMETYPE = 'application/vnd.ros.msg'
Expand Down Expand Up @@ -69,7 +74,7 @@ def get_query_bool(query_string, param_name):
parser = FlaskParser()

import urllib
from pyros_interfaces_common.exceptions import PyrosException
from pyros_common.exceptions import PyrosException
from pyros.client.client import PyrosServiceNotFound, PyrosServiceTimeout
from rostful.exceptions import ServiceNotFound, ServiceTimeout, WrongMessageFormat

Expand Down Expand Up @@ -107,7 +112,7 @@ class BackEnd(restful.Resource): # TODO : unit test that stuff !!! http://flas
def __init__(self, rosname=None):
super(BackEnd, self).__init__()

self.node_client = context.get_pyros_client() # we retrieve pyros client from app context
self.node_client = get_pyros_client() # we retrieve pyros client from app context

# TODO: think about login rest service before disabling REST services if not logged in
def get(self, rosname=None):
Expand Down
25 changes: 15 additions & 10 deletions rostful/flaskapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,27 @@ def create_app(configfile_override=None, logfile=None):

# Rely on ROS to find this package

# TODO : put that at a lower level ? (pyros_setup / pyros_utils / pyros_config ?)
# TODO : put that at a lower level (pyros_setup / pyros_utils / pyros_config ?)
prefix, package_path = helpers.find_package(__package__) # find ROS pkg with same name as this python package
if prefix is None: # not a python installed package (following flask detection logic)
# we are probably installed with ROS
try:
import rospkg
r = rospkg.RosPack()
ros_path = r.get_path(__package__) # find rospkg with same name as this python package
if ros_path.endswith(os.path.join('share', __package__)): # ROS installed package
instance_path = ros_path # using the ROS share path for configuration
# TODO: check if there is a better choice ?
else:
package_path = ros_path # fixing detected package_path in ROS devel case (to access config template file)
instance_path = os.path.join(ros_path, 'instance') # getting instance folder from source

except (ImportError, rospkg.ResourceNotFound): # ROS is not setup OR the package was not found by rospack
try:
ros_path = r.get_path(__package__) # find rospkg with same name as this python package
if ros_path.endswith(os.path.join('share', __package__)): # ROS installed package
instance_path = ros_path # using the ROS share path for configuration
# TODO: check if there is a better choice ?
else:
package_path = ros_path # fixing detected package_path in ROS devel case (to access config template file)
instance_path = os.path.join(ros_path, 'instance') # getting instance folder from source

except rospkg.ResourceNotFound: # the package was not found by rospack
# lets rely on flask detection : this is a develop package
instance_path = os.path.join(package_path, 'instance')

except ImportError: # ROS is not setup
# lets rely on flask detection : this is a develop package
instance_path = os.path.join(package_path, 'instance')
else:
Expand Down
Loading

0 comments on commit ae8e350

Please sign in to comment.