pdm-project / pdm-venv Goto Github PK
View Code? Open in Web Editor NEWA plugin for pdm that enables virtualenv management
Home Page: https://pdm-project.github.io/pdm-venv
License: MIT License
A plugin for pdm that enables virtualenv management
Home Page: https://pdm-project.github.io/pdm-venv
License: MIT License
Describe the bug
On fedora 34 with python 3.9, running pdm plugin add -v pdm-venv
results in the following error:
Running pip command: ['install', 'pdm-venv']
Traceback (most recent call last):
File "/home/oulongwu/.local/lib/python3.9/site-packages/pdm/cli/commands/plugin.py", line 110, in handle
run_pip(pip_args)
File "/home/oulongwu/.local/lib/python3.9/site-packages/pdm/cli/commands/plugin.py", line 36, in run_pip
return subprocess.check_output(
File "/usr/lib64/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib64/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-I', '/usr/lib/python3.9/site-packages/pip', 'install', 'pdm-venv']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/oulongwu/.local/bin/pdm", line 8, in <module>
sys.exit(main())
File "/home/oulongwu/.local/lib/python3.9/site-packages/pdm/core.py", line 194, in main
return Core().main(args)
File "/home/oulongwu/.local/lib/python3.9/site-packages/pdm/core.py", line 152, in main
raise cast(Exception, err).with_traceback(traceback)
File "/home/oulongwu/.local/lib/python3.9/site-packages/pdm/core.py", line 147, in main
f(options.project, options)
File "/home/oulongwu/.local/lib/python3.9/site-packages/pdm/cli/commands/plugin.py", line 112, in handle
spinner.fail("Installation failed: \n" + e.output)
TypeError: can only concatenate str (not "bytes") to str
To Reproduce
Steps to reproduce the behavior:
pdm
with pip3 install --user pdm
pdm-venv
with pdm plugin add pdm-venv
Expected behavior
Install pdm-venv
successfully with pdm plugin add pdm-venv
.
Screenshots
If applicable, add screenshots to help explain your problem.
System (please complete the following information):
pdm-venv
version: 0.2.0Additional context
Add any other context about the problem here.
Describe the bug
I get an error when running any command
Failed to load plugin venv=pdm_venv.plugin:entry_point: cannot import name 'is_venv_python' from 'pdm.utils' (/home/vscode/.local/lib/python3.10/site-packages/pdm/utils.py)
To Reproduce
Steps to reproduce the behavior:
pdm config -vv
Failed to load plugin venv=pdm_venv.plugin:entry_point: cannot import name 'is_venv_python' from 'pdm.utils' (/home/vscode/.local/lib/python3.10/site-packages/pdm/utils.py)
Site/default configuration (/etc/xdg/pdm/config.toml):
# Isolate build environment from the project environment
build_isolation = True
# The root directory of cached files
cache_dir = /home/vscode/.cache/pdm
# Check if there is any newer version available
Expected behavior
Maybe we should inform users about pdm-venv
integration because it was a surprise for me and I spent some time defining the problem's origin.
System (please complete the following information):
pdm
version: 2.0.0pdm-venv
version: 0.5.0The workflow code_quality.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.
I still use a virtualenv for my projects since it is easier since VSCode is able to automatically detect a venv folder if it is in the workspace directory, and hence all type hintings/imports get detected automatically without any further steps required.
Something similar that was implemented for Poetry python-poetry/poetry#108
Poetry has a config key as follows:
virtualenvs.in-project = true
Describe the bug
I thought that one of the benefits of pdm-venv
was to not type pdm run [comand]
every time. However, I could not invoke CLI commands from other packages without running pdm run
, even when the environment is activated
(.venv) anhoang@c2b9 /lab/corradin_biobank/FOR_AN/test-project$ which python
/lab/corradin_biobank/FOR_AN/test-project/.venv/bin/python
(.venv) anhoang@c2b9 /lab/corradin_biobank/FOR_AN/test-project$ which pdm
/home/anhoang/.local/bin/pdm
(.venv) anhoang@c2b9 /lab/corradin_biobank/FOR_AN/test-project$ which jupyter
/lab/corradin_data/FOR_AN/anaconda3/envs/jupyterlab/bin/jupyter
#should be /lab/corradin_biobank/FOR_AN/test-project/.venv/bin/jupyter
To Reproduce
Steps to reproduce the behavior:
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
into $HOME/.local/bin
. Then pdm plugin add pdm-venv
pdm config venv.in_project True; pdm config install.cache True
test-project
pdm use 3.9; pdm venv create; pdm add nbdev, jupyter
eval $(pdm venv activate in-project)
jupyter
or nbdev_new
pdm run jupyter
and pdm run nbdev_new
works as expectedSystem (please complete the following information):
pdm-venv
version: 0.5.0The multiple virtual environments for one project is great. From what I understand, it just changes the python interpreter version right? Or does it create a whole new environment that I can add packages of different versions than the original environment?
Use case: I use a package X along with other packages (Y, Z for example ) for my project. I want to use them all with python 3.8 . However, package X developers pin exact version requirements for multiple packages including Y and Z (in order to, per my understanding, ease maintaining efforts).
I cannot use the latest versions with Y and Z with package X in the same environment so I want to create multiple python 3.8 environments, one with Y and Z at latest version and one with X,Y,Z. I want both environments to be associated with the project and their package versions to both be listed in pyproject.toml
file so users can recreate these two environments and reproduce my data analysis (project is not a python package).
Is this currently possible with PDM?
Describe the bug
A clear and concise description of what the bug is.
pdm venv activate
doesn't work in powershell. Calling the command doesn't activate the venv env.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Calling pdm venv activate
should auto detect the shell used and activate the appropriate script as by manually run activate.ps1
works.
Screenshots
If applicable, add screenshots to help explain your problem.
System (please complete the following information):
pdm-venv
version: 0.2.0Additional context
Add any other context about the problem here.
pdm-venv is installed via pdm plugin add pdm-venv
To Reproduce
pdm venv create --with conda 3.8
. "$(pdm venv activate 3.8)"
Expected behavior
It to activate the conda venv
Actual behavior
.: no such file or directory: /home/mateo/.local/share/pdm/venvs/testing-pdm-PNG08dao-3.8/bin/activate
System (please complete the following information):
pdm-venv
version: 0.2.0pdm
version: 1.7.0Additional context
Thank you for the awesome python project! :)
Would it be possible to support the creation of a virtual environment in the project folder?
pdm-venv allows for easy install and cleanup of virtual environments as well as activation. It would be handy in some cases to create the virtual environment in the project directory.
Thanks for the great work! I've been enjoying pdm and pdm-venv.
With a fresh install of pdm and pdm-venv (installed and injected via pipx), I cannot create virtual environments.
pdm version: 1.8.0
pdm-venv version: 0.3.0
Python version: 3.7
OS: Windows
I wish I had more to report, but I hit a brick wall and the verbose option doesn't provide more insight. Let me know what else would help to debug this issue.
If a user installs pdm via pipx, and then installs pdm-venv via injection, there is no clear way to check the installed version of pdm-venv. A simple:
pdm venv --version would be helpful.
Describe the bug
As mentioned in docs if pdm config venv.in_project
is set to true, then virtual-env is created in project directory. This feature is not working while using pdm venv create
.
To Reproduce
Steps to reproduce the behavior:
pdm config venv.in_project True
and then pdm venv create
Expected behavior
A virtual-env should have been created in the project directory.
Current behavior
Virtual env is getting created in the location specified under venv.location
config
Screenshots
NA
System :
pdm-venv
version: 0.4.0Additional context
As create method supports in_project
argument, but it is always falling back to default value, due to in create command this argument is not passed from the project config.
The workflow code_quality.yml is referencing action pre-commit/action using references v2.0.0. However this reference is missing the commit 80db042ff08cdddbbbfb6f89c06a6bfc4dddf0b7 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.
Describe the bug
Basically I have added section to pyproject.toml file (not .pdm.toml):
[tool.pdm.venv]
in_project = true
To Reproduce
Steps to reproduce the behavior:
pdm install
Expected behavior
venv is created in project directory.
When create a venv with conda
, why do we still need to specify the python interpreter? Shouldn't conda
take care of it? Currently, on my machine, with /usr/bin/python
(3.9):
pdm venv create -w conda 3.9
conda
will install python 3.10
, it makes no sense to specify 3.9 here.
Only with
pdm venv create -w conda 3.9 python=3.8
can I install python 3.8.12
. Again, 3.9
here in the command line makes no sense.
I set things up last week with this:
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python -
echo "export PATH=${HOME}/.local/bin:$PATH > ~/.zshrc"
pdm --pep582 >>~/.zshrc
pdm plugin add pdm-venv
My host is an Apple M1 13" from end of 2020.
Last week executing eval (pdm venv activate 3.8)
was rather fast.
This week it seems to get stuck for almost a minute on pdm venv activate 3.8
:
armenzg@Armens-M1-MBP-2 python-arm64-wheels % set -x
armenzg@Armens-M1-MBP-2 python-arm64-wheels % eval "$(pdm venv activate 3.8)"
+-zsh:3> pdm venv activate 3.8
Many commands raise ModuleNotFoundError: No module named 'editables'
after installing the project with pdm install
To Reproduce
I have setup a repo to illustrate:
git clone [email protected]:CharString/issue649.git
cd issue649
pdm venv create
pdm install
pdm run python foo.py
It's named after pdm-project/pdm#649, but that one was solved, because using pep582 works fine.
Expected behavior
I expect the same behaviour as without the plugin. When I remove the venv and use pep582 it works:
pdm venv remove
pdm use
pdm install
pdm run python foo.py
Screenshots
$ git clone [email protected]:CharString/issue649.git
Cloning into 'issue649'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
Receiving objects: 100% (7/7), done.
remote: Total 7 (delta 0), reused 7 (delta 0), pack-reused 0
$ cd issue649/
$ pdm install
⠙ Resolving packages from lockfile...
⠋ Resolving packages from lockfile...
created virtual environment CPython3.9.5.final.0-64 in 109ms
creator CPython3Posix(dest=/export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/export/scratch1/home/ccw/.local/share/virtualenv)
added seed packages: pip==21.3.1, setuptools==58.5.3, wheel==0.37.0
activators BashActivator,CShellActivator,FishActivator,NushellActivator,Power⠙ Resolving packages from lockfile...
Virtualenv /export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue6All packages are synced to date, nothing to do.
Installing the project as an editable package...
✔ Install issue649 0.0-alpha successful
🎉 All complete!
$ pdm run python foo.py
Error processing line 1 of /export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/issue649.pth:
Traceback (most recent call last):
File "/usr/lib64/python3.9/site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/_issue649.py", line 1, in <module>
from editables.redirector import RedirectingFinder as F
ModuleNotFoundError: No module named 'editables'
Remainder of file ignored
Error processing line 1 of /export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/issue649.pth:
Traceback (most recent call last):
File "/usr/lib64/python3.9/site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/_issue649.py", line 1, in <module>
from editables.redirector import RedirectingFinder as F
ModuleNotFoundError: No module named 'editables'
Remainder of file ignored
Error processing line 1 of /export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/issue649.pth:
Traceback (most recent call last):
File "/usr/lib64/python3.9/site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/_issue649.py", line 1, in <module>
from editables.redirector import RedirectingFinder as F
ModuleNotFoundError: No module named 'editables'
Remainder of file ignored
Error processing line 1 of /export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/issue649.pth:
Traceback (most recent call last):
File "/usr/lib64/python3.9/site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/_issue649.py", line 1, in <module>
from editables.redirector import RedirectingFinder as F
ModuleNotFoundError: No module named 'editables'
Remainder of file ignored
Error processing line 1 of /export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/issue649.pth:
Traceback (most recent call last):
File "/usr/lib64/python3.9/site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/_issue649.py", line 1, in <module>
from editables.redirector import RedirectingFinder as F
ModuleNotFoundError: No module named 'editables'
Remainder of file ignored
Error processing line 1 of /export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/issue649.pth:
Traceback (most recent call last):
File "/usr/lib64/python3.9/site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/export/scratch1/home/ccw/.local/share/virtualenvwrapper/envs/issue649-v-dGyFzm-3.9/lib64/python3.9/site-packages/_issue649.py", line 1, in <module>
from editables.redirector import RedirectingFinder as F
ModuleNotFoundError: No module named 'editables'
Remainder of file ignored
System (please complete the following information):
$ cat /etc/system-release
Fedora release 32 (Thirty Two)
$ pipx runpip pdm freeze
appdirs==1.4.4
atoml==1.1.0
attrs==21.2.0
backports.entry-points-selectable==1.1.0
cached-property==1.5.2
click==8.0.3
distlib==0.3.3
editables==0.2
filelock==3.3.2
installer==0.3.0
packaging==21.2
pdm==1.11.1
pdm-pep517==0.9.2
pdm-venv==0.3.1
pep517==0.12.0
platformdirs==2.4.0
pyparsing==2.4.7
python-dotenv==0.19.1
pythonfinder==1.2.8
resolvelib==0.8.1
shellingham==1.4.0
six==1.16.0
tomli==1.2.2
virtualenv==20.10.0
Is your feature request related to a problem? Please describe.
Install dependencies in virtual env is not straightforward.
Describe the solution you'd like
Add a install
command: pdm venv install [<env-name>]
.
Describe alternatives you've considered
Or maybe pdm already has this tool?
Additional context
Under the hood, this command do:
pdm export -f requirements > requirements.txt
eval $(pdm venv activate <env-name>) # or the first virtualenv if <env-name> not provided in `install` command above
pip install -r requirements.txt
rm requirements.txt
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.