@@ -133,6 +133,7 @@ def build(sources: List[BuildSource],
133133 bin_dir : str = None ,
134134 pyversion : Tuple [int , int ] = defaults .PYTHON3_VERSION ,
135135 custom_typing_module : str = None ,
136+ custom_typeshed_module : str = None ,
136137 report_dirs : Dict [str , str ] = None ,
137138 flags : List [str ] = None ,
138139 python_path : bool = False ) -> BuildResult :
@@ -158,12 +159,21 @@ def build(sources: List[BuildSource],
158159 report_dirs = report_dirs or {}
159160 flags = flags or []
160161
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 )
162169
163170 find_module_clear_caches ()
164171
165172 # 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 )
167177
168178 if TEST_BUILTINS in flags :
169179 # Use stub builtins (to speed up test cases and to make them easier to
@@ -276,11 +286,14 @@ def mypy_path() -> List[str]:
276286 return path_env .split (os .pathsep )
277287
278288
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 ]:
281293 """Return default standard library search paths."""
282294 # IDEA: Make this more portable.
283295 path = [] # type: List[str]
296+ typeshed_name = custom_typeshed_name or 'typeshed'
284297
285298 auto = os .path .join (data_dir , 'stubs-auto' )
286299 if os .path .isdir (auto ):
@@ -294,7 +307,7 @@ def default_lib_path(data_dir: str, pyversion: Tuple[int, int],
294307 # (Note that 3.1 and 3.0 aren't really supported, but we don't care.)
295308 for v in versions + [str (pyversion [0 ]), '2and3' ]:
296309 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 )
298311 if os .path .isdir (stubdir ):
299312 path .append (stubdir )
300313
0 commit comments