From 07ffb8f74a42b14eca7ec63432bd39539f7c14da Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 3 Aug 2022 10:40:15 -0400 Subject: [PATCH 1/3] Revert "Remove compatibility shims for Setuptools." This reverts commit c0a4ea65ab68c8c6cb6ad54cc646c58bede6f0f4. --- distutils/command/bdist.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/distutils/command/bdist.py b/distutils/command/bdist.py index 4af1b8e668..53f1321450 100644 --- a/distutils/command/bdist.py +++ b/distutils/command/bdist.py @@ -20,6 +20,12 @@ def show_formats(): pretty_printer.print_help("List of available distribution formats:") +class ListCompat(dict): + # adapter to allow for Setuptools compatibility in format_commands + def append(self, item): + return + + class bdist(Command): description = "create a built (binary) distribution" @@ -65,18 +71,23 @@ class bdist(Command): default_format = {'posix': 'gztar', 'nt': 'zip'} # Define commands in preferred order for the --help-formats option - format_commands = dict( - rpm=('bdist_rpm', "RPM distribution"), - gztar=('bdist_dumb', "gzip'ed tar file"), - bztar=('bdist_dumb', "bzip2'ed tar file"), - xztar=('bdist_dumb', "xz'ed tar file"), - ztar=('bdist_dumb', "compressed tar file"), - tar=('bdist_dumb', "tar file"), - wininst=('bdist_wininst', "Windows executable installer"), - zip=('bdist_dumb', "ZIP file"), - msi=('bdist_msi', "Microsoft Installer"), + format_commands = ListCompat( + { + 'rpm': ('bdist_rpm', "RPM distribution"), + 'gztar': ('bdist_dumb', "gzip'ed tar file"), + 'bztar': ('bdist_dumb', "bzip2'ed tar file"), + 'xztar': ('bdist_dumb', "xz'ed tar file"), + 'ztar': ('bdist_dumb', "compressed tar file"), + 'tar': ('bdist_dumb', "tar file"), + 'wininst': ('bdist_wininst', "Windows executable installer"), + 'zip': ('bdist_dumb', "ZIP file"), + 'msi': ('bdist_msi', "Microsoft Installer"), + } ) + # for compatibility until Setuptools references only format_commands + format_command = format_commands + def initialize_options(self): self.bdist_base = None self.plat_name = None From 274758f1c02048d295efdbc13d2f88d9923547f8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 3 Aug 2022 10:43:39 -0400 Subject: [PATCH 2/3] Mark use of format_commands.append as deprecated. Ref anxuae/setuptools-cythonize#8. --- distutils/command/bdist.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/distutils/command/bdist.py b/distutils/command/bdist.py index 53f1321450..c9fdbf131c 100644 --- a/distutils/command/bdist.py +++ b/distutils/command/bdist.py @@ -4,6 +4,8 @@ distribution).""" import os +import warnings + from distutils.core import Command from distutils.errors import DistutilsPlatformError, DistutilsOptionError from distutils.util import get_platform @@ -23,7 +25,11 @@ def show_formats(): class ListCompat(dict): # adapter to allow for Setuptools compatibility in format_commands def append(self, item): - return + warnings.warn( + """format_commands is now a dict. append is deprecated.""", + DeprecationWarning, + stacklevel=2, + ) class bdist(Command): @@ -85,7 +91,7 @@ class bdist(Command): } ) - # for compatibility until Setuptools references only format_commands + # for compatibility until consumers only reference format_commands format_command = format_commands def initialize_options(self): From 7c55391347bf33e673f54099470f2d0f10264e2a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 3 Aug 2022 10:46:01 -0400 Subject: [PATCH 3/3] Update changelog. --- changelog.d/3482.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/3482.misc.rst diff --git a/changelog.d/3482.misc.rst b/changelog.d/3482.misc.rst new file mode 100644 index 0000000000..10bab94e58 --- /dev/null +++ b/changelog.d/3482.misc.rst @@ -0,0 +1 @@ +Sync with pypa/distutils@274758f1c02048d295efdbc13d2f88d9923547f8, restoring compatibility shim in bdist.format_commands.