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 1 commit
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
Prev Previous commit
Next Next commit
Update refs
  • Loading branch information
Avasam committed Feb 22, 2023
commit f95f804769816a0ce9d12a9316e8630626598b27
9 changes: 9 additions & 0 deletions stubs/setuptools/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
version = "67.3.*"
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
3 changes: 2 additions & 1 deletion stubs/setuptools/setuptools/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ from collections.abc import Iterable, Mapping, Sequence
from typing import Any

from setuptools._deprecation_warning import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning
from setuptools._distutils.cmd import Command as _Command
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: 11 additions & 9 deletions stubs/setuptools/setuptools/_distutils/cmd.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from _typeshed import Incomplete, Unused
from abc import abstractmethod
from collections.abc import Callable, Iterable
from typing import Any

from setuptools._distutils.dist import Distribution
from .dist import Distribution

class Command:
sub_commands: list[tuple[str, Callable[[Command], bool] | None]]
Expand All @@ -26,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 @@ -35,7 +37,7 @@ class Command:
preserve_mode: int = ...,
preserve_times: int = ...,
link: str | None = ...,
level: Any = ...,
level: Unused = ...,
) -> tuple[str, bool]: ... # level is not used
def copy_tree(
self,
Expand All @@ -44,10 +46,10 @@ class Command:
preserve_mode: int = ...,
preserve_times: int = ...,
preserve_symlinks: int = ...,
level: Any = ...,
level: Unused = ...,
) -> 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: Unused = ...) -> str: ... # level is not used
def spawn(self, cmd: Iterable[str], search_path: int = ..., level: Unused = ...) -> None: ... # level is not used
def make_archive(
self,
base_name: str,
Expand All @@ -62,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.
24 changes: 12 additions & 12 deletions stubs/setuptools/setuptools/_distutils/command/build_clib.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from typing import Any
from _typeshed import Incomplete

from ..cmd import Command

class build_clib(Command):
description: str
user_options: Any
boolean_options: Any
help_options: Any
build_clib: Any
build_temp: Any
libraries: Any
include_dirs: Any
define: Any
undef: Any
debug: Any
user_options: Incomplete
boolean_options: Incomplete
help_options: Incomplete
build_clib: Incomplete
build_temp: Incomplete
libraries: Incomplete
include_dirs: Incomplete
define: Incomplete
undef: Incomplete
debug: Incomplete
force: int
compiler: Any
compiler: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
Expand Down
52 changes: 25 additions & 27 deletions stubs/setuptools/setuptools/_distutils/command/build_ext.pyi
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
from typing import Any
from _typeshed import Incomplete

from ..cmd import Command

extension_name_re: Any

class build_ext(Command):
description: str
sep_by: Any
user_options: Any
boolean_options: Any
help_options: Any
extensions: Any
build_lib: Any
plat_name: Any
build_temp: Any
sep_by: Incomplete
user_options: Incomplete
boolean_options: Incomplete
help_options: Incomplete
extensions: Incomplete
build_lib: Incomplete
plat_name: Incomplete
build_temp: Incomplete
inplace: int
package: Any
include_dirs: Any
define: Any
undef: Any
libraries: Any
library_dirs: Any
rpath: Any
link_objects: Any
debug: Any
force: Any
compiler: Any
swig: Any
swig_cpp: Any
swig_opts: Any
user: Any
parallel: Any
package: Incomplete
include_dirs: Incomplete
define: Incomplete
undef: Incomplete
libraries: Incomplete
library_dirs: Incomplete
rpath: Incomplete
link_objects: Incomplete
debug: Incomplete
force: Incomplete
compiler: Incomplete
swig: Incomplete
swig_cpp: Incomplete
swig_opts: Incomplete
user: Incomplete
parallel: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
Expand Down
24 changes: 12 additions & 12 deletions stubs/setuptools/setuptools/_distutils/command/build_py.pyi
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from typing import Any
from _typeshed import Incomplete

from ..cmd import Command

class build_py(Command):
description: str
user_options: Any
boolean_options: Any
negative_opt: Any
build_lib: Any
py_modules: Any
package: Any
package_data: Any
package_dir: Any
user_options: Incomplete
boolean_options: Incomplete
negative_opt: Incomplete
build_lib: Incomplete
py_modules: Incomplete
package: Incomplete
package_data: Incomplete
package_dir: Incomplete
compile: int
optimize: int
force: Any
force: Incomplete
def initialize_options(self) -> None: ...
packages: Any
data_files: Any
packages: Incomplete
data_files: Incomplete
def finalize_options(self) -> None: ...
def run(self) -> None: ...
def get_data_files(self): ...
Expand Down
50 changes: 25 additions & 25 deletions stubs/setuptools/setuptools/_distutils/command/install.pyi
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
from typing import Any
from _typeshed import Incomplete

from ..cmd import Command

class install(Command):
description: str
user_options: Any
boolean_options: Any
negative_opt: Any
user_options: Incomplete
boolean_options: Incomplete
negative_opt: Incomplete
prefix: str | None
exec_prefix: Any
exec_prefix: Incomplete
home: str | None
user: bool
install_base: Any
install_platbase: Any
install_base: Incomplete
install_platbase: Incomplete
root: str | None
install_purelib: Any
install_platlib: Any
install_headers: Any
install_purelib: Incomplete
install_platlib: Incomplete
install_headers: Incomplete
install_lib: str | None
install_scripts: Any
install_data: Any
install_userbase: Any
install_usersite: Any
compile: Any
optimize: Any
extra_path: Any
install_scripts: Incomplete
install_data: Incomplete
install_userbase: Incomplete
install_usersite: Incomplete
compile: Incomplete
optimize: Incomplete
extra_path: Incomplete
install_path_file: int
force: int
skip_build: int
warn_dir: int
build_base: Any
build_lib: Any
record: Any
build_base: Incomplete
build_lib: Incomplete
record: Incomplete
def initialize_options(self) -> None: ...
config_vars: Any
install_libbase: Any
config_vars: Incomplete
install_libbase: Incomplete
def finalize_options(self) -> None: ...
def dump_dirs(self, msg) -> None: ...
def finalize_unix(self) -> None: ...
Expand All @@ -43,8 +43,8 @@ class install(Command):
def expand_basedirs(self) -> None: ...
def expand_dirs(self) -> None: ...
def convert_paths(self, *names) -> None: ...
path_file: Any
extra_dirs: Any
path_file: Incomplete
extra_dirs: Incomplete
def handle_extra_path(self) -> None: ...
def change_roots(self, *names) -> None: ...
def create_home_path(self) -> None: ...
Expand All @@ -56,4 +56,4 @@ class install(Command):
def has_headers(self): ...
def has_scripts(self): ...
def has_data(self): ...
sub_commands: Any
sub_commands: Incomplete
18 changes: 9 additions & 9 deletions stubs/setuptools/setuptools/_distutils/command/install_lib.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from typing import Any
from _typeshed import Incomplete

from ..cmd import Command

class install_lib(Command):
description: str
user_options: Any
boolean_options: Any
negative_opt: Any
install_dir: Any
build_dir: Any
user_options: Incomplete
boolean_options: Incomplete
negative_opt: Incomplete
install_dir: Incomplete
build_dir: Incomplete
force: int
compile: Any
optimize: Any
skip_build: Any
compile: Incomplete
optimize: Incomplete
skip_build: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from typing import Any
from _typeshed import Incomplete

from ..cmd import Command

class install_scripts(Command):
description: str
user_options: Any
boolean_options: Any
install_dir: Any
user_options: Incomplete
boolean_options: Incomplete
install_dir: Incomplete
force: int
build_dir: Any
skip_build: Any
build_dir: Incomplete
skip_build: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
outfiles: Any
outfiles: Incomplete
def run(self) -> None: ...
def get_inputs(self): ...
def get_outputs(self): ...
3 changes: 1 addition & 2 deletions stubs/setuptools/setuptools/_distutils/command/register.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from _typeshed import Incomplete
from typing import Any

from ..config import PyPIRCCommand

class register(PyPIRCCommand):
description: str
sub_commands: Any
sub_commands: list[tuple[str, Incomplete]]
list_classifiers: int
strict: int
def initialize_options(self) -> None: ...
Expand Down
Loading