-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
replace pkg_resources with importlib.metadata and packaging #333
replace pkg_resources with importlib.metadata and packaging #333
Conversation
fix #175 |
Requirements of different extras may cause same pkgs listed in one node. But I think it is resonable. |
The result looks corret with my own tests. |
714c368
to
b0578d4
Compare
Thanks for contributing @xiacunshun! I do see some areas in your PR that aren't related to migrating the codebase to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packaging
is not apart of the Python standard library, so I guess we need to add it as a dependency in pyproject.toml
.
733c7cd
to
b01ea90
Compare
ad4efaf
to
aa8dc8b
Compare
8bb4cee
to
d7b639f
Compare
d7b639f
to
9dff1af
Compare
Does it mean that the needed requirements cannot be installed if the warning appears? Is that a problem should alarm? Edit: If so, I think we should warn them out in another way maybe? |
No, we shouldn't warn them since packages with environment markers essentially makes it conditional whether or not they should be installed. If there is an environment marker that expects the package to be installed on a Windows machine, pip or other package managers won't install this package on a MacOS machine. So there shouldn't be a warning (just like how it was handled before when dealing with the pip API). |
Got it, it makes sense. |
I think everything looks good. The only problem I found just now has to do with using
Since we now depend on
Edit: looks like pip has "on-by-default" caching, so we don't need to think about it |
I think this error may not need to be solved, because if you need to use non-host python which uses the dependencies in that env, so the user should ensure that the necessary dependencies exist in that environment? edit: pip do have on-by-default cache, but it looks like it cannot be used in venv(they are separate). |
I do see your point, but this changes how Right now I think I see two approaches:
Regarding how pip handles caching, it seems that pip uses a single cache no matter if we're using the system environment or a virtual environment, for example:
|
The second one is better I think, I will try this. |
You are right. I didn't notice it before.
We should better not to download something in our progress, even in non host cases. |
I agree, and I think the latter approach is better since we don't have to perform any networking (as |
60530f5
to
63ffb33
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Alright, after looking at this patch a couple more times I'm not seeing any other areas of concern so I think this is good to go. Thanks @xiacunshun for the contribution! |
Hey @gaborbernat, it looks like since I was the latest one to push to this branch I'm gonna need your approval with this one. I understand you're busy, so please review this at your convenience. Thank you! @xiacunshun Once this PR is merged, I'll go ahead and add you as a collaborator 👍 |
Thanks! Alright @xiacunshun, after you accept the invitation you will be able to manage issues and pull requests. And since this is refactoring work, I believe we can cut a minor release (i.e. 2.17.0) |
Thanks for your invitation! I think |
We should not wait for that. The pull request in question might be in progress for another month from all we know. |
I agree. Also, even though we have removed alot of its API usage, we still need pip to generate frozen requirements. This PR removed older frozen requirement API since we assumed that we would be working with pip>=23.1.2. If we need to handle older pip versions again, we need to revert some of these changes and maybe change the existing adapter class or add new adapter classes to handle older versions of I'll see if I can cut a minor release tomorrow! |
Hmm, the thought of duplicate packages when using $ mkdir temp-site-pkgs
$ pip install --target temp-site-pkgs/ pytest
Collecting pytest
Using cached pytest-8.1.1-py3-none-any.whl.metadata (7.6 kB)
. . .
Installing collected packages: tomli, pluggy, packaging, iniconfig, exceptiongroup, pytest
Successfully installed exceptiongroup-1.2.0 iniconfig-2.0.0 packaging-24.0 pluggy-1.4.0 pytest-8.1.1 tomli-2.0.1
$ PYTHONPATH=/workspaces/pipdeptree/temp-site-pkgs pipdeptree -a -d 0
attrs==23.2.0
Automat==22.10.0
cachetools==5.3.3
certifi==2024.2.2
cffi==1.16.0
cfgv==3.4.0
chardet==5.2.0
charset-normalizer==3.3.2
colorama==0.4.6
constantly==23.10.4
covdefaults==2.3.0
coverage==7.4.4
cryptography==42.0.5
cssselect==1.2.0
diff_cover==8.0.3
distlib==0.3.8
exceptiongroup==1.2.0 # <--- Here
exceptiongroup==1.2.0
filelock==3.13.1
gitdb==4.0.11
GitPython==3.1.41
hyperlink==21.0.0
identify==2.5.35
idna==3.6
incremental==22.10.0
iniconfig==2.0.0 # <--- Here
iniconfig==2.0.0
itemadapter==0.8.0
itemloaders==1.1.0
Jinja2==3.1.3
jmespath==1.0.1
lxml==5.2.1
MarkupSafe==2.1.5
nodeenv==1.8.0
packaging==24.0 # <--- Here
packaging==24.0
parsel==1.9.0
pip==24.0
pip==23.0.1
pipdeptree==2.16.3.dev3+g91d21e3
platformdirs==4.2.0
pluggy==1.4.0 # <--- Here
pluggy==1.4.0
pre-commit==3.7.0
Protego==0.3.0
pyasn1==0.6.0
pyasn1_modules==0.4.0
pycparser==2.22
PyDispatcher==2.0.7
Pygments==2.17.2
pyOpenSSL==24.1.0
pyproject-api==1.6.1
pytest==8.1.1 # <--- Here
pytest==8.1.1
pytest-cov==4.1.0
pytest-mock==3.14.0
PyYAML==6.0.1
queuelib==1.6.2
requests==2.31.0
requests-file==2.0.0
Scrapy==2.11.1
service-identity==24.1.0
setuptools==69.0.3
six==1.16.0
smmap==5.0.1
tldextract==5.1.2
tomli==2.0.1 # <--- Here
tomli==2.0.1
tox==4.14.2
Twisted==24.3.0
typing_extensions==4.10.0
urllib3==2.2.1
virtualenv==20.25.1
w3lib==2.1.2
wheel==0.42.0
zope.interface==6.2 |
No description provided.