Skip to content

Commit

Permalink
Updated documentation, CHANGELOGs and package versions for release 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
max-krichenbauer committed Dec 4, 2019
1 parent 2bb0fb4 commit 88d94a6
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 31 deletions.
79 changes: 52 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ Python virtual environment wrapper package, based on [catkin_virtualenv](https:/

This package provides a mechanism to:

- choose that the target package should be run in a virtual Python environment of the desired version
- export python library requirements in `requirements.txt` format via `package.xml`.
- bundle a virtualenv within a ament package, inheriting requirements from any dependencies.
- wrap python scripts and tests in a ament package with a virtualenv loader.

At build time, CMake macros provided by this package will create a virtualenv, and create
wrapper scripts for any Python scripts in the package. Both will be included in any associated bloom artifacts.
At build time, Python commands and CMake macros provided by this package will create a virtualenv, and create
wrapper scripts for Python scripts installed by the in the target package.
Both will be included in the release.

This library is GPL licensed due to the inclusion of dh_virtualenv.

Expand All @@ -35,47 +37,70 @@ Add an export to `package.xml`:
</export>
```

Make sure to install the requirements file in `CMakeLists.txt`:

```cmake
install(FILES requirements.txt
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME})
If your package uses `ament_python` as build tool, add the following to your `setup.py` file:

```python
import setuptools.command.install
import ament_virtualenv.install

class InstallCommand(setuptools.command.install.install):
def run(self):
super().run()
ament_virtualenv.install.install_venv(
install_base=self.install_base,
package_name=package_name,
python_version='2'
)
# instead of self.install_base we may also use:
# self.config_vars['platbase'] or self.config_vars['base']
# Exchange the python_version with '3' if your package uses Python3.
return

setup(
cmdclass={
'install': InstallCommand
},
```

If an ament package exports dependencies in a `requirements.txt` file, any dependent ament package that bundles a virtualenv (see below) will inherit those dependencies.

## Bundling virtualenv

It's possible to bundle all of an ament package's python requirements, as well as those of its ament dependencies, into a virtualenv.
If your package uses `ament_cmake` as build tool, add the following to your `CMakeLists.txt`:

This operation does not do any dependency resolution - similar to how `pip` operates, the topmost dependency declaration
'wins' (https://github.com/pypa/pip/issues/988).
```cmake
find_package(ament_cmake_virtualenv REQUIRED)
ament_generate_virtualenv(PYTHON_VERSION 2)
# Exchange the python_version with '3' if your package uses Python3.

Add an build dependency on ament_virtualenv to `package.xml`, as well as on any library packages you may want. Traditionally
# Tell ament to install your Python module:
ament_python_install_module(path/to/my/module.py)
# ... or a whole folder containing a Python package:
ament_python_install_package(path/to/your/package)

```xml
<build_depend>ament_virtualenv</build_depend>
# Tell ament also to copy the requirements.txt file
install(FILES requirements.txt
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME})

<!-- In an ament/python world, this would normally be an exec_depend. However, if `some_python_library` exports
requirements.txt, it needs to be pulled in at build time as well -->
<depend>some_python_library</depend>
```

In CMakeLists.txt:

```cmake
# Make sure to find-package `ament_cmake_virtualenv`
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_virtualenv REQUIRED)

Finally, add an build dependency on ament_virtualenv to your `package.xml`.

# Generate the virtualenv:
ament_generate_virtualenv()
If you're using `ament_python` as build tool:
```xml
<build_depend>ament_virtualenv</build_depend>
```

# Must be called after target definitons
ament_package()
If you're using `ament_cmake` as build tool:
```xml
<build_depend>ament_cmake_virtualenv</build_depend>
```

If an ament package exports dependencies in a `requirements.txt` file, any dependent ament package that bundles a virtualenv (see below) will inherit those dependencies.
Note that the requirements installation does not do any dependency resolution - similar to how `pip` operates, the topmost dependency declaration
'wins' (https://github.com/pypa/pip/issues/988).


### Additional CMake Options

Expand All @@ -84,7 +109,7 @@ The following options are supported by `ament_generate_virtualenv()`:
```cmake
ament_generate_virtualenv(
# Select an alternative version of the python interpreter - it must be installed on the system. Minor version is optional.
PYTHON_VERSION 3.7 # Default 2
PYTHON_VERSION 3.7 # Default 3

# Choose not to use underlying system packages. This excludes any python packages installed by apt or system-pip from the environment.
USE_SYSTEM_PACKAGES FALSE # Default TRUE
Expand Down
4 changes: 4 additions & 0 deletions ament_cmake_virtualenv/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog for package ament_cmake_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.0.3 (2019-12-04)
------------------
* various bug-fixes

0.0.2 (2019-11-21)
------------------
* various bug-fixes
Expand Down
2 changes: 1 addition & 1 deletion ament_cmake_virtualenv/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<package format="2">
<name>ament_cmake_virtualenv</name>
<version>0.0.2</version>
<version>0.0.3</version>
<description>Bundle python requirements in a ament package via virtualenv.</description>

<maintainer email="[email protected]">Max Krichenbauer</maintainer>
Expand Down
4 changes: 4 additions & 0 deletions ament_virtualenv/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog for package ament_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.0.3 (2019-12-04)
------------------
* various bug-fixes

0.0.2 (2019-11-21)
------------------
* various bug-fixes
Expand Down
2 changes: 1 addition & 1 deletion ament_virtualenv/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<package format="2">
<name>ament_virtualenv</name>
<version>0.0.2</version>
<version>0.0.3</version>
<description>Bundle python requirements in a ament package via virtualenv.</description>

<maintainer email="[email protected]">Max Krichenbauer</maintainer>
Expand Down
7 changes: 7 additions & 0 deletions test_ament_cmake_virtualenv/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package test_ament_cmake_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.0.3 (2019-12-04)
------------------
* added this package to the release
2 changes: 1 addition & 1 deletion test_ament_cmake_virtualenv/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<package format="2">
<name>test_ament_cmake_virtualenv</name>
<version>0.0.2</version>
<version>0.0.3</version>
<description>Package to test ament_cmake_virtualenv</description>
<maintainer email="[email protected]">Max Krichenbauer</maintainer>
<license>GPL</license>
Expand Down
4 changes: 4 additions & 0 deletions test_ament_virtualenv/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog for package test_ament_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.0.3 (2019-12-04)
------------------
* various bug-fixes

0.0.2 (2019-11-21)
------------------
* various bug-fixes
Expand Down
2 changes: 1 addition & 1 deletion test_ament_virtualenv/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<package format="2">
<name>test_ament_virtualenv</name>
<version>0.0.2</version>
<version>0.0.3</version>
<description>Package to test ament_virtualenv.</description>

<maintainer email="[email protected]">Max Krichenbauer</maintainer>
Expand Down

0 comments on commit 88d94a6

Please sign in to comment.