Skip to content

Commit

Permalink
Try wheel cli
Browse files Browse the repository at this point in the history
Try using pypa/wheel#422
  • Loading branch information
mayeut committed Nov 21, 2021
1 parent 450d8bb commit 688d1d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion requirements-repair.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
git+https:/jcfr/wheeltools.git@wheeltools-2018-10-28-a2f174d0e
git+https:/henryiii/wheel.git@deb2a78012b41bb3a9ebdef9e139261d62ce6be5
23 changes: 13 additions & 10 deletions scripts/repair_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import zipfile
from pathlib import Path

from convert_to_generic_platform_wheel import convert_to_generic_platform_wheel


def main():
if sys.platform.startswith("linux"):
Expand Down Expand Up @@ -56,8 +54,8 @@ def main():
assert len(files) == 1, files
file = files[0]

# we need to handle macOS x86_64 & arm64 here for now, let's use additional_platforms for this.
additional_platforms = []
# we need to handle macOS x86_64 & arm64 here for now, let's use platform_tag_args for this.
platform_tag_args = []
if os_ == "macos":
# delocate-wheel --require-archs does not seem to check executables...
with tempfile.TemporaryDirectory() as tmpdir2_:
Expand All @@ -67,7 +65,7 @@ def main():
exe = list(tmpdir2.glob("**/bin/ninja"))
assert len(exe) == 1, exe
subprocess.run(["lipo", str(exe[0]), "-verify_arch", "x86_64", "arm64"], check=True, stdout=subprocess.PIPE)

additional_platforms = []
# first, get the target macOS deployment target from the wheel
match = re.match(r"^.*-macosx_(\d+)_(\d+)_.*\.whl$", file.name)
assert match is not None, f"Couldn't match on {file.name}"
Expand All @@ -88,13 +86,18 @@ def main():
# They're were also issues with pip not picking up some universal2 wheels, tag twice
additional_platforms.append("macosx_11_0_universal2")

platform_tag_args = ["--platform-tag", f".{'.'.join(additional_platforms)}"]

# make this a py2.py3 wheel
convert_to_generic_platform_wheel(
str(file),
out_dir=str(wheelhouse),
py2_py3=True,
additional_platforms=additional_platforms,
subprocess.run(
["wheel", "tags", "--python-tag", "py2.py3", "--abi-tag", "none", *platform_tag_args, "--remove", str(file)],
check=True,
stdout=subprocess.PIPE,
)
files = list(tmpdir.glob("*.whl"))
assert len(files) == 1, files
file = files[0]
file.rename(wheelhouse / file.name)


if __name__ == "__main__":
Expand Down

0 comments on commit 688d1d7

Please sign in to comment.