File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,9 @@ def build(sources: List[BuildSource],
168
168
for source in sources :
169
169
if source .path :
170
170
# Include directory of the program file in the module search path.
171
- dir = remove_cwd_prefix_from_path (dirname (source .path ))
171
+ dir = remove_cwd_prefix_from_path (
172
+ dirname (source .path ), namespaces_allowed = options .namespace_packages
173
+ )
172
174
if dir not in lib_path :
173
175
lib_path .insert (0 , dir )
174
176
@@ -701,21 +703,23 @@ def stats_summary(self) -> Mapping[str, object]:
701
703
return self .stats
702
704
703
705
704
- def remove_cwd_prefix_from_path (p : str ) -> str :
706
+ def remove_cwd_prefix_from_path (p : str , namespaces_allowed : bool ) -> str :
705
707
"""Remove current working directory prefix from p, if present.
706
708
707
709
Also crawl up until a directory without __init__.py is found.
708
710
709
711
If the result would be empty, return '.' instead.
710
712
"""
713
+ def is_pkg (p ):
714
+ return (os .path .isfile (os .path .join (p , '__init__.py' ))
715
+ or os .path .isfile (os .path .join (p , '__init__.pyi' )))
716
+
711
717
cur = os .getcwd ()
712
718
# Add separator to the end of the path, unless one is already present.
713
719
if basename (cur ) != '' :
714
720
cur += os .sep
715
721
# Compute root path.
716
- while (p and
717
- (os .path .isfile (os .path .join (p , '__init__.py' )) or
718
- os .path .isfile (os .path .join (p , '__init__.pyi' )))):
722
+ while (p and (namespaces_allowed or is_pkg (p ))):
719
723
dir , base = os .path .split (p )
720
724
if not base :
721
725
break
You can’t perform that action at this time.
0 commit comments