Skip to content

Commit 43c6ee4

Browse files
committed
Merge https://github.com/pypa/distutils into distutils-8c3c3d29
2 parents 8032430 + 8c3c3d2 commit 43c6ee4

Some content is hidden

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

53 files changed

+152
-111
lines changed

setuptools/_distutils/_collections.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def bounds(self):
185185
return (sorted_keys[RangeMap.first_item], sorted_keys[RangeMap.last_item])
186186

187187
# some special values for the RangeMap
188-
undefined_value = type(str('RangeValueUndefined'), (), {})()
188+
undefined_value = type('RangeValueUndefined', (), {})()
189189

190190
class Item(int):
191191
"RangeMap Item"

setuptools/_distutils/_msvccompiler.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ def compile( # noqa: C901
339339
extra_postargs=None,
340340
depends=None,
341341
):
342-
343342
if not self.initialized:
344343
self.initialize()
345344
compile_info = self._setup_compile(
@@ -413,8 +412,7 @@ def compile( # noqa: C901
413412
args = [self.cc] + compile_opts + pp_opts
414413
if add_cpp_opts:
415414
args.append('/EHsc')
416-
args.append(input_opt)
417-
args.append("/Fo" + obj)
415+
args.extend((input_opt, "/Fo" + obj))
418416
args.extend(extra_postargs)
419417

420418
try:
@@ -427,7 +425,6 @@ def compile( # noqa: C901
427425
def create_static_lib(
428426
self, objects, output_libname, output_dir=None, debug=0, target_lang=None
429427
):
430-
431428
if not self.initialized:
432429
self.initialize()
433430
objects, output_dir = self._fix_object_args(objects, output_dir)
@@ -461,7 +458,6 @@ def link(
461458
build_temp=None,
462459
target_lang=None,
463460
):
464-
465461
if not self.initialized:
466462
self.initialize()
467463
objects, output_dir = self._fix_object_args(objects, output_dir)

setuptools/_distutils/bcppcompiler.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class BCPPCompiler(CCompiler):
6464
exe_extension = '.exe'
6565

6666
def __init__(self, verbose=0, dry_run=0, force=0):
67-
6867
super().__init__(verbose, dry_run, force)
6968

7069
# These executables are assumed to all be in the path.
@@ -98,7 +97,6 @@ def compile( # noqa: C901
9897
extra_postargs=None,
9998
depends=None,
10099
):
101-
102100
macros, objects, extra_postargs, pp_opts, build = self._setup_compile(
103101
output_dir, macros, include_dirs, sources, depends, extra_postargs
104102
)
@@ -167,7 +165,6 @@ def compile( # noqa: C901
167165
def create_static_lib(
168166
self, objects, output_libname, output_dir=None, debug=0, target_lang=None
169167
):
170-
171168
(objects, output_dir) = self._fix_object_args(objects, output_dir)
172169
output_filename = self.library_filename(output_libname, output_dir=output_dir)
173170

@@ -200,7 +197,6 @@ def link( # noqa: C901
200197
build_temp=None,
201198
target_lang=None,
202199
):
203-
204200
# XXX this ignores 'build_temp'! should follow the lead of
205201
# msvccompiler.py
206202

@@ -219,7 +215,6 @@ def link( # noqa: C901
219215
output_filename = os.path.join(output_dir, output_filename)
220216

221217
if self._need_link(objects, output_filename):
222-
223218
# Figure out linker args based on type of target.
224219
if target_desc == CCompiler.EXECUTABLE:
225220
startup_obj = 'c0w32'
@@ -294,8 +289,7 @@ def link( # noqa: C901
294289
ld_args.append(libfile)
295290

296291
# some default libraries
297-
ld_args.append('import32')
298-
ld_args.append('cw32mt')
292+
ld_args.extend(('import32', 'cw32mt'))
299293

300294
# def file for export symbols
301295
ld_args.extend([',', def_file])
@@ -381,7 +375,6 @@ def preprocess(
381375
extra_preargs=None,
382376
extra_postargs=None,
383377
):
384-
385378
(_, macros, include_dirs) = self._fix_compile_args(None, macros, include_dirs)
386379
pp_opts = gen_preprocess_options(macros, include_dirs)
387380
pp_args = ['cpp32.exe'] + pp_opts

setuptools/_distutils/ccompiler.py

+40-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import os
88
import re
9+
import warnings
910

1011
from .errors import (
1112
CompileError,
@@ -388,7 +389,7 @@ def _fix_compile_args(self, output_dir, macros, include_dirs):
388389
raise TypeError("'macros' (if supplied) must be a list of tuples")
389390

390391
if include_dirs is None:
391-
include_dirs = self.include_dirs
392+
include_dirs = list(self.include_dirs)
392393
elif isinstance(include_dirs, (list, tuple)):
393394
include_dirs = list(include_dirs) + (self.include_dirs or [])
394395
else:
@@ -824,9 +825,19 @@ def has_function( # noqa: C901
824825
libraries=None,
825826
library_dirs=None,
826827
):
827-
"""Return a boolean indicating whether funcname is supported on
828-
the current platform. The optional arguments can be used to
829-
augment the compilation environment.
828+
"""Return a boolean indicating whether funcname is provided as
829+
a symbol on the current platform. The optional arguments can
830+
be used to augment the compilation environment.
831+
832+
The libraries argument is a list of flags to be passed to the
833+
linker to make additional symbol definitions available for
834+
linking.
835+
836+
The includes and include_dirs arguments are deprecated.
837+
Usually, supplying include files with function declarations
838+
will cause function detection to fail even in cases where the
839+
symbol is available for linking.
840+
830841
"""
831842
# this can't be included at module scope because it tries to
832843
# import math which might not be available at that point - maybe
@@ -835,8 +846,12 @@ def has_function( # noqa: C901
835846

836847
if includes is None:
837848
includes = []
849+
else:
850+
warnings.warn("includes is deprecated", DeprecationWarning)
838851
if include_dirs is None:
839852
include_dirs = []
853+
else:
854+
warnings.warn("include_dirs is deprecated", DeprecationWarning)
840855
if libraries is None:
841856
libraries = []
842857
if library_dirs is None:
@@ -845,7 +860,24 @@ def has_function( # noqa: C901
845860
f = os.fdopen(fd, "w")
846861
try:
847862
for incl in includes:
848-
f.write("""#include "%s"\n""" % incl)
863+
f.write("""#include %s\n""" % incl)
864+
if not includes:
865+
# Use "char func(void);" as the prototype to follow
866+
# what autoconf does. This prototype does not match
867+
# any well-known function the compiler might recognize
868+
# as a builtin, so this ends up as a true link test.
869+
# Without a fake prototype, the test would need to
870+
# know the exact argument types, and the has_function
871+
# interface does not provide that level of information.
872+
f.write(
873+
"""\
874+
#ifdef __cplusplus
875+
extern "C"
876+
#endif
877+
char %s(void);
878+
"""
879+
% funcname
880+
)
849881
f.write(
850882
"""\
851883
int main (int argc, char **argv) {
@@ -871,7 +903,9 @@ def has_function( # noqa: C901
871903
except (LinkError, TypeError):
872904
return False
873905
else:
874-
os.remove(os.path.join(self.output_dir or '', "a.out"))
906+
os.remove(
907+
self.executable_filename("a.out", output_dir=self.output_dir or '')
908+
)
875909
finally:
876910
for fn in objects:
877911
os.remove(fn)

setuptools/_distutils/cmd.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def dump_options(self, header=None, indent=""):
160160
header = "command options for '%s':" % self.get_command_name()
161161
self.announce(indent + header, level=logging.INFO)
162162
indent = indent + " "
163-
for (option, _, _) in self.user_options:
163+
for option, _, _ in self.user_options:
164164
option = option.translate(longopt_xlate)
165165
if option[-1] == "=":
166166
option = option[:-1]
@@ -291,7 +291,7 @@ def set_undefined_options(self, src_cmd, *option_pairs):
291291
# Option_pairs: list of (src_option, dst_option) tuples
292292
src_cmd_obj = self.distribution.get_command_obj(src_cmd)
293293
src_cmd_obj.ensure_finalized()
294-
for (src_option, dst_option) in option_pairs:
294+
for src_option, dst_option in option_pairs:
295295
if getattr(self, dst_option) is None:
296296
setattr(self, dst_option, getattr(src_cmd_obj, src_option))
297297

@@ -325,7 +325,7 @@ def get_sub_commands(self):
325325
run for the current distribution. Return a list of command names.
326326
"""
327327
commands = []
328-
for (cmd_name, method) in self.sub_commands:
328+
for cmd_name, method in self.sub_commands:
329329
if method is None or method(self):
330330
commands.append(cmd_name)
331331
return commands

setuptools/_distutils/command/bdist.py

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def append(self, item):
3333

3434

3535
class bdist(Command):
36-
3736
description = "create a built (binary) distribution"
3837

3938
user_options = [

setuptools/_distutils/command/bdist_dumb.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
class bdist_dumb(Command):
17-
1817
description = "create a \"dumb\" built distribution"
1918

2019
user_options = [

setuptools/_distutils/command/bdist_rpm.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
class bdist_rpm(Command):
24-
2524
description = "create an RPM distribution"
2625

2726
user_options = [
@@ -554,7 +553,7 @@ def _make_spec_file(self): # noqa: C901
554553
('postun', 'post_uninstall', None),
555554
]
556555

557-
for (rpm_opt, attr, default) in script_options:
556+
for rpm_opt, attr, default in script_options:
558557
# Insert contents of file referred to, if no file is referred to
559558
# use 'default' as contents of script
560559
val = getattr(self, attr)

setuptools/_distutils/command/build.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def show_compilers():
1616

1717

1818
class build(Command):
19-
2019
description = "build everything needed to install"
2120

2221
user_options = [

setuptools/_distutils/command/build_clib.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def show_compilers():
2828

2929

3030
class build_clib(Command):
31-
3231
description = "build C/C++ libraries used by Python extensions"
3332

3433
user_options = [
@@ -103,7 +102,7 @@ def run(self):
103102
self.compiler.set_include_dirs(self.include_dirs)
104103
if self.define is not None:
105104
# 'define' option is a list of (name,value) tuples
106-
for (name, value) in self.define:
105+
for name, value in self.define:
107106
self.compiler.define_macro(name, value)
108107
if self.undef is not None:
109108
for macro in self.undef:
@@ -155,14 +154,14 @@ def get_library_names(self):
155154
return None
156155

157156
lib_names = []
158-
for (lib_name, build_info) in self.libraries:
157+
for lib_name, build_info in self.libraries:
159158
lib_names.append(lib_name)
160159
return lib_names
161160

162161
def get_source_files(self):
163162
self.check_library_list(self.libraries)
164163
filenames = []
165-
for (lib_name, build_info) in self.libraries:
164+
for lib_name, build_info in self.libraries:
166165
sources = build_info.get('sources')
167166
if sources is None or not isinstance(sources, (list, tuple)):
168167
raise DistutilsSetupError(
@@ -175,7 +174,7 @@ def get_source_files(self):
175174
return filenames
176175

177176
def build_libraries(self, libraries):
178-
for (lib_name, build_info) in libraries:
177+
for lib_name, build_info in libraries:
179178
sources = build_info.get('sources')
180179
if sources is None or not isinstance(sources, (list, tuple)):
181180
raise DistutilsSetupError(

setuptools/_distutils/command/build_ext.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def show_compilers():
3939

4040

4141
class build_ext(Command):
42-
4342
description = "build C/C++ extensions (compile/link to build directory)"
4443

4544
# XXX thoughts on how to deal with complex command-line options like
@@ -328,7 +327,7 @@ def run(self): # noqa: C901
328327
self.compiler.set_include_dirs(self.include_dirs)
329328
if self.define is not None:
330329
# 'define' option is a list of (name,value) tuples
331-
for (name, value) in self.define:
330+
for name, value in self.define:
332331
self.compiler.define_macro(name, value)
333332
if self.undef is not None:
334333
for macro in self.undef:
@@ -721,7 +720,7 @@ def get_export_symbols(self, ext):
721720
name = ext.name.split('.')[-1]
722721
try:
723722
# Unicode module name support as defined in PEP-489
724-
# https://www.python.org/dev/peps/pep-0489/#export-hook-name
723+
# https://peps.python.org/pep-0489/#export-hook-name
725724
name.encode('ascii')
726725
except UnicodeEncodeError:
727726
suffix = 'U_' + name.encode('punycode').replace(b'-', b'_').decode('ascii')

setuptools/_distutils/command/build_py.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
class build_py(Command):
17-
1817
description = "\"build\" pure Python modules (copy to build directory)"
1918

2019
user_options = [
@@ -310,7 +309,7 @@ def get_module_outfile(self, build_dir, package, module):
310309
def get_outputs(self, include_bytecode=1):
311310
modules = self.find_all_modules()
312311
outputs = []
313-
for (package, module, module_file) in modules:
312+
for package, module, module_file in modules:
314313
package = package.split('.')
315314
filename = self.get_module_outfile(self.build_lib, package, module)
316315
outputs.append(filename)
@@ -352,7 +351,7 @@ def build_module(self, module, module_file, package):
352351

353352
def build_modules(self):
354353
modules = self.find_modules()
355-
for (package, module, module_file) in modules:
354+
for package, module, module_file in modules:
356355
# Now "build" the module -- ie. copy the source file to
357356
# self.build_lib (the build directory for Python source).
358357
# (Actually, it gets copied to the directory for this package
@@ -375,7 +374,7 @@ def build_packages(self):
375374

376375
# Now loop over the modules we found, "building" each one (just
377376
# copy it to self.build_lib).
378-
for (package_, module, module_file) in modules:
377+
for package_, module, module_file in modules:
379378
assert package == package_
380379
self.build_module(module, module_file, package)
381380

setuptools/_distutils/command/build_scripts.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323

2424
class build_scripts(Command):
25-
2625
description = "\"build\" scripts (copy and fixup #! line)"
2726

2827
user_options = [

setuptools/_distutils/command/clean.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212

1313
class clean(Command):
14-
1514
description = "clean up temporary files from 'build' command"
1615
user_options = [
1716
('build-base=', 'b', "base build directory (default: 'build.build-base')"),

setuptools/_distutils/command/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
class config(Command):
24-
2524
description = "prepare to build"
2625

2726
user_options = [

0 commit comments

Comments
 (0)