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