Skip to content
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

Add setup.py to selfcheck #18609

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
"-p",
"mypyc",
],
# Type check setup.py as well
"self-packaging": [
executable,
"-m",
"mypy",
"--config-file",
"mypy_self_check.ini",
"setup.py",
],
# Lint
"lint": ["pre-commit", "run", "--all-files"],
# Fast test cases only (this is the bulk of the test suite)
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def is_list_of_setuptools_extension(items: list[Any]) -> TypeGuard[list[Extensio
return all(isinstance(item, Extension) for item in items)


def find_package_data(base, globs, root="mypy"):
def find_package_data(base: str, globs: list[str], root: str = "mypy") -> list[str]:
"""Find all interesting data files, for setup(package_data=)

Arguments:
Expand All @@ -52,13 +52,13 @@ def find_package_data(base, globs, root="mypy"):


class CustomPythonBuild(build_py):
def pin_version(self):
def pin_version(self) -> None:
path = os.path.join(self.build_lib, "mypy")
self.mkpath(path)
with open(os.path.join(path, "version.py"), "w") as stream:
stream.write(f'__version__ = "{version}"\n')

def run(self):
def run(self) -> None:
self.execute(self.pin_version, ())
build_py.run(self)

Expand Down Expand Up @@ -153,10 +153,10 @@ def run(self):
# our Appveyor builds run out of memory sometimes.
multi_file=sys.platform == "win32" or force_multifile,
)
assert is_list_of_setuptools_extension(ext_modules), "Expected mypycify to use setuptools"

else:
ext_modules = []

assert is_list_of_setuptools_extension(ext_modules), "Expected mypycify to use setuptools"

setup(version=version, ext_modules=ext_modules, cmdclass=cmdclass)