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 2 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
12 changes: 4 additions & 8 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,10 @@
# Self type check
"self": [
executable,
"-m",
"mypy",
"--config-file",
"mypy_self_check.ini",
"-p",
"mypy",
"-p",
"mypyc",
"-c",
"from mypy.main import main as mypy; "
"mypy(args=['--config-file', 'mypy_self_check.ini', '-p', 'mypy', '-p', 'mypyc']); "
"mypy(args=['--config-file', 'mypy_self_check.ini', 'setup.py'])",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should have two different type checks, self (which checks mypy) and self-packaging (which checks setup.py)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought about splitting them, but then I saw the comment at https://github.com/python/mypy/pull/18609/files/72e1ff81760a6e50a2acba2d2a262ad409afdc25#diff-17019d8813f584a97bc5531faa1df3f1a590413d61a77d7d93db76df66163b63R53-R54

Each run should have tests that each take a roughly similar time to run.

To me, the check of just setup.py feels too short to have its own run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to take this PR in whatever direction the reviewers / mergers / maintainers wish, of course :-)

],
# Lint
"lint": ["pre-commit", "run", "--all-files"],
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)