- Notifications
You must be signed in to change notification settings - Fork2
locusrobotics/ament_virtualenv
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Python virtual environment wrapper package, based oncatkin_virtualenv.
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.txtformat viapackage.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, Python commands and CMake macros provided by this package will create a virtualenv, and createwrapper 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.
The package containing python modules with external library dependencies should define arequirements.txt:
GitPython>=2.1.5psutil>=5.2.2wrapt>=1.10.10
Add an export topackage.xml:
<export> <pip_requirements>requirements.txt</pip_requirements></export>
If your package usesament_python as build tool, add the following to yoursetup.py file:
importsetuptools.command.installimportament_virtualenv.installclassInstallCommand(setuptools.command.install.install):defrun(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.returnsetup(cmdclass={'install':InstallCommand },
If your package usesament_cmake as build tool, add the following to yourCMakeLists.txt:
find_package(ament_cmake_virtualenv REQUIRED)ament_generate_virtualenv(PYTHON_VERSION 2)# Exchange the python_version with '3' if your package uses Python3.# 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)# Tell ament also to copy the requirements.txt fileinstall(FILES requirements.txtDESTINATION${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME})
Finally, add an build dependency on ament_virtualenv to yourpackage.xml.
If you're usingament_python as build tool:
<build_depend>ament_virtualenv</build_depend>
If you're usingament_cmake as build tool:
<build_depend>ament_cmake_virtualenv</build_depend>
If an ament package exports dependencies in arequirements.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 howpip operates, the topmost dependency declaration'wins' (pypa/pip#988).
The following options are supported byament_generate_virtualenv():
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 3# Choose not to use underlying system packages. This excludes any python packages installed by apt or system-pip from the environment. USE_SYSTEM_PACKAGESFALSE# Default TRUE# Disable including pip requirements from catkin dependencies of this package. ISOLATE_REQUIREMENTSTRUE# Default FALSE# Provide extra arguments to the underlying pip invocation EXTRA_PIP_ARGS --no-binary=:all: -vvv)
About
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- Python87.8%
- CMake11.7%
- Shell0.5%