MCPcopy Index your code
hub / github.com/python/cpython / fixup_build_ext

Function fixup_build_ext

Tools/peg_generator/pegen/build.py:33–69  ·  view source on GitHub ↗

Function needed to make build_ext tests pass. When Python was built with --enable-shared on Unix, -L. is not enough to find libpython .so, because regrtest runs in a tempdir, not in the source directory where the .so lives. When Python was built with in debug mode on Windows,

(cmd: Incomplete)

Source from the content-addressed store, hash-verified

31
32
33def fixup_build_ext(cmd: Incomplete) -> None:
34 """Function needed to make build_ext tests pass.
35
36 When Python was built with --enable-shared on Unix, -L. is not enough to
37 find libpython<blah>.so, because regrtest runs in a tempdir, not in the
38 source directory where the .so lives.
39
40 When Python was built with in debug mode on Windows, build_ext commands
41 need their debug attribute set, and it is not done automatically for
42 some reason.
43
44 This function handles both of these things. Example use:
45
46 cmd = build_ext(dist)
47 support.fixup_build_ext(cmd)
48 cmd.ensure_finalized()
49
50 Unlike most other Unix platforms, Mac OS X embeds absolute paths
51 to shared libraries into executables, so the fixup is not needed there.
52
53 Taken from distutils (was part of the CPython stdlib until Python 3.11)
54 """
55 if os.name == "nt":
56 cmd.debug = sys.executable.endswith("_d.exe")
57 elif sysconfig.get_config_var("Py_ENABLE_SHARED"):
58 # To further add to the shared builds fun on Unix, we can't just add
59 # library_dirs to the Extension() instance because that doesn't get
60 # plumbed through to the final compiler command.
61 runshared = sysconfig.get_config_var("RUNSHARED")
62 if runshared is None:
63 cmd.library_dirs = ["."]
64 else:
65 if sys.platform == "darwin":
66 cmd.library_dirs = []
67 else:
68 name, equals, value = runshared.partition("=")
69 cmd.library_dirs = [d for d in value.split(os.pathsep) if d]
70
71
72def compile_c_extension(

Callers 1

compile_c_extensionFunction · 0.85

Calls 3

endswithMethod · 0.45
partitionMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…