-
Notifications
You must be signed in to change notification settings - Fork 166
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
Remove site-packages from packages search tree #723
Remove site-packages from packages search tree #723
Conversation
I should have written logic to handle this already, it may just be missing the regex rules |
Here's what I found: 2182bfe (utils.py) |
Honestly if I was to rewrite this again, I'd abstract the db, parsing and discovery (separate layers for package and module/file discovery) layers out of the main class - it's a bit of a monstrosity. They honestly can be made single threaded. There's also some poor logic in one of the cache generation functions I fixed in a PR I never merged. |
So why not merge it then? :) |
I never finished the work, it was part of a much broader change that broke API compatibility. I don't see the problem in the current rope code, but my idea was to use the same function to generate the cache and have both cache generation functions call it instead of implementing the logic twice. |
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.
I hadn't tested this, but from bird's eye view, this looks reasonable. @bagel897 mentioned that she did a similar fix in an unmerged branch, so if this looks ok to her, it is ok to me as well.
Does this handle cases where venv is in the project root? I am running into that on windows with the autodetect branch. Maybe this is a venv vs virtualenv thing? I think our implementation should be recursive (IE no Lib.site-packages.xyz modules) but I'm not sure how to implement that efficiently |
I think this PR doesn't change the way we treat virtual environments. The PR only doesn't treat That said: @lieryan I saw you approved the PR. Can you merge this? @bagel897 if you have any concerns related virtual environments, can we please address this in a separate issue/PR? |
Autoimport scans for packages in the python path Here's another failure example: |
Hi @tkrabel-db, thanks for creating this PR. I'm currently travelling on vacation, so my availability to look into rope issues and review PRs will be limited until December. So don't worry, but I hadn't forgotten about this 🙂, but I won't be able to action the PR or make a new release until December. |
@bagel897 coming back to your comment:
I tested my code creating a virtual environment using There, you can see we have duplications of the form (and only of the form)
Let's use an example to facilitate the conversation.
Here, you see that we attribute the The change I propose (with your help of pointing me to the correct util; thank you!) captures all cases in which we attribute any object/module to be of root (i.e. the "package") Again, I tested my code and found that it also captures the case you presented. If you think my PR still has some gaps, pls show them in a reproducible example based on this PR. And thank you for engaging in this PR! It's truly helpful having the original author around :) |
Thanks for fixing this issue @tkrabel |
Description
Remove
site-packages
from the python package search tree to avoid duplicate entries in the autoimport database. This also speeds up generating the modules cache by a factor of ~2.Fixes #722
Checklist (delete if not relevant):