Main goal: make it easy to work with Python code inside a worktree, i.e avoid having to manually set PYTHONPATH and other environment variables.
We’ll use pip and virtualenv because they are becoming the standard to deal with this kind of issues.
More precisely:
Handle 3rd-party libraries
to use ‘import foo’ and directly use the code from <worktree>/foo, without having to write a setup.py
Handle python extensions written in C++ depending one one or more qibuild CMake projects.
Handle C++ code that embeds a Python interpreter and loads Python extensions.
This is useful for instance in qidoc, to specify the sphinx version and its deps, or the tools in spinxcontrib, and so on.
This is also useful for whatever Python project.
For instance, for qidoc, we read the requirements.txt from the templates repo if it exists and use a virtualenv in .qi/venv/qidoc
<qiproject version="3">
<pyproject name="foo" />
</qiproject>
Again, the same thing, but we use virtualenv --python=${PYTHON_EXECUTABLE}, wher PYTHON_EXECUTABLE is found by CMake. So if you are using Python from your system, nothing changes, and if you are using Python from a toolchain, you use it in the virtualenv.
Examples:
I want to run py.test on the foo project that depends on the bar project.
pytest
$ qivenv use default
$ qibuild configure -c <config> myext
$ qivenv add <config>
$ qivenv use <config>
$ python
>>> import myext