-
-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pdm installs packages although nox re-uses virtualenv #346
Comments
Did you turn on the venv support by |
Here are my settings: pdm config 2039ms Sa 27 Mär 2021 16:44:51 UTC
Home configuration (/home/tom/.pdm/config.toml):
auto_global = False
cache_dir = /home/tom/.cache/pdm
parallel_install = True
pypi.json_api = False
pypi.url = https://pypi.org/simple
pypi.verify_ssl = True
python.use_pyenv = True
strategy.resolve_max_rounds = 1000
strategy.save = compatible
strategy.update = reuse
use_venv = True
Project configuration (/home/tom/proj/assertion/.pdm.toml):
python.path = /usr/bin/python3 |
It makes no sense. How did you get nox installed and whether there are any env vars begin with |
But I think, I had a different setup first and switched to pipx later own. I'll test it with a fresh repo. |
Ok, I just tried pdm and nox in a newly set up project:
project folder tree:
pyproject.toml: [project]
name = "pn"
version = "0.1.0"
description = ""
authors = [{ name = "Thomas Pohl", email = "[email protected]" }]
dependencies = []
dev-dependencies = []
requires-python = ">=3.8"
dynamic = ["classifiers"]
license = { text = "MIT" }
[project.urls]
homepage = ""
[project.optional-dependencies]
mooh = ["cowsay~=3.0"]
[build-system]
requires = ["pdm-pep517"]
build-backend = "pdm.pep517.api"
[tool]
[tool.pdm] noxfile.py import os
import nox
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
@nox.session
def mooh(session):
session.run("pdm", "install", "-v", "-s", "mooh", external=True)
session.run("cowsay", "Mooh!") When I run nox > Running session mooh
nox > Re-using existing virtual environment at .nox/mooh.
nox > pdm install -v -s mooh
Synchronizing working set with lock file: 1 to add, 0 to update, 0 to remove
Install cowsay 3.0 successful
Installing the project as an editable package...
Preparing isolated env for PEP 517 build...
Requirement already satisfied: setuptools in ./.nox/mooh/lib/python3.8/site-packages (from -r /tmp/pdm-build-reqs-7fbr7x_z.txt (line 1)) (53.1.0)
running egg_info
writing pn.egg-info/PKG-INFO
writing dependency_links to pn.egg-info/dependency_links.txt
writing requirements to pn.egg-info/requires.txt
writing top-level names to pn.egg-info/top_level.txt
reading manifest file 'pn.egg-info/SOURCES.txt'
writing manifest file 'pn.egg-info/SOURCES.txt'
Preparing isolated env for PEP 517 build...
Requirement already satisfied: setuptools in ./.nox/mooh/lib/python3.8/site-packages (from -r /tmp/pdm-build-reqs-gweuz743.txt (line 1)) (53.1.0)
running develop
running egg_info
writing pn.egg-info/PKG-INFO
writing dependency_links to pn.egg-info/dependency_links.txt
writing requirements to pn.egg-info/requires.txt
writing top-level names to pn.egg-info/top_level.txt
reading manifest file 'pn.egg-info/SOURCES.txt'
writing manifest file 'pn.egg-info/SOURCES.txt'
running build_ext
Creating /home/tom/proj/pn/.nox/mooh/lib/python3.8/site-packages/pn.egg-link (link to .)
pn 0.1.0 is already the active version in easy-install.pth
Installed /home/tom/proj/pn
Install pn 0.1.0 successful
🎉 All complete!
nox > cowsay Mooh!
_____
< Mooh! >
=====
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
nox > Session mooh was successful. When running it a second (third, ...) time, I still get the line about pdm installing cowsay, but it's faster than the first run (3.5s vs 2.6s). Is the |
I just tried the same with two heavier packages to see a larger time difference when actually installing packages. I added an additional math section in my pyproject.toml: [project.optional-dependencies]
mooh = [
"cowsay~=3.0",
]
math = [
"numpy~=1.20",
"scipy~=1.6",
] The first Why is it behaving as expected for these two packages? |
I still couldn't reproduce it. A Dockerfile may help |
Ok, I'll prepare a Dockerfile. Apart from that, it would be great to have some more output in the verbose mode why pdm thinks it has to re-install packages. |
Based on the comparison between lock file and the current installed working set. And the latter heavily relies on the selection of the Python environment which is created based on the interpreter. When Lines 159 to 174 in fd22d4b
Even when |
With this Dockerfile # docker build -t pdm_nox .
# docker run --rm -ti pdm_nox
FROM python:3.8-slim
WORKDIR /root/pn
RUN pip install pipx
RUN pipx install pdm
RUN pipx install nox
ENV PATH="/root/.local/bin:${PATH}"
ADD noxfile.py pyproject.toml ./
RUN pdm config use_venv true
CMD /bin/bash
# nox -e mooh --reuse-existing-virtualenv
# nox -e math --reuse-existing-virtualenv I was not able to reproduce the issue (I'm using fish locally and bash in the container, but that shouldn't make a difference). Since the selection of the right environment is crucial, a log output in verbose mode would be super helpful. |
Yeah, sorry, but can you hook into somewhere around this function before the return statement: Lines 202 to 206 in fd22d4b
to see what the value of |
For some reason, some installed packages are not detected in the WorkingSet. For the nox venv with numpy and scipy it works:
For the nox venv with cowsay it doesn't work:
And because of that, in If I find the time, I will look into the WorkingSet constructor. |
Ah, cowsay does not install anything into |
Ah, it makes sense now, I have come out with a quick fix #364 where you can try if the issue is fixed. |
Works now as expected. Cheers! 🍾 |
Steps to reproduce
I'm using PDM in combination with nox and enabled nox' ability to re-use virtualenvs.
When I start a linting session (which uses black, isort, mypy, and flake8), nox claims to re-use the virtualenv:
In total, the execution takes about 7 seconds with most time spent by pdm.
Interestingly, the result is different when I explicitly disallow re-using the virtualenv
This takes about 12 seconds, maybe because PDM installed three more packages (regex, mypy, typed-ast).
My expectation would be that nox doesn't even need to run PDM (so it might be a nox issue) if I tell it to re-use the virtualenv.
Environment Information
The text was updated successfully, but these errors were encountered: