@@ -1699,6 +1699,7 @@ class State:
1699
1699
order = None # type: int # Order in which modules were encountered
1700
1700
id = None # type: str # Fully qualified module name
1701
1701
path = None # type: Optional[str] # Path to module source
1702
+ abspath = None # type: Optional[str] # Absolute path to module source
1702
1703
xpath = None # type: str # Path or '<string>'
1703
1704
source = None # type: Optional[str] # Module source code
1704
1705
source_hash = None # type: Optional[str] # Hash calculated based on the source code
@@ -1800,6 +1801,8 @@ def __init__(self,
1800
1801
if follow_imports == 'silent' :
1801
1802
self .ignore_all = True
1802
1803
self .path = path
1804
+ if path :
1805
+ self .abspath = os .path .abspath (path )
1803
1806
self .xpath = path or '<string>'
1804
1807
if path and source is None and self .manager .fscache .isdir (path ):
1805
1808
source = ''
@@ -2758,7 +2761,7 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
2758
2761
2759
2762
# Note: Running this each time could be slow in the daemon. If it's a problem, we
2760
2763
# can do more work to maintain this incrementally.
2761
- seen_files = {st .path : st for st in graph .values () if st .path }
2764
+ seen_files = {st .abspath : st for st in graph .values () if st .path }
2762
2765
2763
2766
# Collect dependencies. We go breadth-first.
2764
2767
# More nodes might get added to new as we go, but that's fine.
@@ -2805,16 +2808,18 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
2805
2808
if dep in st .dependencies_set :
2806
2809
st .suppress_dependency (dep )
2807
2810
else :
2808
- if newst .path in seen_files :
2809
- manager .errors .report (
2810
- - 1 , 0 ,
2811
- "Source file found twice under different module names: '{}' and '{}'" .
2812
- format (seen_files [newst .path ].id , newst .id ),
2813
- blocker = True )
2814
- manager .errors .raise_error ()
2815
-
2816
2811
if newst .path :
2817
- seen_files [newst .path ] = newst
2812
+ newst_path = os .path .abspath (newst .path )
2813
+
2814
+ if newst_path in seen_files :
2815
+ manager .errors .report (
2816
+ - 1 , 0 ,
2817
+ "Source file found twice under different module names: "
2818
+ "'{}' and '{}'" .format (seen_files [newst_path ].id , newst .id ),
2819
+ blocker = True )
2820
+ manager .errors .raise_error ()
2821
+
2822
+ seen_files [newst_path ] = newst
2818
2823
2819
2824
assert newst .id not in graph , newst .id
2820
2825
graph [newst .id ] = newst
0 commit comments