Closed leetschau closed 2 years ago
It looks not useful to install to a specific venv without using it.
You just switch to that venv by pdm use
and do pdm install
@frostming I tried to install dependencies in the virtualenv with the following commands:
pdm venv create --name testenv --with venv 3.9
eval $(pdm venv activate testenv)
pdm install
However, it install dependencies into pdm install
can not install dependencies in virtualenv.
Are my operations above to install deps in virtualenv right?
Thanks.
By pdm use
you tell PDM to use which interpreter and env, while pdm venv activate
is only the shell magic same as the old . venv/bin/activate
, it doesn't change the interpreter setting of PDM. The setting saved in .pdm.toml
always takes precedence unless you have PDM_IGNORE_SAVED_PYTHON=1
. You can verify the current interpreter with pdm info
.
So to build a virtualenv according to PDM project definitions, run:
pdm venv create ...
pdm use # choose the interpreter in the virtualenv created above
pdm install
The install
command suggested above is unnecessary.
Thanks.
Hi, I also don't understand what's going on here:
pdm config python.use_venv = True
venv.in_project = True
eval $(pdm venv activate <name>
python.path = /home/<user>/.local/share/pdm/venvs/<env-name>/bin/python
pdm info
shows the same path as python.path
pdm install
-> packages are installed in $PROJECT_ROOT/__pypackages__/
instead of $PROJECT_ROOT/.venv/
??what is going on? I would like to test different versions of libraries under the same python version, which I thought I could do using venv.
I see now that I shouldn't give a name using --name
, given https://github.com/pdm-project/pdm-venv/issues/32, but I don't think that's obvious.
Even then, I would expect packages to be placed under /home/<user>/.local/share/pdm/venvs/<env-name>/
, not $PROJECT_ROOT/__pypackages__/
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: