| OLD | NEW |
| 1 """Support code for distutils test cases.""" | 1 """Support code for distutils test cases.""" |
| 2 import os | 2 import os |
| 3 import sys | 3 import sys |
| 4 import shutil | 4 import shutil |
| 5 import tempfile | 5 import tempfile |
| 6 import unittest | 6 import unittest |
| 7 import sysconfig | 7 import sysconfig |
| 8 from copy import deepcopy | 8 from copy import deepcopy |
| 9 | 9 |
| 10 from distutils import log | 10 from distutils import log |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 # this file is run from its parent directory, so walk up the | 162 # this file is run from its parent directory, so walk up the |
| 163 # tree to find the real srcdir | 163 # tree to find the real srcdir |
| 164 os.path.join(srcdir, '..', '..', '..', 'Modules', 'xxmodule.c'), | 164 os.path.join(srcdir, '..', '..', '..', 'Modules', 'xxmodule.c'), |
| 165 ] | 165 ] |
| 166 for path in candidates: | 166 for path in candidates: |
| 167 if os.path.exists(path): | 167 if os.path.exists(path): |
| 168 return path | 168 return path |
| 169 | 169 |
| 170 | 170 |
| 171 def fixup_build_ext(cmd): | 171 def fixup_build_ext(cmd): |
| 172 """Function needed to make build_ext tests pass on shared builds. | 172 """Function needed to make build_ext tests pass. |
| 173 | 173 |
| 174 When Python was build with --enable-shared, -L. is not good enough to find | 174 When Python was build with --enable-shared on Unix, -L. is not good |
| 175 the libpython<blah>.so. This is because regrtest runs it under a tempdir, | 175 enough to find the libpython<blah>.so. This is because regrtest runs |
| 176 not in the top level where the .so lives. By the time we've gotten here, | 176 it under a tempdir, not in the top level where the .so lives. By the |
| 177 Python's already been chdir'd to the tempdir. This function work arounds | 177 time we've gotten here, Python's already been chdir'd to the tempdir. |
| 178 that. Example use: | 178 |
| 179 When Python was built with in debug mode on Windows, build_ext commands |
| 180 need their debug attribute set, and it is not done automatically for |
| 181 some reason. |
| 182 |
| 183 This function handles both of these things. Example use: |
| 179 | 184 |
| 180 cmd = build_ext(dist) | 185 cmd = build_ext(dist) |
| 181 support.fixup_build_ext(cmd) | 186 support.fixup_build_ext(cmd) |
| 182 cmd.ensure_finalized() | 187 cmd.ensure_finalized() |
| 183 """ | 188 """ |
| 184 # To further add to the fun, we can't just add library_dirs to the | 189 if os.name == "nt": |
| 185 # Extension() instance because that doesn't get plumbed through to the | 190 cmd.debug = sys.executable.endswith("_d.exe") |
| 186 # final compiler command. | 191 elif sysconfig.get_config_var('Py_ENABLE_SHARED'): |
| 187 if (sysconfig.get_config_var('Py_ENABLE_SHARED') and | 192 # To further add to the shared builds fun on Unix, we can't just add |
| 188 not sys.platform.startswith('win')): | 193 # library_dirs to the Extension() instance because that doesn't get |
| 194 # plumbed through to the final compiler command. |
| 189 runshared = sysconfig.get_config_var('RUNSHARED') | 195 runshared = sysconfig.get_config_var('RUNSHARED') |
| 190 if runshared is None: | 196 if runshared is None: |
| 191 cmd.library_dirs = ['.'] | 197 cmd.library_dirs = ['.'] |
| 192 else: | 198 else: |
| 193 name, equals, value = runshared.partition('=') | 199 name, equals, value = runshared.partition('=') |
| 194 cmd.library_dirs = value.split(os.pathsep) | 200 cmd.library_dirs = value.split(os.pathsep) |
| OLD | NEW |