Build System
The Ark cmake build system provides the ability to generate Python virtual environments for specialized targets (and to use those virtual environments as dependencies for those targets).
The general format is:
add_python_venv(
"my_venv_name"
PACKAGES
websocket-client
torch
pyyaml
ARK_LIBRARIES
"path/to/library/in/repo"
RBUFS
rbuf_target_name
)
The virtual environment will be constructed for you as part of the build process and located
in the build/virtualenvs
directory (for example, build/virtualenvs/my_venv_name
).
It will automatically use pip
to install the websocket-client, torch, and pyyaml packages.
It will then copy the paths to the libraries that you gave directly into the virtual environment’s
site packages, such that they can be imported. It’s assumed that each path given to ARK_LIBRARIES
is a path to a directory that contains, at a minimum, a __init__.py
file.
Finally, any rbuf target given will have the rbuf compiler invoked to generate native Python code,
and that will be installed into the virtual environment in a library that matches the target name. For
example, if you use ark_image_messages
as a target, it will create a Python module named ark_image_messages
that you can import from.
A few other options that might be interesting:
BINDINGS
- Copies a pybind11 module into the virtual environmentREPOS
- Passes the repo to PIP, compiling it and installing it into your virtual environmentLINKS
- Passes the list of links to PIP, as an alternate source for packages
Dependencies
You must manually add your virtual environment as a dependency to some other target for it to be
built automatically (or run ./make.sh my_venv_name
to explicitly build that virtual environment).
For example:
add_dependencies(my_target my_venv_name)