@@ -629,7 +629,7 @@ def get_prefixes(python_executable: Optional[str]) -> Tuple[str, str]:
629
629
630
630
631
631
@functools .lru_cache (maxsize = None )
632
- def get_site_packages_dirs (python_executable : Optional [str ]) -> Tuple [ List [str ], List [ str ] ]:
632
+ def get_site_packages_dirs (python_executable : Optional [str ]) -> List [str ]:
633
633
"""Find package directories for given python.
634
634
635
635
This runs a subprocess call, which generates a list of the egg directories, and the site
@@ -648,51 +648,7 @@ def get_site_packages_dirs(python_executable: Optional[str]) -> Tuple[List[str],
648
648
site_packages = ast .literal_eval (
649
649
subprocess .check_output ([python_executable , pyinfo .__file__ , 'getsitepackages' ],
650
650
stderr = subprocess .PIPE ).decode ())
651
- return expand_site_packages (site_packages )
652
-
653
-
654
- def expand_site_packages (site_packages : List [str ]) -> Tuple [List [str ], List [str ]]:
655
- """Expands .pth imports in site-packages directories"""
656
- egg_dirs : List [str ] = []
657
- for dir in site_packages :
658
- if not os .path .isdir (dir ):
659
- continue
660
- pth_filenames = sorted (name for name in os .listdir (dir ) if name .endswith (".pth" ))
661
- for pth_filename in pth_filenames :
662
- egg_dirs .extend (_parse_pth_file (dir , pth_filename ))
663
-
664
- return egg_dirs , site_packages
665
-
666
-
667
- def _parse_pth_file (dir : str , pth_filename : str ) -> Iterator [str ]:
668
- """
669
- Mimics a subset of .pth import hook from Lib/site.py
670
- See https://github.com/python/cpython/blob/3.5/Lib/site.py#L146-L185
671
- """
672
-
673
- pth_file = os .path .join (dir , pth_filename )
674
- try :
675
- f = open (pth_file , "r" )
676
- except OSError :
677
- return
678
- with f :
679
- for line in f .readlines ():
680
- if line .startswith ("#" ):
681
- # Skip comment lines
682
- continue
683
- if line .startswith (("import " , "import\t " )):
684
- # import statements in .pth files are not supported
685
- continue
686
-
687
- yield _make_abspath (line .rstrip (), dir )
688
-
689
-
690
- def _make_abspath (path : str , root : str ) -> str :
691
- """Take a path and make it absolute relative to root if not already absolute."""
692
- if os .path .isabs (path ):
693
- return os .path .normpath (path )
694
- else :
695
- return os .path .join (root , os .path .normpath (path ))
651
+ return site_packages
696
652
697
653
698
654
def add_py2_mypypath_entries (mypypath : List [str ]) -> List [str ]:
@@ -781,7 +737,7 @@ def compute_search_paths(sources: List[BuildSource],
781
737
if options .python_version [0 ] == 2 :
782
738
mypypath = add_py2_mypypath_entries (mypypath )
783
739
784
- egg_dirs , site_packages = get_site_packages_dirs (options .python_executable )
740
+ site_packages = get_site_packages_dirs (options .python_executable )
785
741
base_prefix , prefix = get_prefixes (options .python_executable )
786
742
is_venv = base_prefix != prefix
787
743
for site_dir in site_packages :
@@ -801,7 +757,7 @@ def compute_search_paths(sources: List[BuildSource],
801
757
802
758
return SearchPaths (python_path = tuple (reversed (python_path )),
803
759
mypy_path = tuple (mypypath ),
804
- package_path = tuple (egg_dirs + site_packages ),
760
+ package_path = tuple (site_packages ),
805
761
typeshed_path = tuple (lib_path ))
806
762
807
763
0 commit comments