Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge with distutils@8c3c3d29 #3809

Merged
merged 35 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4330386
Add `tests/test*.py` to source distributions
DimitriPapadopoulos Nov 20, 2022
56a5b33
distutils.ccompiler: Make has_function work with more C99 compilers
fweimer-rh Dec 14, 2022
3e804f4
Fix MinGW-w64 segmentation fault
GalaxySnail Dec 24, 2022
459f144
Apply refurb suggestions
DimitriPapadopoulos Nov 20, 2022
f7ff2d0
Apply refurb suggestions
DimitriPapadopoulos Nov 20, 2022
b289d74
Apply refurb suggestions
DimitriPapadopoulos Nov 20, 2022
32e9b27
Apply refurb suggestions
DimitriPapadopoulos Nov 20, 2022
1713e72
Apply refurb suggestions
DimitriPapadopoulos Nov 20, 2022
fa93529
Update outdated GitHub Actions
DimitriPapadopoulos Nov 20, 2022
69a832f
Link directly to PEPs
hugovk Jan 16, 2023
f448b95
Add xfail test capturing missed expectation. Ref pypa/distutils#178.
jaraco Feb 6, 2023
ff9b6d1
In _get_python_inc_posix, only return an extant path from the sysconf…
jaraco Feb 6, 2023
5f1d979
Merge failing test commit 'f448b' into bugfix/178-include-posix-prefix
jaraco Feb 6, 2023
2fe57ea
Merge pull request #198 from hugovk/pep-redirect
jaraco Feb 6, 2023
b504971
Merge pull request #191 from DimitriPapadopoulos/refurb
jaraco Feb 6, 2023
ca3195b
Merge pull request #190 from DimitriPapadopoulos/actions
jaraco Feb 6, 2023
67bb76c
⚫ Fade to black.
jaraco Feb 6, 2023
fb2a173
Merge pull request #200 from pypa/bugfix/178-include-posix-prefix
jaraco Feb 6, 2023
e32c71f
Fix typos found by codespell
DimitriPapadopoulos Nov 20, 2022
0171aee
Merge pull request #197 from GalaxySnail/fix-mingw-w64
jaraco Feb 6, 2023
a83ea62
Merge pull request #188 from DimitriPapadopoulos/codespell
jaraco Feb 6, 2023
3944f4e
Merge pull request #189 from DimitriPapadopoulos/tests
jaraco Feb 6, 2023
8bf0435
Merge pull request #195 from fweimer-rh/c99
jaraco Feb 6, 2023
53f297d
add a pypy CI run
mattip Feb 6, 2023
c2bc813
Revert "Merge pull request #197 from GalaxySnail/fix-mingw-w64"
jaraco Feb 6, 2023
e2264e5
Fix MinGW-w64 segmentation fault
GalaxySnail Feb 6, 2023
6324549
Fixed accumulating include dirs after compile
mrbean-bremen Jan 18, 2023
2f16327
Mark test as xfail on Windows. Ref pypa/distutils#195.
jaraco Feb 6, 2023
7e751d3
distutils.ccompiler: Remove correct executable file on Windows
fweimer-rh Feb 6, 2023
8fe7b5f
Merge pull request #202 from GalaxySnail/fix-mingw-w64-2
jaraco Feb 6, 2023
854862f
Merge pull request #203 from fweimer-rh/ccompiler-windows
jaraco Feb 6, 2023
1efd3d5
Merge pull request #201 from mattip/pypy2
jaraco Feb 6, 2023
8c3c3d2
Merge pull request #199 from mrbean-bremen/issue3591
jaraco Feb 6, 2023
43c6ee4
Merge https://github.com/pypa/distutils into distutils-8c3c3d29
jaraco Feb 6, 2023
47c7cfd
Add changelog (draft)
jaraco Feb 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3809.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Merge with distutils@8c3c3d29, including fix for ``sysconfig.get_python_inc()`` (pypa/distutils#178), fix for segfault on MinGW (pypa/distutils#196), and better ``has_function`` support (pypa/distutils#195).
2 changes: 1 addition & 1 deletion setuptools/_distutils/_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def bounds(self):
return (sorted_keys[RangeMap.first_item], sorted_keys[RangeMap.last_item])

# some special values for the RangeMap
undefined_value = type(str('RangeValueUndefined'), (), {})()
undefined_value = type('RangeValueUndefined', (), {})()

class Item(int):
"RangeMap Item"
Expand Down
6 changes: 1 addition & 5 deletions setuptools/_distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ def compile( # noqa: C901
extra_postargs=None,
depends=None,
):

if not self.initialized:
self.initialize()
compile_info = self._setup_compile(
Expand Down Expand Up @@ -413,8 +412,7 @@ def compile( # noqa: C901
args = [self.cc] + compile_opts + pp_opts
if add_cpp_opts:
args.append('/EHsc')
args.append(input_opt)
args.append("/Fo" + obj)
args.extend((input_opt, "/Fo" + obj))
args.extend(extra_postargs)

try:
Expand All @@ -427,7 +425,6 @@ def compile( # noqa: C901
def create_static_lib(
self, objects, output_libname, output_dir=None, debug=0, target_lang=None
):

if not self.initialized:
self.initialize()
objects, output_dir = self._fix_object_args(objects, output_dir)
Expand Down Expand Up @@ -461,7 +458,6 @@ def link(
build_temp=None,
target_lang=None,
):

if not self.initialized:
self.initialize()
objects, output_dir = self._fix_object_args(objects, output_dir)
Expand Down
9 changes: 1 addition & 8 deletions setuptools/_distutils/bcppcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class BCPPCompiler(CCompiler):
exe_extension = '.exe'

def __init__(self, verbose=0, dry_run=0, force=0):

super().__init__(verbose, dry_run, force)

# These executables are assumed to all be in the path.
Expand Down Expand Up @@ -98,7 +97,6 @@ def compile( # noqa: C901
extra_postargs=None,
depends=None,
):

macros, objects, extra_postargs, pp_opts, build = self._setup_compile(
output_dir, macros, include_dirs, sources, depends, extra_postargs
)
Expand Down Expand Up @@ -167,7 +165,6 @@ def compile( # noqa: C901
def create_static_lib(
self, objects, output_libname, output_dir=None, debug=0, target_lang=None
):

(objects, output_dir) = self._fix_object_args(objects, output_dir)
output_filename = self.library_filename(output_libname, output_dir=output_dir)

Expand Down Expand Up @@ -200,7 +197,6 @@ def link( # noqa: C901
build_temp=None,
target_lang=None,
):

# XXX this ignores 'build_temp'! should follow the lead of
# msvccompiler.py

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

if self._need_link(objects, output_filename):

# Figure out linker args based on type of target.
if target_desc == CCompiler.EXECUTABLE:
startup_obj = 'c0w32'
Expand Down Expand Up @@ -294,8 +289,7 @@ def link( # noqa: C901
ld_args.append(libfile)

# some default libraries
ld_args.append('import32')
ld_args.append('cw32mt')
ld_args.extend(('import32', 'cw32mt'))

# def file for export symbols
ld_args.extend([',', def_file])
Expand Down Expand Up @@ -381,7 +375,6 @@ def preprocess(
extra_preargs=None,
extra_postargs=None,
):

(_, macros, include_dirs) = self._fix_compile_args(None, macros, include_dirs)
pp_opts = gen_preprocess_options(macros, include_dirs)
pp_args = ['cpp32.exe'] + pp_opts
Expand Down
46 changes: 40 additions & 6 deletions setuptools/_distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import os
import re
import warnings

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

if include_dirs is None:
include_dirs = self.include_dirs
include_dirs = list(self.include_dirs)
elif isinstance(include_dirs, (list, tuple)):
include_dirs = list(include_dirs) + (self.include_dirs or [])
else:
Expand Down Expand Up @@ -824,9 +825,19 @@ def has_function( # noqa: C901
libraries=None,
library_dirs=None,
):
"""Return a boolean indicating whether funcname is supported on
the current platform. The optional arguments can be used to
augment the compilation environment.
"""Return a boolean indicating whether funcname is provided as
a symbol on the current platform. The optional arguments can
be used to augment the compilation environment.

The libraries argument is a list of flags to be passed to the
linker to make additional symbol definitions available for
linking.

The includes and include_dirs arguments are deprecated.
Usually, supplying include files with function declarations
will cause function detection to fail even in cases where the
symbol is available for linking.

"""
# this can't be included at module scope because it tries to
# import math which might not be available at that point - maybe
Expand All @@ -835,8 +846,12 @@ def has_function( # noqa: C901

if includes is None:
includes = []
else:
warnings.warn("includes is deprecated", DeprecationWarning)
if include_dirs is None:
include_dirs = []
else:
warnings.warn("include_dirs is deprecated", DeprecationWarning)
if libraries is None:
libraries = []
if library_dirs is None:
Expand All @@ -845,7 +860,24 @@ def has_function( # noqa: C901
f = os.fdopen(fd, "w")
try:
for incl in includes:
f.write("""#include "%s"\n""" % incl)
f.write("""#include %s\n""" % incl)
if not includes:
# Use "char func(void);" as the prototype to follow
# what autoconf does. This prototype does not match
# any well-known function the compiler might recognize
# as a builtin, so this ends up as a true link test.
# Without a fake prototype, the test would need to
# know the exact argument types, and the has_function
# interface does not provide that level of information.
f.write(
"""\
#ifdef __cplusplus
extern "C"
#endif
char %s(void);
"""
% funcname
)
f.write(
"""\
int main (int argc, char **argv) {
Expand All @@ -871,7 +903,9 @@ def has_function( # noqa: C901
except (LinkError, TypeError):
return False
else:
os.remove(os.path.join(self.output_dir or '', "a.out"))
os.remove(
self.executable_filename("a.out", output_dir=self.output_dir or '')
)
finally:
for fn in objects:
os.remove(fn)
Expand Down
6 changes: 3 additions & 3 deletions setuptools/_distutils/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def dump_options(self, header=None, indent=""):
header = "command options for '%s':" % self.get_command_name()
self.announce(indent + header, level=logging.INFO)
indent = indent + " "
for (option, _, _) in self.user_options:
for option, _, _ in self.user_options:
option = option.translate(longopt_xlate)
if option[-1] == "=":
option = option[:-1]
Expand Down Expand Up @@ -291,7 +291,7 @@ def set_undefined_options(self, src_cmd, *option_pairs):
# Option_pairs: list of (src_option, dst_option) tuples
src_cmd_obj = self.distribution.get_command_obj(src_cmd)
src_cmd_obj.ensure_finalized()
for (src_option, dst_option) in option_pairs:
for src_option, dst_option in option_pairs:
if getattr(self, dst_option) is None:
setattr(self, dst_option, getattr(src_cmd_obj, src_option))

Expand Down Expand Up @@ -325,7 +325,7 @@ def get_sub_commands(self):
run for the current distribution. Return a list of command names.
"""
commands = []
for (cmd_name, method) in self.sub_commands:
for cmd_name, method in self.sub_commands:
if method is None or method(self):
commands.append(cmd_name)
return commands
Expand Down
1 change: 0 additions & 1 deletion setuptools/_distutils/command/bdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def append(self, item):


class bdist(Command):

description = "create a built (binary) distribution"

user_options = [
Expand Down
1 change: 0 additions & 1 deletion setuptools/_distutils/command/bdist_dumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class bdist_dumb(Command):

description = "create a \"dumb\" built distribution"

user_options = [
Expand Down
3 changes: 1 addition & 2 deletions setuptools/_distutils/command/bdist_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class bdist_rpm(Command):

description = "create an RPM distribution"

user_options = [
Expand Down Expand Up @@ -554,7 +553,7 @@ def _make_spec_file(self): # noqa: C901
('postun', 'post_uninstall', None),
]

for (rpm_opt, attr, default) in script_options:
for rpm_opt, attr, default in script_options:
# Insert contents of file referred to, if no file is referred to
# use 'default' as contents of script
val = getattr(self, attr)
Expand Down
1 change: 0 additions & 1 deletion setuptools/_distutils/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def show_compilers():


class build(Command):

description = "build everything needed to install"

user_options = [
Expand Down
9 changes: 4 additions & 5 deletions setuptools/_distutils/command/build_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def show_compilers():


class build_clib(Command):

description = "build C/C++ libraries used by Python extensions"

user_options = [
Expand Down Expand Up @@ -103,7 +102,7 @@ def run(self):
self.compiler.set_include_dirs(self.include_dirs)
if self.define is not None:
# 'define' option is a list of (name,value) tuples
for (name, value) in self.define:
for name, value in self.define:
self.compiler.define_macro(name, value)
if self.undef is not None:
for macro in self.undef:
Expand Down Expand Up @@ -155,14 +154,14 @@ def get_library_names(self):
return None

lib_names = []
for (lib_name, build_info) in self.libraries:
for lib_name, build_info in self.libraries:
lib_names.append(lib_name)
return lib_names

def get_source_files(self):
self.check_library_list(self.libraries)
filenames = []
for (lib_name, build_info) in self.libraries:
for lib_name, build_info in self.libraries:
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
raise DistutilsSetupError(
Expand All @@ -175,7 +174,7 @@ def get_source_files(self):
return filenames

def build_libraries(self, libraries):
for (lib_name, build_info) in libraries:
for lib_name, build_info in libraries:
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
raise DistutilsSetupError(
Expand Down
5 changes: 2 additions & 3 deletions setuptools/_distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def show_compilers():


class build_ext(Command):

description = "build C/C++ extensions (compile/link to build directory)"

# XXX thoughts on how to deal with complex command-line options like
Expand Down Expand Up @@ -328,7 +327,7 @@ def run(self): # noqa: C901
self.compiler.set_include_dirs(self.include_dirs)
if self.define is not None:
# 'define' option is a list of (name,value) tuples
for (name, value) in self.define:
for name, value in self.define:
self.compiler.define_macro(name, value)
if self.undef is not None:
for macro in self.undef:
Expand Down Expand Up @@ -721,7 +720,7 @@ def get_export_symbols(self, ext):
name = ext.name.split('.')[-1]
try:
# Unicode module name support as defined in PEP-489
# https://www.python.org/dev/peps/pep-0489/#export-hook-name
# https://peps.python.org/pep-0489/#export-hook-name
name.encode('ascii')
except UnicodeEncodeError:
suffix = 'U_' + name.encode('punycode').replace(b'-', b'_').decode('ascii')
Expand Down
7 changes: 3 additions & 4 deletions setuptools/_distutils/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class build_py(Command):

description = "\"build\" pure Python modules (copy to build directory)"

user_options = [
Expand Down Expand Up @@ -310,7 +309,7 @@ def get_module_outfile(self, build_dir, package, module):
def get_outputs(self, include_bytecode=1):
modules = self.find_all_modules()
outputs = []
for (package, module, module_file) in modules:
for package, module, module_file in modules:
package = package.split('.')
filename = self.get_module_outfile(self.build_lib, package, module)
outputs.append(filename)
Expand Down Expand Up @@ -352,7 +351,7 @@ def build_module(self, module, module_file, package):

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

# Now loop over the modules we found, "building" each one (just
# copy it to self.build_lib).
for (package_, module, module_file) in modules:
for package_, module, module_file in modules:
assert package == package_
self.build_module(module, module_file, package)

Expand Down
1 change: 0 additions & 1 deletion setuptools/_distutils/command/build_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


class build_scripts(Command):

description = "\"build\" scripts (copy and fixup #! line)"

user_options = [
Expand Down
1 change: 0 additions & 1 deletion setuptools/_distutils/command/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class clean(Command):

description = "clean up temporary files from 'build' command"
user_options = [
('build-base=', 'b', "base build directory (default: 'build.build-base')"),
Expand Down
1 change: 0 additions & 1 deletion setuptools/_distutils/command/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class config(Command):

description = "prepare to build"

user_options = [
Expand Down
Loading