Skip to content

Commit 1495fb0

Browse files
committed
Merge branch 'main' into patch-1
2 parents e524b20 + 4993305 commit 1495fb0

10 files changed

+79
-80
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 65.1.1
2+
current_version = 65.2.0
33
commit = True
44
tag = True
55

CHANGES.rst

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
v65.2.0
2+
-------
3+
4+
5+
Changes
6+
^^^^^^^
7+
* #3553: Sync with pypa/distutils@22b9bcf, including fixed cross-compiling support and removing deprecation warning per pypa/distutils#169.
8+
9+
110
v65.1.1
211
-------
312

changelog.d/3554.doc.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Changed requires to requests in the pyproject.toml example in the :ref:`Dependency management section of the Quickstart guide <userguide/quickstart:dependency-management>` -- by :user:`mfbutner`

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ filterwarnings=
6060
ignore:Setuptools is replacing distutils
6161

6262
# suppress warnings in deprecated msvc compilers
63-
ignore:msvc9?compiler is deprecated
63+
ignore:(bcpp|msvc9?)compiler is deprecated
6464

6565
ignore:Support for .* in .pyproject.toml. is still .beta.
6666
ignore::setuptools.command.editable_wheel.InformationOnly

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = setuptools
3-
version = 65.1.1
3+
version = 65.2.0
44
author = Python Packaging Authority
55
author_email = [email protected]
66
description = Easily download, build, install, upgrade, and uninstall Python packages

setuptools/_distutils/_msvccompiler.py

+4-26
Original file line numberDiff line numberDiff line change
@@ -318,38 +318,16 @@ def initialize(self, plat_name=None):
318318

319319
# -- Worker methods ------------------------------------------------
320320

