Skip to main content

Install requirements and run code in virtual environments from the comfort of your own GIL

Project description

Venvception

GitHub Workflow Status (with event)

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.

venvception in action

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

venvception-0.0.4.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

venvception-0.0.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file venvception-0.0.4.tar.gz.

File metadata

  • Download URL: venvception-0.0.4.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for venvception-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c983a907e464c87a72dbbd3c4ea13c779969c8f3eaf505a2817a0a1c9e713bb0
MD5 e6d507e4708a44b078b26ec965b83719
BLAKE2b-256 f02e381e84903df5201fa4c9b56d6151e8ec52f8e7444eb9585692ebf8170048

See more details on using hashes here.

File details

Details for the file venvception-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: venvception-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for venvception-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1cd71ab496fe8c833d654e1458aa4130f99ab8f07ac43ffa6cd7d89347a59137
MD5 dbe0d6e1a9da4c4f4fc8750e56591446
BLAKE2b-256 7028755bd46c9be7ee77d126f6fb6282e0bdf908d68afb311023a2614cdbb025

See more details on using hashes here.

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