@@ -133,6 +133,7 @@ def build(sources: List[BuildSource],
133
133
bin_dir : str = None ,
134
134
pyversion : Tuple [int , int ] = defaults .PYTHON3_VERSION ,
135
135
custom_typing_module : str = None ,
136
+ custom_typeshed_module : str = None ,
136
137
report_dirs : Dict [str , str ] = None ,
137
138
flags : List [str ] = None ,
138
139
python_path : bool = False ) -> BuildResult :
@@ -158,12 +159,20 @@ def build(sources: List[BuildSource],
158
159
report_dirs = report_dirs or {}
159
160
flags = flags or []
160
161
161
- data_dir = default_data_dir (bin_dir )
162
+ custom_typeshed_name = None
163
+ if custom_typeshed_module :
164
+ custom_data_dir , custom_typeshed_name = os .path .split (custom_typeshed_module .rstrip (os .sep ))
165
+ data_dir = custom_data_dir
166
+ else :
167
+ data_dir = default_data_dir (bin_dir )
162
168
163
169
find_module_clear_caches ()
164
170
165
171
# Determine the default module search path.
166
- lib_path = default_lib_path (data_dir , pyversion , python_path )
172
+ lib_path = default_lib_path (data_dir ,
173
+ pyversion ,
174
+ python_path ,
175
+ custom_typeshed_name = custom_typeshed_name )
167
176
168
177
if TEST_BUILTINS in flags :
169
178
# Use stub builtins (to speed up test cases and to make them easier to
@@ -276,11 +285,14 @@ def mypy_path() -> List[str]:
276
285
return path_env .split (os .pathsep )
277
286
278
287
279
- def default_lib_path (data_dir : str , pyversion : Tuple [int , int ],
280
- python_path : bool ) -> List [str ]:
288
+ def default_lib_path (data_dir : str ,
289
+ pyversion : Tuple [int , int ],
290
+ python_path : bool ,
291
+ custom_typeshed_name : str = None ) -> List [str ]:
281
292
"""Return default standard library search paths."""
282
293
# IDEA: Make this more portable.
283
294
path = [] # type: List[str]
295
+ typeshed_name = custom_typeshed_name or 'typeshed'
284
296
285
297
auto = os .path .join (data_dir , 'stubs-auto' )
286
298
if os .path .isdir (auto ):
@@ -294,7 +306,7 @@ def default_lib_path(data_dir: str, pyversion: Tuple[int, int],
294
306
# (Note that 3.1 and 3.0 aren't really supported, but we don't care.)
295
307
for v in versions + [str (pyversion [0 ]), '2and3' ]:
296
308
for lib_type in ['stdlib' , 'third_party' ]:
297
- stubdir = os .path .join (data_dir , 'typeshed' , lib_type , v )
309
+ stubdir = os .path .join (data_dir , typeshed_name , lib_type , v )
298
310
if os .path .isdir (stubdir ):
299
311
path .append (stubdir )
300
312
0 commit comments