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

Remove most of setuptools._distutils #9795

Merged
merged 9 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
18 changes: 12 additions & 6 deletions stubs/setuptools/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ pkg_resources.declare_namespace
pkg_resources.fixup_namespace_packages
pkg_resources.get_entry_map
pkg_resources.get_provider
pkg_resources.py31compat
pkg_resources.split_sections
pkg_resources.to_filename

# Only present if docutils is installed
setuptools._distutils.command.check.SilentReporter
# Uncomment once ignore_missing_stub is turned off
# # Not supported by typeshed
# setuptools.py34compat

# Discrepancy in the value of the default
# between setuptools's version of distutils and the stdlib distutils
setuptools._distutils.core.Command.announce
# # Private modules
# setuptools.config._validate_pyproject.*
# setuptools.build_meta._BuildMetaBackend.*

# # Vendored and modified version of stdlib's distutils. Basically implementation details
# setuptools._distutils.*
# # Other vendored code
# setuptools._vendor.*
# pkg_resources._vendor.*
10 changes: 9 additions & 1 deletion stubs/setuptools/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
version = "67.4.*"
requires = ["types-docutils"]
extra_description = """\
Having [setuptools](https://pypi.org/project/setuptools/) installed results in incorrect \
[distutils](https://docs.python.org/3/distutils/introduction.html) typing. \
`types-setuptools` makes no attempt at correcting this issue. As of \
`setuptools>=60.0.0`, you [should not be using `distutils` directly](\
https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html). \
`distutils` is deprecated as of Python 3.10 and will be fully removed in Python 3.12. \
(see [PEP 632](https://peps.python.org/pep-0632/))
"""
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that this is necessary -- it sort of feels like it's setuptools's problem rather than ours. If we do want some kind of a note here, I'd prefer it if it were slightly more concise.

Copy link
Collaborator Author

@Avasam Avasam Feb 25, 2023

Choose a reason for hiding this comment

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

Does this look better to you? Same links, and all the same info can be found at those locations.

Having setuptools installed results in incorrect distutils typing. types-setuptools makes no attempt at correcting this issue. See Porting from Distutils and PEP 632 – Deprecate distutils module.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, the more I think about it, the more I lean towards not including this note at all. It feels like unnecessary finger-pointing at setuptools from us. The distutils situation is very frustrating for me, a typeshed maintainer, but as far as I know we haven't received any complaints from users of our stubs about incorrect distutils typing, so it sort of feels like this note is attempting to solve something that may not actually be much of an issue for users. If we do get complaints or queries from users, we can maybe rethink this, but for now I think we can probably do without this :)

Copy link
Collaborator Author

@Avasam Avasam Feb 25, 2023

Choose a reason for hiding this comment

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

I can see what you mean. I also expect the amount of users who'll actually land on the PyPI page to be taught about the issue of mixing setuptools and distutils together to be really small. (pyright ships stubs, and the average mypy user probably installs stubs from mypy's CLI suggestion).
I'll omit the message for now. Can be revised later if needed or if other maintainers feel differently about it.


[tool.stubtest]
ignore_missing_stub = true
5 changes: 0 additions & 5 deletions stubs/setuptools/pkg_resources/py31compat.pyi

This file was deleted.

3 changes: 2 additions & 1 deletion stubs/setuptools/setuptools/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from abc import abstractmethod
from collections.abc import Iterable, Mapping, Sequence
from distutils.core import Command as _Command
from typing import Any

from setuptools._deprecation_warning import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning
from setuptools.depends import Require as Require
from setuptools.dist import Distribution as Distribution
from setuptools.extension import Extension as Extension

from ._distutils.cmd import Command as _Command

__version__: str

class PackageFinder:
Expand Down
Empty file.
20 changes: 0 additions & 20 deletions stubs/setuptools/setuptools/_distutils/archive_util.pyi

This file was deleted.

3 changes: 0 additions & 3 deletions stubs/setuptools/setuptools/_distutils/bcppcompiler.pyi

This file was deleted.

152 changes: 0 additions & 152 deletions stubs/setuptools/setuptools/_distutils/ccompiler.pyi

This file was deleted.

21 changes: 12 additions & 9 deletions stubs/setuptools/setuptools/_distutils/cmd.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from _typeshed import Incomplete
from abc import abstractmethod
from collections.abc import Callable, Iterable
from distutils.dist import Distribution
from typing import Any

from .dist import Distribution

class Command:
sub_commands: list[tuple[str, Callable[[Command], bool] | None]]
Expand All @@ -25,7 +26,9 @@ class Command:
def run_command(self, command: str) -> None: ...
def get_sub_commands(self) -> list[str]: ...
def warn(self, msg: str) -> None: ...
def execute(self, func: Callable[..., object], args: Iterable[Any], msg: str | None = ..., level: int = ...) -> None: ...
def execute(
self, func: Callable[..., object], args: Iterable[Incomplete], msg: str | None = ..., level: int = ...
) -> None: ...
def mkpath(self, name: str, mode: int = ...) -> None: ...
def copy_file(
self,
Expand All @@ -34,7 +37,7 @@ class Command:
preserve_mode: int = ...,
preserve_times: int = ...,
link: str | None = ...,
level: Any = ...,
level: int = ...,
) -> tuple[str, bool]: ... # level is not used
def copy_tree(
self,
Expand All @@ -43,10 +46,10 @@ class Command:
preserve_mode: int = ...,
preserve_times: int = ...,
preserve_symlinks: int = ...,
level: Any = ...,
level: int = ...,
) -> list[str]: ... # level is not used
def move_file(self, src: str, dst: str, level: Any = ...) -> str: ... # level is not used
def spawn(self, cmd: Iterable[str], search_path: int = ..., level: Any = ...) -> None: ... # level is not used
def move_file(self, src: str, dst: str, level: int = ...) -> str: ... # level is not used
def spawn(self, cmd: Iterable[str], search_path: int = ..., level: int = ...) -> None: ... # level is not used
def make_archive(
self,
base_name: str,
Expand All @@ -61,8 +64,8 @@ class Command:
infiles: str | list[str] | tuple[str, ...],
outfile: str,
func: Callable[..., object],
args: list[Any],
args: list[Incomplete],
exec_msg: str | None = ...,
skip_msg: str | None = ...,
level: Any = ...,
level: int = ...,
) -> None: ... # level is not used
Empty file.
25 changes: 0 additions & 25 deletions stubs/setuptools/setuptools/_distutils/command/bdist.pyi

This file was deleted.

21 changes: 0 additions & 21 deletions stubs/setuptools/setuptools/_distutils/command/bdist_dumb.pyi

This file was deleted.

52 changes: 0 additions & 52 deletions stubs/setuptools/setuptools/_distutils/command/bdist_rpm.pyi

This file was deleted.

Loading