@@ -125,12 +125,20 @@ def build(sources: List[BuildSource],
125
125
directories; if omitted, use '.' as the data directory
126
126
"""
127
127
128
- data_dir = default_data_dir (bin_dir )
128
+ custom_typeshed_name = None
129
+ if options .custom_typeshed_dir :
130
+ custom_data_dir , custom_typeshed_name = os .path .split (
131
+ options .custom_typeshed_dir .rstrip (os .sep ))
132
+ data_dir = custom_data_dir
133
+ else :
134
+ data_dir = default_data_dir (bin_dir )
129
135
130
136
find_module_clear_caches ()
131
137
132
138
# Determine the default module search path.
133
- lib_path = default_lib_path (data_dir , options .python_version )
139
+ lib_path = default_lib_path (data_dir ,
140
+ options .python_version ,
141
+ custom_typeshed_name = custom_typeshed_name )
134
142
135
143
if options .use_builtins_fixtures :
136
144
# Use stub builtins (to speed up test cases and to make them easier to
@@ -244,10 +252,13 @@ def mypy_path() -> List[str]:
244
252
return path_env .split (os .pathsep )
245
253
246
254
247
- def default_lib_path (data_dir : str , pyversion : Tuple [int , int ]) -> List [str ]:
255
+ def default_lib_path (data_dir : str ,
256
+ pyversion : Tuple [int , int ],
257
+ custom_typeshed_name : str = None ) -> List [str ]:
248
258
"""Return default standard library search paths."""
249
259
# IDEA: Make this more portable.
250
260
path = [] # type: List[str]
261
+ typeshed_name = custom_typeshed_name or 'typeshed'
251
262
252
263
auto = os .path .join (data_dir , 'stubs-auto' )
253
264
if os .path .isdir (auto ):
@@ -261,7 +272,7 @@ def default_lib_path(data_dir: str, pyversion: Tuple[int, int]) -> List[str]:
261
272
# (Note that 3.1 and 3.0 aren't really supported, but we don't care.)
262
273
for v in versions + [str (pyversion [0 ]), '2and3' ]:
263
274
for lib_type in ['stdlib' , 'third_party' ]:
264
- stubdir = os .path .join (data_dir , 'typeshed' , lib_type , v )
275
+ stubdir = os .path .join (data_dir , typeshed_name , lib_type , v )
265
276
if os .path .isdir (stubdir ):
266
277
path .append (stubdir )
267
278
0 commit comments