question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to exclude `site-packages` from python path

See original GitHub issue

PEP 582, as it is today only adds __pypackages__ to the list of discovery paths. This might lead to the usage of globally installed packages by mistake.

I think it would be very useful if it were possible to remove global python paths on a per project basis. Maybe a flag on the pyproject.toml file.

Assuming a project in /Users/foo/projects/bar on macOS using python3.8 installed using official installers:

  • Current path list

    ['',
     '/Users/foo/projects/bar/pdm/__pypackages__/3.8/lib',
     '/Users/foo/projects/bar/pdm',
     '/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
     '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
     '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload',
     '/Users/foo/Library/Python/3.8/lib/python/site-packages',
     '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages'
    ]
    
  • Suggested path list

    ['',
     '/Users/foo/projects/bar/pdm/__pypackages__/3.8/lib',
     '/Users/foo/projects/bar/pdm',
     '/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
     '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
     '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload',
    ]
    

Is this something that you are open to?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
frostmingcommented, Jul 8, 2022

@mgzenitech it turns out to be a corner case that the running env overrides the preset ones. It is handled in #1211

1reaction
frostmingcommented, Apr 11, 2020

Still waiting for the CI to pass(something is going wrong with GitHub actions), the next release should come out in the next 2 days after the PR is merged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I remove my system's 'site-packages' from the search ...
The easiest option is to pass -S to python on the command line, as described in the documentation.
Read more >
Understanding site-packages directories
Launching Python with the -S option will disable importing site , which means this directory will be excluded.
Read more >
add an option to exclude site-packages - Launchpad Bugs
We need an option in buildout that can be used to run the buildout without including site-packages. With the Grok project we now...
Read more >
Excluded folders are included in Python path
PyCharm simply ignores Excluded folders, it doesn't remove them from PYTHONPATH. >When running without the Python Console, source roots are NOT ...
Read more >
How to Exclude Folders in PyCharm - mothergeo
PyCharm allows you to exclude directories from consideration when searching and refactoring. You can exclude a directory by right-clicking on it and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found