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

Support detecting multiple site-packages directories in venvs #1165

Merged
merged 2 commits into from
Nov 13, 2020

Conversation

truls
Copy link
Contributor

@truls truls commented Nov 12, 2020

On Red Hat derived systems, Python's purelib and platlib are set to <prefix>/lib and <prefix>/lib64 respectively. This means that Python packages are installed to either of those directories depending on whether they contain native libraries or not (as I understand it). This distinction is also present in pipenv's virtualenvs. See:

$  . /home/truls/.local/share/virtualenvs/pyright-test-Fm_xQ9MX/bin/activate
(pyright-test) truls@dhcp-111-236 ~/foo/pyright-test $ python
Python 3.9.0 (default, Oct  6 2020, 00:00:00) 
[GCC 10.2.1 20200826 (Red Hat 10.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_path('purelib')
'/home/truls/.local/share/virtualenvs/pyright-test-Fm_xQ9MX/lib/python3.9/site-packages'
>>> sysconfig.get_path('platlib')
'/home/truls/.local/share/virtualenvs/pyright-test-Fm_xQ9MX/lib64/python3.9/site-packages'
>>> 

The current virtualenv include path detection logic in pyright returns only the first extant site-packages directory it finds. This is insufficient for discovering the full include path for virtualenvs where packages may be installed in both the lib and lib64 directories. This PR changes the virtualenv include path detection logic so that it returns all of the extant site-packages dirs it finds in the lib, lib64 or Lib directories.

@ghost
Copy link

ghost commented Nov 12, 2020

CLA assistant check
All CLA requirements met.

@erictraut erictraut merged commit c25430a into microsoft:master Nov 13, 2020
@erictraut
Copy link
Collaborator

Thanks for the contribution!

@truls truls deleted the multiple-venv-dirs branch November 13, 2020 15:24
@truls truls restored the multiple-venv-dirs branch November 13, 2020 15:35
@truls truls deleted the multiple-venv-dirs branch November 13, 2020 15:35
heejaechang pushed a commit to heejaechang/pyright that referenced this pull request Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants