Skip to content

Commit 645ea62

Browse files
authored
Reduce the size of the build by not compiling parts of stubgen (#10107)
This might fix the out-of-memory errors we are getting when building Windows wheels. In any case these will speed up builds slightly. The `stubgen.py` file must be compiled since it uses inheritance from native classes. This removes one case of inheritance, but the others are harder to get rid of.
1 parent 22528cf commit 645ea62

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

mypy/stubgen.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,26 @@ def __init__(self,
192192
self.export_less = export_less
193193

194194

195-
class StubSource(BuildSource):
195+
class StubSource:
196196
"""A single source for stub: can be a Python or C module.
197197
198198
A simple extension of BuildSource that also carries the AST and
199199
the value of __all__ detected at runtime.
200200
"""
201201
def __init__(self, module: str, path: Optional[str] = None,
202202
runtime_all: Optional[List[str]] = None) -> None:
203-
super().__init__(path, module, None)
203+
self.source = BuildSource(path, module, None)
204204
self.runtime_all = runtime_all
205205
self.ast = None # type: Optional[MypyFile]
206206

207+
@property
208+
def module(self) -> str:
209+
return self.source.module
210+
211+
@property
212+
def path(self) -> Optional[str]:
213+
return self.source.path
214+
207215

208216
# What was generated previously in the stub file. We keep track of these to generate
209217
# nicely formatted output (add empty line between non-empty classes, for example).
@@ -1435,7 +1443,7 @@ def generate_asts_for_modules(py_modules: List[StubSource],
14351443
return
14361444
# Perform full semantic analysis of the source set.
14371445
try:
1438-
res = build(list(py_modules), mypy_options)
1446+
res = build([module.source for module in py_modules], mypy_options)
14391447
except CompileError as e:
14401448
raise SystemExit("Critical error during semantic analysis: {}".format(e)) from e
14411449

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ def run(self):
9999
# Also I think there would be problems with how we generate version.py.
100100
'version.py',
101101

102-
# Can be removed once we drop support for Python 3.5.2 and lower.
102+
# Skip these to reduce the size of the build
103103
'stubtest.py',
104+
'stubgenc.py',
105+
'stubdoc.py',
106+
'stubutil.py',
104107
)) + (
105108
# Don't want to grab this accidentally
106109
os.path.join('mypyc', 'lib-rt', 'setup.py'),

0 commit comments

Comments
 (0)