Skip to content

Commit aeefe34

Browse files
committed
2 parents a36b7ba + 6c0427b commit aeefe34

File tree

13 files changed

+97
-38
lines changed

13 files changed

+97
-38
lines changed

newsfragments/4871.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restored implicit distutils.ccompiler import for g-ir-scanner.

newsfragments/4876.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restore `distutils.ccompiler.compiler_class` -- by :user:`Avasam`
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from .compilers.C import msvc
22

3+
__all__ = ["MSVCCompiler"]
4+
35
MSVCCompiler = msvc.Compiler

setuptools/_distutils/ccompiler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
from .compilers.C import base
22
from .compilers.C.base import (
3-
CompileError,
4-
LinkError,
3+
compiler_class,
54
gen_lib_options,
65
gen_preprocess_options,
76
get_default_compiler,
87
new_compiler,
98
show_compilers,
109
)
10+
from .compilers.C.errors import CompileError, LinkError
1111

1212
__all__ = [
1313
'CompileError',
1414
'LinkError',
15+
'compiler_class',
1516
'gen_lib_options',
1617
'gen_preprocess_options',
1718
'get_default_compiler',

setuptools/_distutils/command/build.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@
1010
from collections.abc import Callable
1111
from typing import ClassVar
1212

13+
from ..ccompiler import show_compilers
1314
from ..core import Command
1415
from ..errors import DistutilsOptionError
1516
from ..util import get_platform
1617

1718

18-
def show_compilers():
19-
from ..ccompiler import show_compilers
20-
21-
show_compilers()
22-
23-
2419
class build(Command):
2520
description = "build everything needed to install"
2621

setuptools/_distutils/command/build_clib.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,12 @@
1919
from distutils._log import log
2020
from typing import ClassVar
2121

22+
from ..ccompiler import new_compiler, show_compilers
2223
from ..core import Command
2324
from ..errors import DistutilsSetupError
2425
from ..sysconfig import customize_compiler
2526

2627

27-
def show_compilers():
28-
from ..ccompiler import show_compilers
29-
30-
show_compilers()
31-
32-
3328
class build_clib(Command):
3429
description = "build C/C++ libraries used by Python extensions"
3530

@@ -93,9 +88,6 @@ def run(self) -> None:
9388
if not self.libraries:
9489
return
9590

96-
# Yech -- this is cut 'n pasted from build_ext.py!
97-
from ..ccompiler import new_compiler
98-
9991
self.compiler = new_compiler(
10092
compiler=self.compiler, dry_run=self.dry_run, force=self.force
10193
)

setuptools/_distutils/command/build_ext.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from typing import ClassVar
1717

1818
from .._modified import newer_group
19+
from ..ccompiler import new_compiler, show_compilers
1920
from ..core import Command
2021
from ..errors import (
2122
CCompilerError,
@@ -34,12 +35,6 @@
3435
extension_name_re = re.compile(r'^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$')
3536

3637

37-
def show_compilers():
38-
from ..ccompiler import show_compilers
39-
40-
show_compilers()
41-
42-
4338
class build_ext(Command):
4439
description = "build C/C++ extensions (compile/link to build directory)"
4540

@@ -303,8 +298,6 @@ def finalize_options(self) -> None: # noqa: C901
303298
raise DistutilsOptionError("parallel should be an integer")
304299

305300
def run(self) -> None: # noqa: C901
306-
from ..ccompiler import new_compiler
307-
308301
# 'self.extensions', as supplied by setup.py, is a list of
309302
# Extension instances. See the documentation for Extension (in
310303
# distutils.extension) for details.

setuptools/_distutils/command/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def _check_rst_data(self, data):
141141
document.note_source(source_path, -1)
142142
try:
143143
parser.parse(data, document)
144-
except AttributeError as e:
144+
except (AttributeError, TypeError) as e:
145145
reporter.messages.append((
146146
-1,
147147
f'Could not finish the parsing: {e}.',

setuptools/_distutils/command/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ def try_run(
258258
built from 'body' and 'headers'. Return true on success, false
259259
otherwise.
260260
"""
261-
from ..ccompiler import CompileError, LinkError
262-
263261
self._check_compiler()
264262
try:
265263
src, obj, exe = self._link(

setuptools/_distutils/compilers/C/unix.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ class Compiler(base.Compiler):
158158
dylib_lib_extension = ".dll"
159159
dylib_lib_format = "cyg%s%s"
160160

161+
def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs):
162+
"""Remove standard library path from rpath"""
163+
libraries, library_dirs, runtime_library_dirs = super()._fix_lib_args(
164+
libraries, library_dirs, runtime_library_dirs
165+
)
166+
libdir = sysconfig.get_config_var('LIBDIR')
167+
if (
168+
runtime_library_dirs
169+
and libdir.startswith("/usr/lib")
170+
and (libdir in runtime_library_dirs)
171+
):
172+
runtime_library_dirs.remove(libdir)
173+
return libraries, library_dirs, runtime_library_dirs
174+
161175
def preprocess(
162176
self,
163177
source: str | os.PathLike[str],

0 commit comments

Comments
 (0)