Skip to main content

A plugin for pdm that enables virtualenv management

Project description

pdm-venv

Tests pypi version pre-commit Code style: black

A plugin for pdm that enables virtualenv management

Requirements

pdm-venv requires Python>=3.7

Installation

If pdm is installed via pipx(the recommended way), run:

$ pipx inject pdm pdm-venv

Otherwise if pdm is installed via Homebrew, run:

$ $(brew --prefix pdm)/libexec/bin/pip install pdm-venv

Or install with pip to the user site:

$ python -m pip install --user pdm-venv

Note that pdm-venv must be installed to the same environment as pdm.

Usage

pdm-venv enhances pdm's CLI with the support of virtualenv creation and management. With pdm-venv installed, the default value of use_venv will turn to True, you can disable the whole plugin by pdm config use_venv false.

Create a virtualenv

# Create a virtualenv based on 3.8 interpreter
$ pdm venv create 3.8
# Assign a different name other than the version string
$ pdm venv create --name for-test 3.8
# Use venv as the backend to create, support 3 backends: virtualenv(default), venv, conda
$ pdm venv create --with venv 3.9

List all virtualenv created with this project

$ pdm venv list
Virtualenvs created with this project:

-  3.8.6: C:\Users\Frost Ming\AppData\Local\pdm\pdm\venvs\test-project-8Sgn_62n-3.8.6
-  for-test: C:\Users\Frost Ming\AppData\Local\pdm\pdm\venvs\test-project-8Sgn_62n-for-test
-  3.9.1: C:\Users\Frost Ming\AppData\Local\pdm\pdm\venvs\test-project-8Sgn_62n-3.9.1

The name before the colon(:) is the key of the virtualenv which is used in remove and activate commands below.

Remove a virtualenv

$ pdm venv remove for-test
Virtualenvs created with this project:
Will remove: C:\Users\Frost Ming\AppData\Local\pdm\pdm\venvs\test-project-8Sgn_62n-for-test, continue? [y/N]:y
Removed C:\Users\Frost Ming\AppData\Local\pdm\pdm\venvs\test-project-8Sgn_62n-for-test

Activate a virtualenv

Instead of spawning a subshell like what pipenv and poetry do, pdm-venv doesn't create the shell for you but print the activate command to the console. In this way you won't lose the fancy shell features. You can then feed the output to source command to activate the virtualenv without leaving the current shell:

$ . "$(pdm venv activate for-test)"
(test-project-8Sgn_62n-for-test) $  # Virtualenv entered

You can make your own shell shortcut function to avoid the input of long command.

Additionally, if the saved Python interpreter is a venv Python, you can omit the name argument of activate.

Switch Python interpreter

When pdm-venv is enabled, Python interpreters associated with the venvs will also show in the interpreter list of pdm use or pdm init command.

Virtualenv auto creation

If no Python interpreter is selected for the project, pdm-venv will take charge to create on for you and select the venv interpreter automatically, just like what pipenv and poetry do.

Configuration

Config Item Description Default Value Available in Project Env var
venv.location The root directory to store virtualenvs appdirs.user_data_dir() / "venvs" No
venv.backend The default backend used to create virtualenv virtualenv No

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

pdm-venv-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

pdm_venv-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file pdm-venv-0.1.0.tar.gz.

File metadata

  • Download URL: pdm-venv-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for pdm-venv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fbecde811c8fb7fc3a3558f9eab66b8dada8d4ca9ea7924ae2eedd929c306803
MD5 1f435781789b269e5ea8b7e0d7cffb62
BLAKE2b-256 c6a018a163f5f6671aaf754171b46d0d6090b7189ebabd7cc27bc24e4224b7f4

See more details on using hashes here.

Provenance

File details

Details for the file pdm_venv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pdm_venv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for pdm_venv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52ddc1a6e3178a6ea7d14b132f0d21ebe57e2732496ae89822149577cfefbd5f
MD5 2e1a67e20684c6faa2f5137d91ae09e2
BLAKE2b-256 c06cbb95022aba476cf5c26fa1dd260db467724a9b5eafdf95e310943741f53d

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