From 89e58cdeaae3cc613a8a56d8767adfaa01d67704 Mon Sep 17 00:00:00 2001 From: AlexV Date: Sun, 14 Apr 2019 18:58:26 +0200 Subject: [PATCH 1/4] pipfile for pipenv to install genmsg and genpy via setuptools. with envrc for direnv setup. --- .envrc | 1 + Pipfile | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .envrc create mode 100644 Pipfile diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..d3bd36e --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +layout pipenv \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..bbf61cf --- /dev/null +++ b/Pipfile @@ -0,0 +1,14 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +ros-genmsg = {editable = true,git = "https://github.com/asmodehn/genmsg.git",ref = "setuptools"} +ros-genpy = {editable = true,git = "https://github.com/asmodehn/genpy.git",ref = "setuptools-kinetic"} +pytest = "*" + +[requires] +python_version = "3.6" From 54f46ab3bddfacda9ffd2e9b688ae1b98eb7d206 Mon Sep 17 00:00:00 2001 From: AlexV Date: Sun, 14 Apr 2019 19:13:42 +0200 Subject: [PATCH 2/4] now relying on tox-pipenv in the environment for tox to use pipenv to setup virtualenvs via pipfile. --- .travis.yml | 1 + Pipfile | 3 +++ requirements-dev.txt | 14 -------------- tox.ini | 6 ++---- 4 files changed, 6 insertions(+), 18 deletions(-) delete mode 100644 requirements-dev.txt diff --git a/.travis.yml b/.travis.yml index 8e2530d..c4c4ecb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ python: - 3.4 - 3.5 - 3.6 + - 3.7 #- pypy #- pypy3 diff --git a/Pipfile b/Pipfile index bbf61cf..b65de77 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,9 @@ verify_ssl = true ros-genmsg = {editable = true,git = "https://github.com/asmodehn/genmsg.git",ref = "setuptools"} ros-genpy = {editable = true,git = "https://github.com/asmodehn/genpy.git",ref = "setuptools-kinetic"} pytest = "*" +pytest-xdist = "*" +gitchangelog = "*" +twine = "*" [requires] python_version = "3.6" diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index f54ec84..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,14 +0,0 @@ -gitchangelog -twine - -# this is needed as install dependency since we embed tests in the package. -pytest>=2.5.1 -pytest-xdist # for --boxed (careful with the version it will be moved out of xdist) - - -# source access to latest filefinder from git ... -# -e git+https://github.com/asmodehn/filefinder2.git#egg=filefinder2 - -# ros dependencies (necessary when running tests from install) --e git+https://github.com/asmodehn/genmsg.git@setuptools#egg=ros_genmsg --e git+https://github.com/asmodehn/genpy.git@setuptools-kinetic#egg=ros_genpy diff --git a/tox.ini b/tox.ini index 9014991..cdc038a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ # content of: tox.ini , put in same dir as setup.py [tox] -envlist = py27, py34, py35, py36 +envlist = py27, py34, py35, py36, py37 #, pypy #, pypy3 skip_missing_interpreters=true @@ -10,6 +10,7 @@ skip_missing_interpreters=true 3.4 = py34 3.5 = py35 3.6 = py36 +3.7 = py37 # not tested yet #pypy = pypy @@ -28,9 +29,6 @@ skipsdist=True [testenv] whitelist_externals = git -deps = - # only when we want to test latest unreleased filefinder2 | genpy | genmsg - -rrequirements-dev.txt # to always force recreation and avoid unexpected side effects recreate=True From 65c5aceca4e6fa4199a9761a9e5ffbbde675cc49 Mon Sep 17 00:00:00 2001 From: AlexV Date: Thu, 18 Apr 2019 16:34:04 +0200 Subject: [PATCH 3/4] reviwing pipfile and CI after master merge. --- .travis.yml | 12 ++++++------ Pipfile | 14 ++++++-------- README.rst | 5 +++-- tox.ini | 3 +++ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4c4ecb..7d32218 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +dist: xenial language: python branches: @@ -5,15 +6,14 @@ branches: - gh-pages python: - - 2.7 - - 3.4 - - 3.5 - - 3.6 - - 3.7 + - '2.7' + - '3.4' + - '3.5' + - '3.6' + - '3.7' #- pypy #- pypy3 -before_install: install: - pip install tox tox-travis diff --git a/Pipfile b/Pipfile index b65de77..6b090f1 100644 --- a/Pipfile +++ b/Pipfile @@ -4,14 +4,12 @@ url = "https://pypi.org/simple" verify_ssl = true [dev-packages] - -[packages] -ros-genmsg = {editable = true,git = "https://github.com/asmodehn/genmsg.git",ref = "setuptools"} -ros-genpy = {editable = true,git = "https://github.com/asmodehn/genpy.git",ref = "setuptools-kinetic"} -pytest = "*" -pytest-xdist = "*" gitchangelog = "*" twine = "*" +pytest = "*" +pytest-xdist = "*" -[requires] -python_version = "3.6" +[packages] +pyros-genmsg = "*" +pyros-genpy = "*" +filefinder2 = "*" diff --git a/README.rst b/README.rst index 4d7b67f..672a6bd 100644 --- a/README.rst +++ b/README.rst @@ -62,7 +62,8 @@ Usage: with rosimport.RosImporter(): import my_msgs.msg # directly from a my_msgs/msg directory containing My.msg ros definition - # Or relatively : - from . import msg # modules are still available, but importer has been deactivated. +Relative imports are supported, as well as all the import semantics of python3 (even in python2, thanks for filefinder2) + +TODO : TermtoSVG / ASCIInema ! diff --git a/tox.ini b/tox.ini index cdc038a..8b3f567 100644 --- a/tox.ini +++ b/tox.ini @@ -32,6 +32,9 @@ whitelist_externals = git # to always force recreation and avoid unexpected side effects recreate=True +deps= + pytest + pytest-xdist commands= git submodule sync -q From 08a2405be81cf4cb0a571f19e3d1b3862929c2c5 Mon Sep 17 00:00:00 2001 From: alexv Date: Wed, 5 Jun 2019 11:57:07 +0200 Subject: [PATCH 4/4] adding example package --- example/MyPyRosPkg/__init__.py | 12 ++++++++++++ example/MyPyRosPkg/msg/mymsg.msg | 1 + example/README.rst | 28 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 example/MyPyRosPkg/__init__.py create mode 100644 example/MyPyRosPkg/msg/mymsg.msg create mode 100644 example/README.rst diff --git a/example/MyPyRosPkg/__init__.py b/example/MyPyRosPkg/__init__.py new file mode 100644 index 0000000..588465f --- /dev/null +++ b/example/MyPyRosPkg/__init__.py @@ -0,0 +1,12 @@ +import sys +import rosimport + +with rosimport.RosImporter(): + + from . import msg + +print("dir(msg) ->" + repr(dir(msg))) + +import inspect +print("inspect.getsource(msg.mymsg) ->") +print(inspect.getsource(msg.mymsg)) diff --git a/example/MyPyRosPkg/msg/mymsg.msg b/example/MyPyRosPkg/msg/mymsg.msg new file mode 100644 index 0000000..cb8d81e --- /dev/null +++ b/example/MyPyRosPkg/msg/mymsg.msg @@ -0,0 +1 @@ +string mystring diff --git a/example/README.rst b/example/README.rst new file mode 100644 index 0000000..7da9ded --- /dev/null +++ b/example/README.rst @@ -0,0 +1,28 @@ +HOW TO USE +========== + +Use a virtualenv. If you are not sure how, you can do some very useful reading at https://packaging.python.org/tutorials/managing-dependencies/ + +If you have direnv (and pipenv) on your machine, this is done as soon as you 'cd' into rosimport working tree. + + +1) Install rosimport in the virtualenv:: + + (rosimport--FuygrvY)alexv@AlexV-ROS-vbox:~/rosimport$ pipenv install -e . + Installing -e .… + Adding rosimport to Pipfile's [packages]… + ✔ Installation Succeeded + Pipfile.lock (474337) out of date, updating to (c8604e)… + Locking [dev-packages] dependencies… + ✔ Success! + Locking [packages] dependencies… + ✔ Success! + Updated Pipfile.lock (474337)! + Installing dependencies from Pipfile.lock (474337)… + 🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 — 00:00:02 + (rosimport--FuygrvY)alexv@AlexV-ROS-vbox:~/rosimport$ + +2) Import the package to trigger the import sequence + + +