Skip to main content

Turn Python installations into venv-like environments that you can activate

Project description

venvify

Python package to turn Python installations into venv-like environments that you can activate.

Say you have the following python installation:

python_env
|- bin
|   |- python3.9
|- include
|- lib

Then you can venvify it by running the following script:

venvify ~/python_env

The result:

python_env
|- bin
|   |- python3.9
|   |- python (symlink)
|   |- python3 (symlink)
|   |- activate
|   |- activate.sh
|   |- etc.
|- include
|- lib

Now you can source the activate file to use the environment as you would use a venv:

user@laptop: source python_env/bin/activate
(python_env) user@laptop: python -m pip install <some_package>

To undo the venvifying, simply remove the activate scripts and the symlinks from the bin directory.

Installation

All the logic of the package can be found in a single script venvify.py. The only dependency is the venv Python standard library package. venv should be shipped with Python 3, but can be installed with sudo apt install python3-venv.

So if you don't want to pip install, you can clone this repo and simply run venvify.py with any Python interpreter.

However if you don't mind you can:

pip install venvify

And then run the venvify command.

Use case: Blender Python environment

I made this package to make developing python scripts for Blender a bit more convenient.

Blender ships with its own Python installation. But specifying the entire path to the Blender Python executable is tedious. My initial solution was to add an alias bpython to my .bashrc. This relieved the burden of typing long paths, but another problem remained.

Some Python packages come with command line entry points. For example, a package I use BlenderProc has a command blenderproc. After installing BlenderProc into the Blender Python installation, there was no way access this command.

However, when you install such a package into a virtual environment, its commands are exposed after sourcing the created activate file. Hence this package, which allowed me to activate the Blender Python environment and use the commands of the installed Python packages.

TODO

Maybe in the future this package could also ensure pip gets installed into the environment.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

venvify-0.0.2.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

venvify-0.0.2-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page