321-
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
322-
ext_map = {
323-
**{ext: self.obj_extension for ext in self.src_extensions},
321+
@property
322+
def out_extensions(self):
323+
return {
324+
**super().out_extensions,
324325
**{
325326
ext: self.res_extension
326327
for ext in self._rc_extensions + self._mc_extensions
327328
},
328329
}
329330

330-
output_dir = output_dir or ''
331-
332-
def make_out_path(p):
333-
base, ext = os.path.splitext(p)
334-
if strip_dir:
335-
base = os.path.basename(base)
336-
else:
337-
_, base = os.path.splitdrive(base)
338-
if base.startswith((os.path.sep, os.path.altsep)):
339-
base = base[1:]
340-
try:
341-
# XXX: This may produce absurdly long paths. We should check
342-
# the length of the result and trim base until we fit within
343-
# 260 characters.
344-
return os.path.join(output_dir, base + ext_map[ext])
345-
except LookupError:
346-
# Better to raise an exception instead of silently continuing
347-
# and later complain about sources and targets having
348-
# different lengths
349-
raise CompileError(f"Don't know how to compile {p}")
350-
351-
return list(map(make_out_path, source_filenames))
352-
353331
def compile( # noqa: C901
354332
self,
355333
sources,

setuptools/_distutils/bcppcompiler.py

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414

1515
import os
16+
import warnings
17+
1618
from distutils.errors import (
1719
DistutilsExecError,
1820
CompileError,
@@ -26,6 +28,14 @@
2628
from distutils import log
2729

2830

31+
warnings.warn(
32+
"bcppcompiler is deprecated and slated to be removed "
33+
"in the future. Please discontinue use or file an issue "
34+
"with pypa/distutils describing your use case.",
35+
DeprecationWarning,
36+
)
37+
38+
2939
class BCPPCompiler(CCompiler):
3040
"""Concrete class that implements an interface to the Borland C/C++
3141
compiler, as defined by the CCompiler abstract class.

setuptools/_distutils/ccompiler.py

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

1110
from distutils.errors import (
1211
CompileError,
@@ -924,37 +923,39 @@ def find_library_file(self, dirs, lib, debug=0):
924923
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
925924
if output_dir is None:
926925
output_dir = ''
927-
obj_names = []
928-
for src_name in source_filenames:
929-
base, ext = os.path.splitext(src_name)
930-
base = self._mangle_base(base)
931-
if ext not in self.src_extensions:
932-
raise UnknownFileError(
933-
"unknown file type '{}' (from '{}')".format(ext, src_name)
934-
)
935-
if strip_dir:
936-
base = os.path.basename(base)
937-
obj_names.append(os.path.join(output_dir, base + self.obj_extension))
938-
return obj_names
926+
return list(
927+
self._make_out_path(output_dir, strip_dir, src_name)
928+
for src_name in source_filenames
929+
)
930+
931+
@property
932+
def out_extensions(self):
933+
return dict.fromkeys(self.src_extensions, self.obj_extension)
934+
935+
def _make_out_path(self, output_dir, strip_dir, src_name):
936+
base, ext = os.path.splitext(src_name)
937+
base = self._make_relative(base)
938+
try:
939+
new_ext = self.out_extensions[ext]
940+
except LookupError:
941+
raise UnknownFileError(
942+
"unknown file type '{}' (from '{}')".format(ext, src_name)
943+
)
944+
if strip_dir:
945+
base = os.path.basename(base)
946+
return os.path.join(output_dir, base + new_ext)
939947

940948
@staticmethod
941-
def _mangle_base(base):
949+
def _make_relative(base):
942950
"""
943-
For unknown reasons, absolute paths are mangled.
951+
In order to ensure that a filename always honors the
952+
indicated output_dir, make sure it's relative.
953+
Ref python/cpython#37775.
944954
"""
945955
# Chop off the drive
946956
no_drive = os.path.splitdrive(base)[1]
947957
# If abs, chop off leading /
948-
rel = no_drive[os.path.isabs(no_drive) :]
949-
if rel != base:
950-
msg = (
951-
f"Absolute path {base!r} is being replaced with a "
952-
f"relative path {rel!r} for outputs. This behavior is "
953-
"deprecated. If this behavior is desired, please "
954-
"comment in pypa/distutils#169."
955-
)
956-
warnings.warn(msg, DeprecationWarning)
957-
return rel
958+
return no_drive[os.path.isabs(no_drive) :]
958959

959960
def shared_object_filename(self, basename, strip_dir=0, output_dir=''):
960961
assert output_dir is not None

setuptools/_distutils/cygwinccompiler.py

+14-23
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
DistutilsPlatformError,
2121
CCompilerError,
2222
CompileError,
23-
UnknownFileError,
2423
)
2524
from distutils.version import LooseVersion, suppress_known_deprecation
2625

@@ -242,28 +241,20 @@ def runtime_library_dir_option(self, dir):
242241

243242
# -- Miscellaneous methods -----------------------------------------
244243

245-
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
246-
"""Adds supports for rc and res files."""
247-
if output_dir is None:
248-
output_dir = ''
249-
obj_names = []
250-
for src_name in source_filenames:
251-
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
252-
base, ext = os.path.splitext(os.path.normcase(src_name))
253-
if ext not in (self.src_extensions + ['.rc', '.res']):
254-
raise UnknownFileError(
255-
"unknown file type '{}' (from '{}')".format(ext, src_name)
256-
)
257-
if strip_dir:
258-
base = os.path.basename(base)
259-
if ext in ('.res', '.rc'):
260-
# these need to be compiled to object files
261-
obj_names.append(
262-
os.path.join(output_dir, base + ext + self.obj_extension)
263-
)
264-
else:
265-
obj_names.append(os.path.join(output_dir, base + self.obj_extension))
266-
return obj_names
244+
def _make_out_path(self, output_dir, strip_dir, src_name):
245+
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
246+
norm_src_name = os.path.normcase(src_name)
247+
return super()._make_out_path(output_dir, strip_dir, norm_src_name)
248+
249+
@property
250+
def out_extensions(self):
251+
"""
252+
Add support for rc and res files.
253+
"""
254+
return {
255+
**super().out_extensions,
256+
**{ext: ext + self.obj_extension for ext in ('.res', '.rc')},
257+
}
267258

268259

269260
# the same as cygwin plus some additional parameters

setuptools/_distutils/sysconfig.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,19 @@ def _get_python_inc_from_config(plat_specific, spec_prefix):
164164
the host
165165
platform Python installation, while the current Python
166166
executable is from the build platform installation.
167+
168+
>>> monkeypatch = getfixture('monkeypatch')
169+
>>> gpifc = _get_python_inc_from_config
170+
>>> monkeypatch.setitem(gpifc.__globals__, 'get_config_var', str.lower)
171+
>>> gpifc(False, '/usr/bin/')
172+
>>> gpifc(False, '')
173+
>>> gpifc(False, None)
174+
'includepy'
175+
>>> gpifc(True, None)
176+
'confincludepy'
167177
"""
168-
if not spec_prefix:
169-
return
170-
return get_config_var('CONF' * plat_specific + 'INCLUDEPY')
178+
if spec_prefix is None:
179+
return get_config_var('CONF' * plat_specific + 'INCLUDEPY')
171180

172181

173182
def _get_python_inc_posix_prefix(prefix):

0 commit comments

Comments
 (0)