Skip to content

Commit ccb0666

Browse files
authored
Merge pull request #3475 from pypa/distutils-129480b
Merge with distutils@129480b
2 parents 5cef9ab + b8d50cf commit ccb0666

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+389
-797
lines changed

changelog.d/3475.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Merge with pypa/distutils@129480b, including substantial delinting and cleanup, some refactoring around compiler logic, better messaging in cygwincompiler (pypa/distutils#161).

setuptools/_distutils/_msvccompiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def make_out_path(p):
345345

346346
return list(map(make_out_path, source_filenames))
347347

348-
def compile(
348+
def compile( # noqa: C901
349349
self,
350350
sources,
351351
output_dir=None,

setuptools/_distutils/archive_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _set_uid_gid(tarinfo):
134134
return archive_name
135135

136136

137-
def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
137+
def make_zipfile(base_name, base_dir, verbose=0, dry_run=0): # noqa: C901
138138
"""Create a zip file from all the files under 'base_dir'.
139139
140140
The output zip file will be named 'base_name' + ".zip". Uses either the

setuptools/_distutils/bcppcompiler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, verbose=0, dry_run=0, force=0):
7777

7878
# -- Worker methods ------------------------------------------------
7979

80-
def compile(
80+
def compile( # noqa: C901
8181
self,
8282
sources,
8383
output_dir=None,
@@ -174,7 +174,7 @@ def create_static_lib(
174174

175175
# create_static_lib ()
176176

177-
def link(
177+
def link( # noqa: C901
178178
self,
179179
target_desc,
180180
objects,
@@ -250,8 +250,8 @@ def link(
250250
else:
251251
objects.append(file)
252252

253-
for l in library_dirs:
254-
ld_args.append("/L%s" % os.path.normpath(l))
253+
for ell in library_dirs:
254+
ld_args.append("/L%s" % os.path.normpath(ell))
255255
ld_args.append("/L.") # we sometimes use relative paths
256256

257257
# list of object files

setuptools/_distutils/ccompiler.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33
Contains CCompiler, an abstract base class that defines the interface
44
for the Distutils compiler abstraction model."""
55

6-
import sys, os, re
7-
from distutils.errors import *
6+
import sys
7+
import os
8+
import re
9+
from distutils.errors import (
10+
CompileError,
11+
LinkError,
12+
UnknownFileError,
13+
DistutilsPlatformError,
14+
DistutilsModuleError,
15+
)
816
from distutils.spawn import spawn
917
from distutils.file_util import move_file
1018
from distutils.dir_util import mkpath
@@ -808,7 +816,7 @@ def library_option(self, lib):
808816
"""
809817
raise NotImplementedError
810818

811-
def has_function(
819+
def has_function( # noqa: C901
812820
self,
813821
funcname,
814822
includes=None,
@@ -945,10 +953,9 @@ def library_filename(
945953
self, libname, lib_type='static', strip_dir=0, output_dir='' # or 'shared'
946954
):
947955
assert output_dir is not None
948-
if lib_type not in ("static", "shared", "dylib", "xcode_stub"):
949-
raise ValueError(
950-
"'lib_type' must be \"static\", \"shared\", \"dylib\", or \"xcode_stub\""
951-
)
956+
expected = '"static", "shared", "dylib", "xcode_stub"'
957+
if lib_type not in eval(expected):
958+
raise ValueError(f"'lib_type' must be {expected}")
952959
fmt = getattr(self, lib_type + "_lib_format")
953960
ext = getattr(self, lib_type + "_lib_extension")
954961

setuptools/_distutils/cmd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
in the distutils.command package.
55
"""
66

7-
import sys, os, re
7+
import sys
8+
import os
9+
import re
810
from distutils.errors import DistutilsOptionError
911
from distutils import util, dir_util, file_util, archive_util, dep_util
1012
from distutils import log

setuptools/_distutils/command/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Package containing implementation of all the standard Distutils
44
commands."""
55

6-
__all__ = [
6+
__all__ = [ # noqa: F822
77
'build',
88
'build_py',
99
'build_ext',
@@ -23,10 +23,4 @@
2323
'bdist_wininst',
2424
'check',
2525
'upload',
26-
# These two are reserved for future use:
27-
#'bdist_sdux',
28-
#'bdist_pkgtool',
29-
# Note:
30-
# bdist_packager is not included because it only provides
31-
# an abstract base class
3226
]

setuptools/_distutils/command/bdist.py

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import os
77
from distutils.core import Command
8-
from distutils.errors import *
8+
from distutils.errors import DistutilsPlatformError, DistutilsOptionError
99
from distutils.util import get_platform
1010

1111

@@ -15,11 +15,17 @@ def show_formats():
1515

1616
formats = []
1717
for format in bdist.format_commands:
18-
formats.append(("formats=" + format, None, bdist.format_command[format][1]))
18+
formats.append(("formats=" + format, None, bdist.format_commands[format][1]))
1919
pretty_printer = FancyGetopt(formats)
2020
pretty_printer.print_help("List of available distribution formats:")
2121

2222

23+
class ListCompat(dict):
24+
# adapter to allow for Setuptools compatibility in format_commands
25+
def append(self, item):
26+
return
27+
28+
2329
class bdist(Command):
2430

2531
description = "create a built (binary) distribution"
@@ -64,31 +70,23 @@ class bdist(Command):
6470
# Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
6571
default_format = {'posix': 'gztar', 'nt': 'zip'}
6672

67-
# Establish the preferred order (for the --help-formats option).
68-
format_commands = [
69-
'rpm',
70-
'gztar',
71-
'bztar',
72-
'xztar',
73-
'ztar',
74-
'tar',
75-
'wininst',
76-
'zip',
77-
'msi',
78-
]
79-
80-
# And the real information.
81-
format_command = {
82-
'rpm': ('bdist_rpm', "RPM distribution"),
83-
'gztar': ('bdist_dumb', "gzip'ed tar file"),
84-
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
85-
'xztar': ('bdist_dumb', "xz'ed tar file"),
86-
'ztar': ('bdist_dumb', "compressed tar file"),
87-
'tar': ('bdist_dumb', "tar file"),
88-
'wininst': ('bdist_wininst', "Windows executable installer"),
89-
'zip': ('bdist_dumb', "ZIP file"),
90-
'msi': ('bdist_msi', "Microsoft Installer"),
91-
}
73+
# Define commands in preferred order for the --help-formats option
74+
format_commands = ListCompat(
75+
{
76+
'rpm': ('bdist_rpm', "RPM distribution"),
77+
'gztar': ('bdist_dumb', "gzip'ed tar file"),
78+
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
79+
'xztar': ('bdist_dumb', "xz'ed tar file"),
80+
'ztar': ('bdist_dumb', "compressed tar file"),
81+
'tar': ('bdist_dumb', "tar file"),
82+
'wininst': ('bdist_wininst', "Windows executable installer"),
83+
'zip': ('bdist_dumb', "ZIP file"),
84+
'msi': ('bdist_msi', "Microsoft Installer"),
85+
}
86+
)
87+
88+
# for compatibility until Setuptools references only format_commands
89+
format_command = format_commands
9290

9391
def initialize_options(self):
9492
self.bdist_base = None
@@ -132,7 +130,7 @@ def run(self):
132130
commands = []
133131
for format in self.formats:
134132
try:
135-
commands.append(self.format_command[format][0])
133+
commands.append(self.format_commands[format][0])
136134
except KeyError:
137135
raise DistutilsOptionError("invalid format '%s'" % format)
138136

setuptools/_distutils/command/bdist_dumb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from distutils.core import Command
99
from distutils.util import get_platform
1010
from distutils.dir_util import remove_tree, ensure_relative
11-
from distutils.errors import *
11+
from distutils.errors import DistutilsPlatformError
1212
from distutils.sysconfig import get_python_version
1313
from distutils import log
1414

setuptools/_distutils/command/bdist_msi.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ def __init__(self, *args, **kw):
3131
default, cancel, bitmap=true)"""
3232
super().__init__(*args)
3333
ruler = self.h - 36
34-
bmwidth = 152 * ruler / 328
35-
# if kw.get("bitmap", True):
36-
# self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
3734
self.line("BottomLine", 0, ruler, self.w, 0)
3835

3936
def title(self, title):
@@ -231,7 +228,7 @@ def finalize_options(self):
231228
)
232229
self.install_script_key = None
233230

234-
def run(self):
231+
def run(self): # noqa: C901
235232
if not self.skip_build:
236233
self.run_command('build')
237234

@@ -318,7 +315,7 @@ def run(self):
318315
if not self.keep_temp:
319316
remove_tree(self.bdist_dir, dry_run=self.dry_run)
320317

321-
def add_files(self):
318+
def add_files(self): # noqa: C901
322319
db = self.db
323320
cab = msilib.CAB("distfiles")
324321
rootdir = os.path.abspath(self.bdist_dir)
@@ -406,11 +403,9 @@ def add_find_python(self):
406403
exe_action = "PythonExe" + ver
407404
target_dir_prop = "TARGETDIR" + ver
408405
exe_prop = "PYTHON" + ver
409-
if msilib.Win64:
410-
# type: msidbLocatorTypeRawValue + msidbLocatorType64bit
411-
Type = 2 + 16
412-
else:
413-
Type = 2
406+
407+
# Type: msidbLocatorTypeRawValue + msidbLocatorType64bit
408+
Type = 2 + 16 * bool(msilib.Win64)
414409
add_data(
415410
self.db,
416411
"RegLocator",
@@ -517,7 +512,6 @@ def add_ui(self):
517512
# see "Dialog Style Bits"
518513
modal = 3 # visible | modal
519514
modeless = 1 # visible
520-
track_disk_space = 32
521515

522516
# UI customization properties
523517
add_data(
@@ -590,7 +584,9 @@ def add_ui(self):
590584
320,
591585
80,
592586
0x30003,
593-
"[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.",
587+
"[ProductName] setup ended prematurely because of an error. "
588+
"Your system has not been modified. To install this program "
589+
"at a later time, please run the installation again.",
594590
)
595591
fatal.text(
596592
"Description2",
@@ -618,7 +614,8 @@ def add_ui(self):
618614
80,
619615
0x30003,
620616
"[ProductName] setup was interrupted. Your system has not been modified. "
621-
"To install this program at a later time, please run the installation again.",
617+
"To install this program at a later time, please run the installation "
618+
"again.",
622619
)
623620
user_exit.text(
624621
"Description2",
@@ -683,7 +680,10 @@ def add_ui(self):
683680
330,
684681
50,
685682
3,
686-
"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.",
683+
"The following applications are using files that need to be updated by "
684+
"this "
685+
"setup. Close these applications and then click Retry to continue the "
686+
"installation or Cancel to exit it.",
687687
)
688688
inuse.control(
689689
"List",
@@ -720,7 +720,6 @@ def add_ui(self):
720720
None,
721721
)
722722
error.text("ErrorText", 50, 9, 280, 48, 3, "")
723-
# error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
724723
error.pushbutton("N", 120, 72, 81, 21, 3, "No", None).event(
725724
"EndDialog", "ErrorNo"
726725
)
@@ -785,7 +784,8 @@ def add_ui(self):
785784
194,
786785
30,
787786
3,
788-
"Please wait while the installer finishes determining your disk space requirements.",
787+
"Please wait while the installer finishes determining your disk space "
788+
"requirements.",
789789
)
790790
c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
791791
c.event("EndDialog", "Exit")
@@ -802,7 +802,8 @@ def add_ui(self):
802802
320,
803803
40,
804804
0x30003,
805-
"Please wait while the Installer prepares to guide you through the installation.",
805+
"Please wait while the Installer prepares to guide you through the "
806+
"installation.",
806807
)
807808
prep.title("Welcome to the [ProductName] Installer")
808809
c = prep.text("ActionText", 15, 110, 320, 20, 0x30003, "Pondering...")
@@ -1096,7 +1097,6 @@ def add_ui(self):
10961097

10971098
# Close dialog when maintenance action scheduled
10981099
c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
1099-
# c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
11001100

11011101
maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
11021102

0 commit comments

Comments
 (0)