Giter VIP home page Giter VIP logo

pdm-venv's People

Contributors

apollo13 avatar blueyed avatar frostming avatar jamestansx avatar linw1995 avatar pre-commit-ci[bot] avatar xanterx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdm-venv's Issues

`pdm plugin add pdm-venv` failure

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:

  1. Install pdm with pip3 install --user pdm
  2. Try installing 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.0
  • Python version: 3.9
  • OS: Fedora 34

Additional context
Add any other context about the problem here.

Error message when using the last version of PDM (with integrated venv)

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:

  1. Install pdm and pdm-venv `pip install --user pdm pdm-venv
  2. Run command 'pdm config -vv'
  3. See error
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.

Screenshots
Annoying message

System (please complete the following information):

  • pdm version: 2.0.0
  • pdm-venv version: 0.5.0
  • Python version: 3.10.4
  • OS: Linux

[Security] Workflow code_quality.yml is using vulnerable action actions/checkout

The 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.

Is there an option to create the virtualenv in project folder? (similar to Poetry)

Is your feature request related to a problem? Please describe.

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.

Describe the solution you'd like

Something similar that was implemented for Poetry python-poetry/poetry#108

Poetry has a config key as follows:

virtualenvs.in-project = true

CLI commands from other packages only work with `pdm run`

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:

  1. Install pdm using curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 - into $HOME/.local/bin. Then pdm plugin add pdm-venv
  2. pdm config venv.in_project True; pdm config install.cache True
  3. Create a new project test-project
  4. pdm use 3.9; pdm venv create; pdm add nbdev, jupyter
  5. eval $(pdm venv activate in-project)
  6. Do either CLI commands from installed package: jupyter or nbdev_new
  7. pdm run jupyter and pdm run nbdev_new works as expected

System (please complete the following information):

  • pdm-venv version: 0.5.0
  • Python version: 3.9
  • OS: Linux

Clarification on multiple virtual environments for a project

The 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?

[powershell] ```pdm venv activate``` doesn't work

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:

  1. pdm venv create -n test
  2. pdm use
  3. pdm venv activate test
  4. virtualenv env isn't activated

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.
image

System (please complete the following information):

  • pdm-venv version: 0.2.0
  • Python version: 3.9.0
  • OS: Windows 21H1

Additional context
Add any other context about the problem here.
pdm-venv is installed via pdm plugin add pdm-venv

Activating conda venv fails

To Reproduce

  1. pdm venv create --with conda 3.8
  2. . "$(pdm venv activate 3.8)"
  3. See error

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

Screenshots
image

System (please complete the following information):

  • pdm-venv version: 0.2.0
  • pdm version: 1.7.0
  • Python version: 3.8
  • OS: Ubuntu 21.04

Additional context
Thank you for the awesome python project! :)

Support local virtual environment creation

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.

Cannot create virtualenv

With a fresh install of pdm and pdm-venv (installed and injected via pipx), I cannot create virtual environments.

Running:
image

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.

Add --version command to pdm-venv

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.

pdm project config `venv.in_project` is ignored while venv creation

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:

  1. Go to project directory (after plugin is installed)
  2. Run command 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.0
  • Python version: 3.10 (all)
  • OS: MacOS (all)

Additional 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.

[Security] Workflow code_quality.yml is using vulnerable action pre-commit/action

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.

pyproject.toml [tool.pdm.venv] is ignored?

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.

create with conda

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.

pdm venv activate very slow

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

No module named 'editables'

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

Add `install` command

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.