I would like to set environment variables when my Python package is pip installed, so that the user and scripts in the package have access to something like PACKAGE_HOME whenever in a virtual environment with my package installed.
I have tried adding the following in setup.py:
os.environ['PACKAGE_HOME'] = 'VALUE'export PACKAGE_HOME=VALUEwithsubprocess.call
but realized that these variables do not persist beyond the current Python runtime/current shell session.
For various reasons I currently pip install my package into a conda environment (I am aware that this is potentially a bad idea). Conda documentation offers this, but I would like to avoid creating a shell script to execute the listed steps and then calling the script from setup.py, if possible.
Is there a more elegant way to achieve this? I would have thought it common for package installations to set EVs. But so far, having seen that setting venv-persistent EVs from within a Python script is not at all convenient, is this even common/acceptable practice?