Portable way to define env vars automatically on activating virtual environment

Hi,

I would like to set some environment variables when I activate a virtual environment.

Up to now I modify the created bin/activate. But that’s not nice, because:

  • this file is not stored in version control
  • changing it is manual work
  • it works only for Linux (not for Windows)
  • It does not work if I call a script which was installed via setup.cfg [scripts]

Any idea how this could be solved.

I am lucky, and know that I have Python >= 3.8.

1 Like

You could have a script in your repo which both creates a virtual environment and modified any activation scripts to set your environment variables.

1 Like