Skip to content
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

[pip 22.1] 'PathDistribution' object has no attribute 'project_name' #164

Closed
imba-tjd opened this issue May 14, 2022 · 31 comments · Fixed by #173
Closed

[pip 22.1] 'PathDistribution' object has no attribute 'project_name' #164

imba-tjd opened this issue May 14, 2022 · 31 comments · Fixed by #173

Comments

@imba-tjd
Copy link

imba-tjd commented May 14, 2022

> pipdeptree.exe
Ignoring invalid distribution ~iztracer (C:\Users\imbat\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\imbat\appdata\local\packages\pythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0\localcache\local-packages\python311\scripts\pipdeptree.exe\__main__.py", line 7, in <module>
  File "C:\Users\imbat\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pipdeptree.py", line 878, in main
    tree = PackageDAG.from_pkgs(pkgs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\imbat\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pipdeptree.py", line 290, in from_pkgs
    pkgs = [DistPackage(p) for p in pkgs]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\imbat\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pipdeptree.py", line 290, in <listcomp>
    pkgs = [DistPackage(p) for p in pkgs]
            ^^^^^^^^^^^^^^
  File "C:\Users\imbat\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pipdeptree.py", line 149, in __init__
    super(DistPackage, self).__init__(obj)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\imbat\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pipdeptree.py", line 109, in __init__
    self.project_name = obj.project_name
                        ^^^^^^^^^^^^^^^^
AttributeError: 'PathDistribution' object has no attribute 'project_name'
@imba-tjd imba-tjd changed the title error when there are broken packages AttributeError: 'PathDistribution' object has no attribute 'project_name' May 14, 2022
@imba-tjd imba-tjd changed the title AttributeError: 'PathDistribution' object has no attribute 'project_name' [pip 22.1] 'PathDistribution' object has no attribute 'project_name' Jun 3, 2022
@imba-tjd
Copy link
Author

imba-tjd commented Jun 3, 2022

I have figured it out. It's a pip issue. The change was made in pypa/pip#11044, between 22.1b and 22.1

For now. If anyone wants to use pipdeptree, set _PIP_USE_IMPORTLIB_METADATA=0

@ssbarnea
Copy link
Member

Yep, same problem on 3.11. Sadly it does not seem to be well maintained.

@naiquevin
Copy link
Contributor

Thanks. Unfortunately I have been caught up with other things and don't have time to work on pipdeptree in the immediate future. I'll try to find time by the end of this month.

Good that _PIP_USE_IMPORTLIB_METADATA=0 can be used as a work around in the meanwhile.

@stonebig
Copy link
Contributor

trying to patch uglily first two errors line 109 & 110 :

    def __init__(self, obj):
        self._obj = obj
        self.project_name = obj.name #  obj.project_name
        self.key = obj.name.replace('-', '_').lower() # obj.key

I fall on line 293, and can't find out this one

pipdeptree -r -p wheel
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\python-3.11.0b5.amd64\Scripts\pipdeptree.exe\__main__.py", line 7, in <module>
  File "D:\python-3.11.0b5.amd64\Lib\site-packages\pipdeptree.py", line 878, in main
    tree = PackageDAG.from_pkgs(pkgs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\python-3.11.0b5.amd64\Lib\site-packages\pipdeptree.py", line 292, in from_pkgs
    m = {p: [ReqPackage(r, idx.get(r.key))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\python-3.11.0b5.amd64\Lib\site-packages\pipdeptree.py", line 293, in <dictcomp>
    for r in p.requires()]
             ^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable

@ssbarnea
Copy link
Member

ssbarnea commented Aug 7, 2022

@naiquevin it is perfectly ok to be busy, but if you really care about pipdeptree, just move it under an org and give others access to fix and maintain it.

@naiquevin
Copy link
Contributor

@ssbarnea I have opened an issue in the pip repo to check if they would be interested in adopting pipdeptree by moving the code inside pip itself. IMO that would be better in the long run rather than maintaining the project externally. - pypa/pip#11360

However, I can see that there's a huge backlog of issues on pip, so expect this to take time. If they are not interested, I'll move it under an org as you suggested.

In the meanwhile I am assuming that any one can fork the project, merge open PRs on any of the public forks, and install pipdeptree into their env from their own fork on github or any other origin for that matter. I am curious about what stops people from doing this? Isn't that the whole point of git?

I don't mean any offense here, please don't get me wrong. As the owner of the pipdeptree on github and pypi.org, I know that it's my responsibility to care about it and ensure timely releases. But due to pipdeptree's dependence on pip's internals, a "stable" version can suddenly become unstable when a new version of pip is released. It's usually not possible for me to drop whatever I am doing and fix it. If there are any PRs I believe I have a greater responsibility to avoid any regression by doing end-to-end test myself before merging them. So it could take some time for PRs to get merged.

Again, no offense meant. But recently I've noticed comments on my projects that imply it's my responsibility to not just maintain the project, but also unblock them on high priority. Not saying you meant that too but I did feel a mild nudge given my recent experience on github in general (not just this project).

@ssbarnea
Copy link
Member

ssbarnea commented Aug 8, 2022

pypa org will not accept projects without active maintainers, as they do not want to become a junkyard. You can still move it to pycontribs or if you want, keeping the ownership.

I am one of the maintainers or pip-tools and we are still not moved to pypa, but looking to in the future.

As pip recently got the inspect feature, i was wondering if it would not be better to reimplement pipdeptree inside pip-tools, especially as we already have two tools in it.

Yep, keeping up with packaging changes is a challenge.

@stonebig
Copy link
Contributor

stonebig commented Aug 8, 2022

@ssbarnea maybe you can propose a patch ? pip may be more inclined to integrate pipdeptree if the current issue is fixed.

@ssbarnea
Copy link
Member

ssbarnea commented Aug 8, 2022

I think that pip team is very careful to minimize the amount of baggage the tool adopts, so unlikely to implement it. We should at least ask, maybe I am wrong.

@stonebig
Copy link
Contributor

stonebig commented Aug 8, 2022

When trying to build an updated set of packages, I'm truly lost without pipdeptree to navigate dependancies.

@stonebig
Copy link
Contributor

stonebig commented Aug 8, 2022

the suggested solution "pip pinspect" per pipa team sounds like a good splitting of duties

@naiquevin
Copy link
Contributor

@ssbarnea Looks like the pip team is reluctant about the proposal, as you had predicted.

As pip recently got the inspect feature, i was wondering if it would not be better to reimplement pipdeptree inside pip-tools, especially as we already have two tools in it.

I was not aware of pip inspect. If the json interface is indeed stable, I don't see why it can't be used to build a tool like pipdeptree.

Please feel free to reimplement it in pip-tools. Let me know once your version reaches stable state, I would happily archive this project and link it to yours.

@naiquevin
Copy link
Contributor

@stonebig Thanks for your kind words and support 👍

@stonebig
Copy link
Contributor

stonebig commented Aug 8, 2022

pipdeptree helped me a lot since the troubled times of figuring out why pip "solver" was doing this or that.
I'm not expert in Json, but I feel it's on my reach to survive pipdeptree with 'pip inspect' ...
... but as it may be take time, I'll do "set _PIP_USE_IMPORTLIB_METADATA=0" for now
winpython/winpython#1100 (comment)

thanks for having done pipdeptree and maintained it till january 2021

@stonebig
Copy link
Contributor

from 'pip inspect' it's a bit tiedous to replace ' and extra == 'test'' or ' extra == 'test'' per a qualified requirement_branch 'test'...

@stonebig
Copy link
Contributor

stonebig commented Aug 11, 2022

ok,

I failed to patch pipdeptree ("def from_pkgs") , which would have been simpler, but is over my debugging capability.

but with 'pip inspect', and 200 lines of 'proof of concept' code, i can do an acceptable ersatz for my use.

I hope it will inspire pip team to do the extra-mile of implementing the 4 basic features I whish

  • pipdeptree -p pandas
  • pipdeptree -r datashader
  • and bonus:
    • pipdeptree -p pandas['test']
    • pipdeptree -r -p datashader['doc'] # could be considered controversial

Proof-of-Concept code in the Notebook there:
https://github.com/winpython/winpython_afterdoc/blob/master/docs/pipdeptree_replacement.ipynb

image

@gaborbernat
Copy link
Member

@naiquevin I'd be interested in taking over this proejct as maintainer, I've contributed via #128 and as https://bernat.tech/about/ I'm PyPA member and fairly active.

@ssbarnea
Copy link
Member

ssbarnea commented Sep 1, 2022

I can vet for @gaborbernat, in case others do not know he is also happens to be tox maintainer.

I will also try to give him a hand as I am using pipdeptree in order to document project dependencies (sphinx build).

My initial hopes were to get this feature reimplemented in pip-tools, but I do not care as long we can find a way to keep the functionality alive (in a maintained project).

@naiquevin
Copy link
Contributor

Thanks @gaborbernat and @ssbarnea. Let me create an org pipdeptree-dev, move this repo under it and grant you two permissions to push and merge PRs.

Please give me time until this weekend though to read up about what it means to "move" a repo on github (I have some questions such as - what happens to open PRs? Will the existing forks continue to work? etc.).

I'll can also add maintainers on pypi for publishing new versions.

@ssbarnea
Copy link
Member

ssbarnea commented Sep 1, 2022

@naiquevin movements do retain all data and add redirects (even if done multiple times on same repo), only repository secrets are lost (security measure). Yep forks work, open prs, everything. GH team did a great job at this. Even GH api does continue to work with old URLs.

You also retain your full rights on repo move but other people with access are not transferred, so you need to add others after.

I do not have create rights on pypa and it was not clear if @gaborbernat wants it there but I do own https://github.com/pycontribs and I can give you rights there, so you would not need to create a new organization (i already have too many on my account). Later we can move it to pypa one.

@gaborbernat
Copy link
Member

I personally would keep it under the tox-dev org I also have access to. A new org seems a bit too much 😅 for a single project.

@ssbarnea
Copy link
Member

ssbarnea commented Sep 1, 2022

@gaborbernat Sure. Give him rights to create repo under tox-dev org and he should be able to make the transfer.

@gaborbernat
Copy link
Member

I think it would be easier to make me the owner of this repository and then I can do the transfer and add both of you on there as admins 👌

@ssbarnea
Copy link
Member

ssbarnea commented Sep 1, 2022

@gaborbernat he cannot do that with repos under personal accounts. But we could transfer it to you and allow you to do the move. It is known issue repos under personal repos.

@naiquevin
Copy link
Contributor

I don't mind transfering the repo to an existing org as long as the org is ok with it (based on the thread I had started on pip repo, pypa is not)

@gaborbernat I think you will need to temporarily grant me permission to create a new repo in the tox-dev org.

From here - https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository

To transfer a repository that you own to an organization, you must have permission to create a repository in the target organization.

@gaborbernat
Copy link
Member

Sent you the invitation.

@naiquevin
Copy link
Contributor

Accepted. Let me see if I can transfer now.

@naiquevin
Copy link
Contributor

@gaborbernat @ssbarnea Done!

Let me know if there are any more steps I need to take.

@gaborbernat
Copy link
Member

All good if you can give us pypi publish rights that would be great.

@naiquevin
Copy link
Contributor

Yeah, I'll do that.

@naiquevin
Copy link
Contributor

naiquevin commented Sep 3, 2022

Sent invitation on pypi.org to @gaborbernat and @ssbarnea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants