Install requirements and run code in virtual environments from the comfort of your own GIL
Project description
Venvception
Venvception is a Python library designed to simplify the process of creating and using temporary virtual environments when you have good reason to stay in the same process. It provides a context manager that automates the setup of a virtual environment, installs specified packages from a requirements.txt
file, and ensures that the environment is used for the duration of the context.
Why?
In distributed contexts, it can be convenient to ship a requirements specification rather than pre-baking containers. This library is quick and dirty.
Installation
To install Venvception, run the following command:
pip install venvception
Quick Start / Usage
Here's a simple example to get started with Venvception:
from venvception import venv
from pathlib import Path
# Specify the path to your requirements file
requirements_path = Path("path/to/your/requirements.txt")
# Use the venv context manager to create and activate the virtual environment
with venv(requirements_path) as venv_path:
# Import a module from the requirements.txt
import your_module
# You can also access the path to the virtual environment via `venv_path`
print(f"Virtual environment created at: {venv_path}")
Ensure your requirements.txt
file is properly formatted and accessible at the specified path.
Accessing the Virtual Environment's Path
The context manager yields the path to the temporary virtual environment, allowing you to interact with it directly:
with venv(Path("requirements.txt")) as venv_path:
print(venv_path)
Contributing
Contributions to Venvception are welcome! Please feel free to submit pull requests, report bugs, or suggest features through the issue tracker.
License
Venvception is released under the MIT License.
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
Built Distribution
File details
Details for the file venvception-0.0.3.tar.gz
.
File metadata
- Download URL: venvception-0.0.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3af527f3b59cd545f393126071edb5d81b371ce928edc69ce1fe0ffe95657abe |
|
MD5 | ec4d2df98a90f56855011ca42a05b30f |
|
BLAKE2b-256 | d54279f5c70eea02725c36ec00459fde966f65812ffd7be91299a89e9388f511 |
File details
Details for the file venvception-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: venvception-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48f1327f2a1b1e5d9be8944366b7069e612be7e812d50b697730ec6fa4ec5e1f |
|
MD5 | 60d1a17330b4f17336c3dd1e8da34203 |
|
BLAKE2b-256 | bc611196065421685bab8ad5b5107e45d36c04653778ac69f2635eeda836e477 |