diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2022-07-31 14:51:14 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2022-07-31 14:51:14 -0400 |
commit | 224defdd470ae9a987f4eca7da2a84da47f08c4d (patch) | |
tree | dad02f6525fc1fe35eb5e3ac207ba921c9fd60ce /setuptools/_distutils/command | |
parent | 5cef9ab648c49c891f434bc0914b5738d81db270 (diff) | |
parent | 129480b92212c4821329caaa626ad3379478e001 (diff) | |
download | python-setuptools-git-224defdd470ae9a987f4eca7da2a84da47f08c4d.tar.gz |
Merge https://github.com/pypa/distutils into distutils-129480b
Diffstat (limited to 'setuptools/_distutils/command')
-rw-r--r-- | setuptools/_distutils/command/__init__.py | 8 | ||||
-rw-r--r-- | setuptools/_distutils/command/bdist.py | 54 | ||||
-rw-r--r-- | setuptools/_distutils/command/bdist_dumb.py | 2 | ||||
-rw-r--r-- | setuptools/_distutils/command/bdist_msi.py | 36 | ||||
-rw-r--r-- | setuptools/_distutils/command/bdist_rpm.py | 24 | ||||
-rw-r--r-- | setuptools/_distutils/command/bdist_wininst.py | 4 | ||||
-rw-r--r-- | setuptools/_distutils/command/build.py | 5 | ||||
-rw-r--r-- | setuptools/_distutils/command/build_clib.py | 2 | ||||
-rw-r--r-- | setuptools/_distutils/command/build_ext.py | 17 | ||||
-rw-r--r-- | setuptools/_distutils/command/build_py.py | 3 | ||||
-rw-r--r-- | setuptools/_distutils/command/build_scripts.py | 2 | ||||
-rw-r--r-- | setuptools/_distutils/command/check.py | 2 | ||||
-rw-r--r-- | setuptools/_distutils/command/config.py | 3 | ||||
-rw-r--r-- | setuptools/_distutils/command/install.py | 17 | ||||
-rw-r--r-- | setuptools/_distutils/command/install_egg_info.py | 10 | ||||
-rw-r--r-- | setuptools/_distutils/command/register.py | 8 | ||||
-rw-r--r-- | setuptools/_distutils/command/sdist.py | 2 | ||||
-rw-r--r-- | setuptools/_distutils/command/upload.py | 2 |
18 files changed, 107 insertions, 94 deletions
diff --git a/setuptools/_distutils/command/__init__.py b/setuptools/_distutils/command/__init__.py index d199c242..a40c1f94 100644 --- a/setuptools/_distutils/command/__init__.py +++ b/setuptools/_distutils/command/__init__.py @@ -3,7 +3,7 @@ Package containing implementation of all the standard Distutils commands.""" -__all__ = [ +__all__ = [ # noqa: F822 'build', 'build_py', 'build_ext', @@ -23,10 +23,4 @@ __all__ = [ 'bdist_wininst', 'check', 'upload', - # These two are reserved for future use: - #'bdist_sdux', - #'bdist_pkgtool', - # Note: - # bdist_packager is not included because it only provides - # an abstract base class ] diff --git a/setuptools/_distutils/command/bdist.py b/setuptools/_distutils/command/bdist.py index 2a639761..53f13214 100644 --- a/setuptools/_distutils/command/bdist.py +++ b/setuptools/_distutils/command/bdist.py @@ -5,7 +5,7 @@ distribution).""" import os from distutils.core import Command -from distutils.errors import * +from distutils.errors import DistutilsPlatformError, DistutilsOptionError from distutils.util import get_platform @@ -15,11 +15,17 @@ def show_formats(): formats = [] for format in bdist.format_commands: - formats.append(("formats=" + format, None, bdist.format_command[format][1])) + formats.append(("formats=" + format, None, bdist.format_commands[format][1])) pretty_printer = FancyGetopt(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" @@ -64,31 +70,23 @@ class bdist(Command): # Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS. default_format = {'posix': 'gztar', 'nt': 'zip'} - # Establish the preferred order (for the --help-formats option). - format_commands = [ - 'rpm', - 'gztar', - 'bztar', - 'xztar', - 'ztar', - 'tar', - 'wininst', - 'zip', - 'msi', - ] - - # And the real information. - format_command = { - '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"), - } + # Define commands in preferred order for the --help-formats option + 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 @@ -132,7 +130,7 @@ class bdist(Command): commands = [] for format in self.formats: try: - commands.append(self.format_command[format][0]) + commands.append(self.format_commands[format][0]) except KeyError: raise DistutilsOptionError("invalid format '%s'" % format) diff --git a/setuptools/_distutils/command/bdist_dumb.py b/setuptools/_distutils/command/bdist_dumb.py index 3c387828..d3f519e0 100644 --- a/setuptools/_distutils/command/bdist_dumb.py +++ b/setuptools/_distutils/command/bdist_dumb.py @@ -8,7 +8,7 @@ import os from distutils.core import Command from distutils.util import get_platform from distutils.dir_util import remove_tree, ensure_relative -from distutils.errors import * +from distutils.errors import DistutilsPlatformError from distutils.sysconfig import get_python_version from distutils import log diff --git a/setuptools/_distutils/command/bdist_msi.py b/setuptools/_distutils/command/bdist_msi.py index 2f292c96..6e1e1abd 100644 --- a/setuptools/_distutils/command/bdist_msi.py +++ b/setuptools/_distutils/command/bdist_msi.py @@ -31,9 +31,6 @@ class PyDialog(Dialog): default, cancel, bitmap=true)""" super().__init__(*args) ruler = self.h - 36 - bmwidth = 152 * ruler / 328 - # if kw.get("bitmap", True): - # self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin") self.line("BottomLine", 0, ruler, self.w, 0) def title(self, title): @@ -231,7 +228,7 @@ class bdist_msi(Command): ) self.install_script_key = None - def run(self): + def run(self): # noqa: C901 if not self.skip_build: self.run_command('build') @@ -318,7 +315,7 @@ class bdist_msi(Command): if not self.keep_temp: remove_tree(self.bdist_dir, dry_run=self.dry_run) - def add_files(self): + def add_files(self): # noqa: C901 db = self.db cab = msilib.CAB("distfiles") rootdir = os.path.abspath(self.bdist_dir) @@ -406,11 +403,9 @@ class bdist_msi(Command): exe_action = "PythonExe" + ver target_dir_prop = "TARGETDIR" + ver exe_prop = "PYTHON" + ver - if msilib.Win64: - # type: msidbLocatorTypeRawValue + msidbLocatorType64bit - Type = 2 + 16 - else: - Type = 2 + + # Type: msidbLocatorTypeRawValue + msidbLocatorType64bit + Type = 2 + 16 * bool(msilib.Win64) add_data( self.db, "RegLocator", @@ -517,7 +512,6 @@ class bdist_msi(Command): # see "Dialog Style Bits" modal = 3 # visible | modal modeless = 1 # visible - track_disk_space = 32 # UI customization properties add_data( @@ -590,7 +584,9 @@ class bdist_msi(Command): 320, 80, 0x30003, - "[ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again.", + "[ProductName] setup ended prematurely because of an error. " + "Your system has not been modified. To install this program " + "at a later time, please run the installation again.", ) fatal.text( "Description2", @@ -618,7 +614,8 @@ class bdist_msi(Command): 80, 0x30003, "[ProductName] setup was interrupted. Your system has not been modified. " - "To install this program at a later time, please run the installation again.", + "To install this program at a later time, please run the installation " + "again.", ) user_exit.text( "Description2", @@ -683,7 +680,10 @@ class bdist_msi(Command): 330, 50, 3, - "The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it.", + "The following applications are using files that need to be updated by " + "this " + "setup. Close these applications and then click Retry to continue the " + "installation or Cancel to exit it.", ) inuse.control( "List", @@ -720,7 +720,6 @@ class bdist_msi(Command): None, ) error.text("ErrorText", 50, 9, 280, 48, 3, "") - # error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None) error.pushbutton("N", 120, 72, 81, 21, 3, "No", None).event( "EndDialog", "ErrorNo" ) @@ -785,7 +784,8 @@ class bdist_msi(Command): 194, 30, 3, - "Please wait while the installer finishes determining your disk space requirements.", + "Please wait while the installer finishes determining your disk space " + "requirements.", ) c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None) c.event("EndDialog", "Exit") @@ -802,7 +802,8 @@ class bdist_msi(Command): 320, 40, 0x30003, - "Please wait while the Installer prepares to guide you through the installation.", + "Please wait while the Installer prepares to guide you through the " + "installation.", ) prep.title("Welcome to the [ProductName] Installer") c = prep.text("ActionText", 15, 110, 320, 20, 0x30003, "Pondering...") @@ -1096,7 +1097,6 @@ class bdist_msi(Command): # Close dialog when maintenance action scheduled c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20) - # c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21) maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg") diff --git a/setuptools/_distutils/command/bdist_rpm.py b/setuptools/_distutils/command/bdist_rpm.py index cf4b9525..fcfd7cd8 100644 --- a/setuptools/_distutils/command/bdist_rpm.py +++ b/setuptools/_distutils/command/bdist_rpm.py @@ -3,11 +3,19 @@ Implements the Distutils 'bdist_rpm' command (create RPM source and binary distributions).""" -import subprocess, sys, os +import subprocess +import sys +import os + from distutils.core import Command from distutils.debug import DEBUG from distutils.file_util import write_file -from distutils.errors import * +from distutils.errors import ( + DistutilsOptionError, + DistutilsPlatformError, + DistutilsFileError, + DistutilsExecError, +) from distutils.sysconfig import get_python_version from distutils import log @@ -268,7 +276,7 @@ class bdist_rpm(Command): self.ensure_string('force_arch') - def run(self): + def run(self): # noqa: C901 if DEBUG: print("before _get_package_data():") print("vendor =", self.vendor) @@ -359,12 +367,12 @@ class bdist_rpm(Command): line = out.readline() if not line: break - l = line.strip().split() - assert len(l) == 2 - binary_rpms.append(l[1]) + ell = line.strip().split() + assert len(ell) == 2 + binary_rpms.append(ell[1]) # The source rpm is named after the first entry in the spec file if source_rpm is None: - source_rpm = l[0] + source_rpm = ell[0] status = out.close() if status: @@ -401,7 +409,7 @@ class bdist_rpm(Command): def _dist_path(self, path): return os.path.join(self.dist_dir, os.path.basename(path)) - def _make_spec_file(self): + def _make_spec_file(self): # noqa: C901 """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ diff --git a/setuptools/_distutils/command/bdist_wininst.py b/setuptools/_distutils/command/bdist_wininst.py index 76b8a890..7e9a64a5 100644 --- a/setuptools/_distutils/command/bdist_wininst.py +++ b/setuptools/_distutils/command/bdist_wininst.py @@ -9,7 +9,7 @@ import warnings from distutils.core import Command from distutils.util import get_platform from distutils.dir_util import remove_tree -from distutils.errors import * +from distutils.errors import DistutilsOptionError, DistutilsPlatformError from distutils.sysconfig import get_python_version from distutils import log @@ -357,7 +357,7 @@ class bdist_wininst(Command): ) return installer_name - def get_exe_bytes(self): + def get_exe_bytes(self): # noqa: C901 # If a target-version other than the current version has been # specified, then using the MSVC version from *this* build is no good. # Without actually finding and executing the target version and parsing diff --git a/setuptools/_distutils/command/build.py b/setuptools/_distutils/command/build.py index 3aa7fac7..e4b06425 100644 --- a/setuptools/_distutils/command/build.py +++ b/setuptools/_distutils/command/build.py @@ -2,7 +2,8 @@ Implements the Distutils 'build' command.""" -import sys, os +import sys +import os from distutils.core import Command from distutils.errors import DistutilsOptionError from distutils.util import get_platform @@ -65,7 +66,7 @@ class build(Command): self.executable = None self.parallel = None - def finalize_options(self): + def finalize_options(self): # noqa: C901 if self.plat_name is None: self.plat_name = get_platform() else: diff --git a/setuptools/_distutils/command/build_clib.py b/setuptools/_distutils/command/build_clib.py index 003499fa..50bb9bba 100644 --- a/setuptools/_distutils/command/build_clib.py +++ b/setuptools/_distutils/command/build_clib.py @@ -16,7 +16,7 @@ module.""" import os from distutils.core import Command -from distutils.errors import * +from distutils.errors import DistutilsSetupError from distutils.sysconfig import customize_compiler from distutils import log diff --git a/setuptools/_distutils/command/build_ext.py b/setuptools/_distutils/command/build_ext.py index 1a6dd394..153a0b6d 100644 --- a/setuptools/_distutils/command/build_ext.py +++ b/setuptools/_distutils/command/build_ext.py @@ -9,7 +9,14 @@ import os import re import sys from distutils.core import Command -from distutils.errors import * +from distutils.errors import ( + DistutilsOptionError, + DistutilsSetupError, + CCompilerError, + DistutilsError, + CompileError, + DistutilsPlatformError, +) from distutils.sysconfig import customize_compiler, get_python_version from distutils.sysconfig import get_config_h_filename from distutils.dep_util import newer_group @@ -124,7 +131,7 @@ class build_ext(Command): self.user = None self.parallel = None - def finalize_options(self): + def finalize_options(self): # noqa: C901 from distutils import sysconfig self.set_undefined_options( @@ -272,7 +279,7 @@ class build_ext(Command): except ValueError: raise DistutilsOptionError("parallel should be an integer") - def run(self): + def run(self): # noqa: C901 from distutils.ccompiler import new_compiler # 'self.extensions', as supplied by setup.py, is a list of @@ -338,7 +345,7 @@ class build_ext(Command): # Now actually compile and link everything. self.build_extensions() - def check_extensions_list(self, extensions): + def check_extensions_list(self, extensions): # noqa: C901 """Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, @@ -724,7 +731,7 @@ class build_ext(Command): ext.export_symbols.append(initfunc_name) return ext.export_symbols - def get_libraries(self, ext): + def get_libraries(self, ext): # noqa: C901 """Return the list of libraries to link against when building a shared extension. On most platforms, this is just 'ext.libraries'; on Windows, we add the Python library (eg. python20.dll). diff --git a/setuptools/_distutils/command/build_py.py b/setuptools/_distutils/command/build_py.py index 7723d359..47c6158e 100644 --- a/setuptools/_distutils/command/build_py.py +++ b/setuptools/_distutils/command/build_py.py @@ -8,7 +8,7 @@ import sys import glob from distutils.core import Command -from distutils.errors import * +from distutils.errors import DistutilsOptionError, DistutilsFileError from distutils.util import convert_path from distutils import log @@ -137,7 +137,6 @@ class build_py(Command): def build_package_data(self): """Copy data files into build directory""" - lastdir = None for package, src_dir, build_dir, filenames in self.data_files: for filename in filenames: target = os.path.join(build_dir, filename) diff --git a/setuptools/_distutils/command/build_scripts.py b/setuptools/_distutils/command/build_scripts.py index 17058dbf..2cc5d1e0 100644 --- a/setuptools/_distutils/command/build_scripts.py +++ b/setuptools/_distutils/command/build_scripts.py @@ -75,7 +75,7 @@ class build_scripts(Command): return outfiles, updated_files - def _copy_script(self, script, outfiles, updated_files): + def _copy_script(self, script, outfiles, updated_files): # noqa: C901 shebang_match = None script = convert_path(script) outfile = os.path.join(self.build_dir, os.path.basename(script)) diff --git a/setuptools/_distutils/command/check.py b/setuptools/_distutils/command/check.py index 176a8b87..9c3523a8 100644 --- a/setuptools/_distutils/command/check.py +++ b/setuptools/_distutils/command/check.py @@ -2,8 +2,6 @@ Implements the Distutils 'check' command. """ -from email.utils import getaddresses - from distutils.core import Command from distutils.errors import DistutilsSetupError diff --git a/setuptools/_distutils/command/config.py b/setuptools/_distutils/command/config.py index 73de1d3e..4492c896 100644 --- a/setuptools/_distutils/command/config.py +++ b/setuptools/_distutils/command/config.py @@ -9,7 +9,8 @@ configure-like tasks: "try to compile this C code", or "figure out where this header file lives". """ -import os, re +import os +import re from distutils.core import Command from distutils.errors import DistutilsExecError diff --git a/setuptools/_distutils/command/install.py b/setuptools/_distutils/command/install.py index 7d9054e3..a38cddcd 100644 --- a/setuptools/_distutils/command/install.py +++ b/setuptools/_distutils/command/install.py @@ -12,11 +12,10 @@ from distutils import log from distutils.core import Command from distutils.debug import DEBUG from distutils.sysconfig import get_config_vars -from distutils.errors import DistutilsPlatformError from distutils.file_util import write_file from distutils.util import convert_path, subst_vars, change_root from distutils.util import get_platform -from distutils.errors import DistutilsOptionError +from distutils.errors import DistutilsOptionError, DistutilsPlatformError from . import _framework_compat as fw from .. import _collections @@ -36,8 +35,10 @@ WINDOWS_SCHEME = { INSTALL_SCHEMES = { 'posix_prefix': { 'purelib': '{base}/lib/{implementation_lower}{py_version_short}/site-packages', - 'platlib': '{platbase}/{platlibdir}/{implementation_lower}{py_version_short}/site-packages', - 'headers': '{base}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}', + 'platlib': '{platbase}/{platlibdir}/{implementation_lower}' + '{py_version_short}/site-packages', + 'headers': '{base}/include/{implementation_lower}' + '{py_version_short}{abiflags}/{dist_name}', 'scripts': '{base}/bin', 'data': '{base}', }, @@ -70,7 +71,8 @@ if HAS_USER_SITE: INSTALL_SCHEMES['nt_user'] = { 'purelib': '{usersite}', 'platlib': '{usersite}', - 'headers': '{userbase}/{implementation}{py_version_nodot_plat}/Include/{dist_name}', + 'headers': '{userbase}/{implementation}{py_version_nodot_plat}' + '/Include/{dist_name}', 'scripts': '{userbase}/{implementation}{py_version_nodot_plat}/Scripts', 'data': '{userbase}', } @@ -78,7 +80,8 @@ if HAS_USER_SITE: INSTALL_SCHEMES['posix_user'] = { 'purelib': '{usersite}', 'platlib': '{usersite}', - 'headers': '{userbase}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}', + 'headers': '{userbase}/include/{implementation_lower}' + '{py_version_short}{abiflags}/{dist_name}', 'scripts': '{userbase}/bin', 'data': '{userbase}', } @@ -327,7 +330,7 @@ class install(Command): # party Python modules on various platforms given a wide # array of user input is decided. Yes, it's quite complex!) - def finalize_options(self): + def finalize_options(self): # noqa: C901 """Finalizes options.""" # This method (and its helpers, like 'finalize_unix()', # 'finalize_other()', and 'select_scheme()') is where the default diff --git a/setuptools/_distutils/command/install_egg_info.py b/setuptools/_distutils/command/install_egg_info.py index dc939633..d5e68a6e 100644 --- a/setuptools/_distutils/command/install_egg_info.py +++ b/setuptools/_distutils/command/install_egg_info.py @@ -1,12 +1,16 @@ -"""distutils.command.install_egg_info +""" +distutils.command.install_egg_info Implements the Distutils 'install_egg_info' command, for installing -a package's PKG-INFO metadata.""" +a package's PKG-INFO metadata. +""" +import os +import sys +import re from distutils.cmd import Command from distutils import log, dir_util -import os, sys, re class install_egg_info(Command): diff --git a/setuptools/_distutils/command/register.py b/setuptools/_distutils/command/register.py index ca407eb7..d2351ab8 100644 --- a/setuptools/_distutils/command/register.py +++ b/setuptools/_distutils/command/register.py @@ -7,11 +7,11 @@ Implements the Distutils 'register' command (register with the repository). import getpass import io -import urllib.parse, urllib.request +import urllib.parse +import urllib.request from warnings import warn from distutils.core import PyPIRCCommand -from distutils.errors import * from distutils import log @@ -104,7 +104,7 @@ class register(PyPIRCCommand): (code, result) = self.post_to_server(self.build_post_data('verify')) log.info('Server response (%s): %s', code, result) - def send_metadata(self): + def send_metadata(self): # noqa: C901 '''Send the metadata to the package index server. Well, do the following: @@ -261,7 +261,7 @@ Your selection [default 1]: ''', data['metadata_version'] = '1.1' return data - def post_to_server(self, data, auth=None): + def post_to_server(self, data, auth=None): # noqa: C901 '''Post a query to the server, and return a string response.''' if 'name' in data: self.announce( diff --git a/setuptools/_distutils/command/sdist.py b/setuptools/_distutils/command/sdist.py index aad3e713..ec3c97ac 100644 --- a/setuptools/_distutils/command/sdist.py +++ b/setuptools/_distutils/command/sdist.py @@ -15,7 +15,7 @@ from distutils.text_file import TextFile from distutils.filelist import FileList from distutils import log from distutils.util import convert_path -from distutils.errors import DistutilsTemplateError, DistutilsOptionError +from distutils.errors import DistutilsOptionError, DistutilsTemplateError def show_formats(): diff --git a/setuptools/_distutils/command/upload.py b/setuptools/_distutils/command/upload.py index 782e3dea..f2a8118e 100644 --- a/setuptools/_distutils/command/upload.py +++ b/setuptools/_distutils/command/upload.py @@ -71,7 +71,7 @@ class upload(PyPIRCCommand): for command, pyversion, filename in self.distribution.dist_files: self.upload_file(command, pyversion, filename) - def upload_file(self, command, pyversion, filename): + def upload_file(self, command, pyversion, filename): # noqa: C901 # Makes sure the repository URL is compliant schema, netloc, url, params, query, fragments = urlparse(self.repository) if params or query or fragments: |