Skip to main content

Project-level Python virtual environment management tool.

Project description

PyEM manages multiple virtual environments local to projects. It provides shortcuts to create, remove, switch between, and run commands against virtual environments created against various Python interpreters.

In Action

Add a virtual environment:

$ pyem venv add python3.7  # Based on a command.

$ pyem venv add 3.6  # Based on interpreter found by the Python launcher.

$ pyem venv add /usr/local/bin/pypy3  # Based on an executable.

The second variant relies on the Python launcher to locate an interpreter. This tool should be installed by default if you use the officlal installer on Windows (and do not explicitly choose not to install it). For other platforms, Python launcher for UNIX by Brett Cannon can be used as an alternative.

List managed virtual environments:

$ pyem venv list
  Quintuplet
=============================================
  cpython-3.6-darwin-x86_64-f14a3513
  cpython-3.7-darwin-x86_64-dbe83ac5
* pypy-3.6-darwin-x86_64-dc1298a1

Set active virtual environment:

$ pyem venv set 3.7
Switched to cpython-3.7-darwin-x86_64-dbe83ac5

$ pyem venv set 3.6
Error: name '3.6' is ambiguous; choose from:
  cpython-3.6-darwin-x86_64-f14a3513
  pypy-3.6-darwin-x86_64-dc1298a1

$ pyem venv set cpython-3.6
Switched to cpython-3.6-darwin-x86_64-f14a3513

Run a command inside a virtual environment:

$ pyem poetry run python -c "import sys; print(sys.executable)"
/tmp/exampleproject/.venvs/bin/python

$ pyem --spec=pypy-3.6 pipenv run pypy3 -c "import sys; print(sys.executable)"
/tmp/exampleproject/.venvs/bin/pypy3

How does this work?

PyEM sets environment variables VIRTUAL_ENV and PATH, and hand off control to subprocess for the command specified. This is enough to trick a lot of Python project tools, including Python launcher, Poetry, and Pipenv. Python interpreters with venv support (e.g. CPython 3.3 or later) should also integrate seamlessly.

Flit is more difficult to trick since it does not automatically inspect environment variables like other tools do. Use this workaround instead:

$ pyem flit install --python=python

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

pyem-0.2.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

pyem-0.2.0-py2.py3-none-any.whl (34.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyem-0.2.0.tar.gz.

File metadata

  • Download URL: pyem-0.2.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.22.0

File hashes

Hashes for pyem-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4194bf986c46bc16b333933be5af0919c946f68294687de851f48c6bedc2c624
MD5 0ef1a969d2564d01737147618a52a2af
BLAKE2b-256 43ce61a52c7cc53b2d9006ed4db99a3b737aea0a7aaa2b1ab29c4c3d46915c27

See more details on using hashes here.

Provenance

File details

Details for the file pyem-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pyem-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.22.0

File hashes

Hashes for pyem-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 73acffbd595fdcedcc6964e3e57c1a142b92bfc9cd4b2e52d4e1c9c3a903755f
MD5 186069ea663bb0211721d6703821af0f
BLAKE2b-256 cfe9f94272295d7ba40236ff82b6b6e030a0469ae8c2713376b670d013c4a6d0

See more details on using hashes here.

Provenance

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