title: Setting environment variables in a virtual environment during a pip installation
body: <p>I would like to set environment variables when my Python package is <code>pip install</code>ed, so that the user and scripts in the package have access to something like <code>PACKAGE_HOME</code> whenever in a virtual environment with my package installed.</p>
  <p>I have tried adding the following in <code>setup.py</code>:</p>
  <ol>
  <li><code>os.environ['PACKAGE_HOME'] = 'VALUE'</code></li>
  <li><code>export PACKAGE_HOME=VALUE</code> with <code>subprocess.call</code></li>
  </ol>
  <p>but realized that these variables do not persist beyond the current Python runtime/current shell session.</p>
  <p>For various reasons I currently <code>pip install</code> my package into a conda environment (I am aware that this is potentially a bad idea). Conda documentation offers <a href="https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#saving-environment-variables" rel="nofollow noreferrer">this</a>, but I would like to avoid creating a shell script to execute the listed steps and then calling the script from <code>setup.py</code>, if possible.</p>
  <p>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?</p>