Skip to content

Commit

Permalink
Override distribution attribute type in all distutils-based commands (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri authored Aug 20, 2024
2 parents 4147b09 + 429ac58 commit 477f713
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions setuptools/command/bdist_rpm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ..dist import Distribution
from ..warnings import SetuptoolsDeprecationWarning

import distutils.command.bdist_rpm as orig
Expand All @@ -12,6 +13,8 @@ class bdist_rpm(orig.bdist_rpm):
disable eggs in RPM distributions.
"""

distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution

def run(self):
SetuptoolsDeprecationWarning.emit(
"Deprecated command",
Expand Down
4 changes: 4 additions & 0 deletions setuptools/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

from typing import Protocol

from ..dist import Distribution

from distutils.command.build import build as _build

_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[:]

Expand Down
4 changes: 4 additions & 0 deletions setuptools/command/build_clib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from ..dist import Distribution

import distutils.command.build_clib as orig
from distutils import log
from distutils.errors import DistutilsSetupError
Expand Down Expand Up @@ -25,6 +27,8 @@ class build_clib(orig.build_clib):
the compiler.
"""

distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution

def build_libraries(self, libraries):
for lib_name, build_info in libraries:
sources = build_info.get('sources')
Expand Down
2 changes: 0 additions & 2 deletions setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from setuptools.command import bdist_egg
from setuptools.command.sdist import sdist, walk_revctrl
from setuptools.command.setopt import edit_config
from setuptools.dist import Distribution
from setuptools.glob import glob

from .. import _entry_points, _normalization
Expand Down Expand Up @@ -522,7 +521,6 @@ def _safe_path(self, path):


class manifest_maker(sdist):
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
template = "MANIFEST.in"

def initialize_options(self):
Expand Down
4 changes: 4 additions & 0 deletions setuptools/command/register.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from setuptools.errors import RemovedCommandError

from ..dist import Distribution

import distutils.command.register as orig
from distutils import log


class register(orig.register):
"""Formerly used to register packages on PyPI."""

distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution

def run(self):
msg = (
"The register command has been removed, use twine to upload "
Expand Down

0 comments on commit 477f713

Please sign in to comment.