My project team is updating from Python 2 to Python 3.10, and we are trying to replace our old workflow using new tools. In particular, I want to transition from using virtualenv
to 3.x's built-in venv
module, since it appears that virtualenv
is being side-lined in Python 3.
I know that there are some approaches out there:
Emulating Bash 'source' in Python
Activate venv from within Python3 Script
Please note that we are not using Python packages for the purposes of installing wheels for use on PyPI, but instead to install a Python-based product that has its complete requirements housed in a virtual environment on a Ubuntu system.
This is our current workflow:
- Create a virtual environment using
virtualenv
- Use
pip
andsetuptools
to install our base and test requirements into the venv - Install the main project into the venv and make the venv relocatable, using virtualenv-make-relocatable
- Package that into a Ubuntu package to be used for installation
How should we replace the functionality of activate_this.py
from the old virtualenv
setup?
As I understand it, the activate_this.py
script is/was an artifact of virtualenv
and remapped various stuff in PATH and in the Python site-packages. So, I could just continue to install this script in my installations and everything would probably work just fine. I could also incorporate the suggestion from the venv
module, and source the /path/to/virtual/environment/activate
script programmatically in one way or another.
However, is this an appropriate solution? Will it work properly with the future changes that are happening in Python 3.10+?