update
This commit is contained in:
@@ -1,40 +1,20 @@
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, List, Dict
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Protocol
|
||||
|
||||
from ..dist import Distribution
|
||||
|
||||
from distutils.command.build import build as _build
|
||||
|
||||
from ..warnings import SetuptoolsDeprecationWarning
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Protocol
|
||||
elif TYPE_CHECKING:
|
||||
from typing_extensions import Protocol
|
||||
else:
|
||||
from abc import ABC as Protocol
|
||||
|
||||
|
||||
_ORIGINAL_SUBCOMMANDS = {"build_py", "build_clib", "build_ext", "build_scripts"}
|
||||
|
||||
|
||||
class build(_build):
|
||||
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
|
||||
|
||||
# copy to avoid sharing the object with parent class
|
||||
sub_commands = _build.sub_commands[:]
|
||||
|
||||
def get_sub_commands(self):
|
||||
subcommands = {cmd[0] for cmd in _build.sub_commands}
|
||||
if subcommands - _ORIGINAL_SUBCOMMANDS:
|
||||
SetuptoolsDeprecationWarning.emit(
|
||||
"Direct usage of `distutils` commands",
|
||||
"""
|
||||
It seems that you are using `distutils.command.build` to add
|
||||
new subcommands. Using `distutils` directly is considered deprecated,
|
||||
please use `setuptools.command.build`.
|
||||
""",
|
||||
due_date=(2023, 12, 13), # Warning introduced in 13 Jun 2022.
|
||||
see_url="https://peps.python.org/pep-0632/",
|
||||
)
|
||||
self.sub_commands = _build.sub_commands
|
||||
return super().get_sub_commands()
|
||||
|
||||
|
||||
class SubCommand(Protocol):
|
||||
"""In order to support editable installations (see :pep:`660`) all
|
||||
@@ -107,14 +87,17 @@ class SubCommand(Protocol):
|
||||
|
||||
def initialize_options(self):
|
||||
"""(Required by the original :class:`setuptools.Command` interface)"""
|
||||
...
|
||||
|
||||
def finalize_options(self):
|
||||
"""(Required by the original :class:`setuptools.Command` interface)"""
|
||||
...
|
||||
|
||||
def run(self):
|
||||
"""(Required by the original :class:`setuptools.Command` interface)"""
|
||||
...
|
||||
|
||||
def get_source_files(self) -> List[str]:
|
||||
def get_source_files(self) -> list[str]:
|
||||
"""
|
||||
Return a list of all files that are used by the command to create the expected
|
||||
outputs.
|
||||
@@ -124,8 +107,9 @@ class SubCommand(Protocol):
|
||||
with all the files necessary to build the distribution.
|
||||
All files should be strings relative to the project root directory.
|
||||
"""
|
||||
...
|
||||
|
||||
def get_outputs(self) -> List[str]:
|
||||
def get_outputs(self) -> list[str]:
|
||||
"""
|
||||
Return a list of files intended for distribution as they would have been
|
||||
produced by the build.
|
||||
@@ -137,8 +121,9 @@ class SubCommand(Protocol):
|
||||
in ``get_output_mapping()`` plus files that are generated during the build
|
||||
and don't correspond to any source file already present in the project.
|
||||
"""
|
||||
...
|
||||
|
||||
def get_output_mapping(self) -> Dict[str, str]:
|
||||
def get_output_mapping(self) -> dict[str, str]:
|
||||
"""
|
||||
Return a mapping between destination files as they would be produced by the
|
||||
build (dict keys) into the respective existing (source) files (dict values).
|
||||
@@ -147,3 +132,4 @@ class SubCommand(Protocol):
|
||||
Destination files should be strings in the form of
|
||||
``"{build_lib}/destination/file/path"``.
|
||||
"""
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user