virtualenv icon indicating copy to clipboard operation
virtualenv copied to clipboard

Hook for post virtualenv creation

Open earonesty opened this issue 3 years ago • 1 comments

What's the problem this feature will solve?

When creating a new virtualenv there may be some things like:

  • sitecustomize files
  • seeded packages that patch/repair builtins
  • other things

Many programs and scripts create virtual environments. Finding and changing all of them to call your custom thing might not be easily done.

Describe the solution you'd like It would be cool if, every time a virtualenv is created, if a 'finalizer' program can be set to run (pretty similar to the seeder, but not specifically about wheel and pip).

Working dir can be the root of the venv.

A simple example could be copying in a sitecustomize.py that replaces the built-in openssl package with pyopenssl. Or other patchers for systems that don't work well in containers.

Alternative Solutions Sure, you can just run a program every time virtualenv is used. Or wrap the virtualenv command-line in a bash script, and hope nobody runs python -m virtualenv

Additional context This is useful when building CI-runners that don't necessarily have access to the code that will be creating virtualenvs.

earonesty avatar Mar 18 '21 19:03 earonesty

I'm not against this, so feel free to open a PR that implements this.

gaborbernat avatar Mar 18 '21 19:03 gaborbernat

As this is 2 years old without updates closing it. If still valid we can reopen.

gaborbernat avatar Jun 27 '23 03:06 gaborbernat