8000 Reduce the size of the build by not compiling stubgen by JukkaL · Pull Request #10107 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Reduce the size of the build by not compiling stubgen #10107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions mypy/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,26 @@ def __init__(self,
self.export_less = export_less


class StubSource(BuildSource):
class StubSource:
"""A single source for stub: can be a Python or C module.

A simple extension of BuildSource that also carries the AST and
the value of __all__ detected at runtime.
"""
def __init__(self, module: str, path: Optional[str] = None,
runtime_all: Optional[List[str]] = None) -> None:
super().__init__(path, module, None)
self.source = BuildSource(path, module, None)
self.runtime_all = runtime_all
self.ast = None # type: Optional[MypyFile]

@property
def module(self) -> str:
return self.source.module

@property
def path(self) -> Optional[str]:
return self.source.path


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

Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ def run(self):
# Also I think there would be problems with how we generate version.py.
'version.py',

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