Issue
Is there a way to write a "config" file for the creation of a virtual environment using the virtualenv
module? For example something like this with a yaml-like syntax
python_version: "3.10"
path: "./venv"
requirement_file: "requirements.txt"
post_create:
- python -c "print('hi from venv')"
Which creates a venv using python 3.10 in the directory ./venv, installs the requiremens from "requirements.txt" and then executres a python command "inside" the venv which prints "hi from venv".
Solution
I once wrote a tool for exactly this purpose and have since published the source code on my github as a package called "venvfromfile". I had polished it up a bit and also added some tests. It is currently not available on pypi and there is clearly a lot of room for improvements (for example, something like post_create
is not implemented), but for my purposes this was enough. You can install it as described in the readme. I hope it is helpful.
Answered By - schade96 Answer Checked By - Cary Denson (WPSolving Admin)