summaryrefslogtreecommitdiff
path: root/igor.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2022-04-29 14:06:45 +0100
committerNed Batchelder <ned@nedbatchelder.com>2022-04-30 09:06:15 -0400
commitd7a7f8970a7497b12b78577a66e2a0f26944363a (patch)
treefa8c51e838959d9c6aaaea90c00765b9e1c9a5bc /igor.py
parent329403bd7b3637854dd71cf1d46d084644289985 (diff)
downloadpython-coveragepy-git-d7a7f8970a7497b12b78577a66e2a0f26944363a.tar.gz
build: Build and test tweaks to help with cross-compilation
For context, I've been testing whether a range of popular libraries are going to work on Windows ARM64. (This requires compiling on a regular x64 machine and then copying the wheel to an ARM64 one for testing.) The good news is, coverage seems to be just fine without any changes. However, because of a few assumptions in the test suite about always testing an in-place build, I had to make some tweaks to be able to run tests. My proposed tweaks should be fine for current uses, but they also allow the following: * support `SETUPTOOLS_EXT_SUFFIX` when building to override the pyd tag on Windows (used with `setup.py build_ext -L <path>` to point at [pythonarm64](https://www.nuget.org/packages/pythonarm64/) import libraries to do the cross-compile) * allow `COVERAGE_INSTALL_ARGS` to override how the tests install coverage into a venv (allows to point at a wheel rather than rebuilding from the sources) * allow `python igor.py remove_extension --from-install` to delete the extension module from `site-packages` rather than only the source tree * other changes to allow removing the `coverage` directory from the source tree before tests so that the installed copy will be used instead. I've tested these on my own Windows ARM64 machine, though unfortunately there aren't any available on CI services yet. If you wanted to start releasing (preview) wheels for win-arm64 you can, but there's no support (yet) in `cibuildwheel` or `build` to do it (because those tools don't really have a concept of cross-compilation for Windows at all... yet ;-) ). For the linter
Diffstat (limited to 'igor.py')
-rw-r--r--igor.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/igor.py b/igor.py
index e2f063fd..657cb2bc 100644
--- a/igor.py
+++ b/igor.py
@@ -56,7 +56,7 @@ def do_show_env():
print(f" {env} = {os.environ[env]!r}")
-def do_remove_extension():
+def do_remove_extension(*args):
"""Remove the compiled C extension, no matter what its name."""
so_patterns = """
@@ -66,8 +66,22 @@ def do_remove_extension():
tracer.*.pyd
""".split()
+ if "--from-install" in args:
+ # Get the install location using a subprocess to avoid
+ # locking the file we are about to delete
+ root = os.path.dirname(subprocess.check_output([
+ sys.executable,
+ "-Xutf8",
+ "-c",
+ "import coverage; print(coverage.__file__)"
+ ], encoding="utf-8").strip())
+ else:
+ root = "coverage"
+
for pattern in so_patterns:
- pattern = os.path.join("coverage", pattern)
+ pattern = os.path.join(root, pattern.strip())
+ if VERBOSITY:
+ print(f"Searching for {pattern}")
for filename in glob.glob(pattern):
if os.path.exists(filename):
if VERBOSITY: