Skip to content

Commit

Permalink
Try overriding bdist_wheel default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Oct 9, 2021
1 parent 70e37a4 commit fcdc13c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 305 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ before-all = [
"pipx install -f --pip-args=\"-c {project}/constraints-ci.txt\" cmake",
"cmake --version",
]
before-build = "pip install -r requirements-repair.txt"
repair-wheel-command = "python scripts/repair_wheel.py -w {dest_dir} {wheel}"
test-extras = "test"
test-command = "pytest {project}/tests"

Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
-r requirements-test.txt
-r requirements-repair.txt
-r requirements-deploy.txt
scikit-build>=0.10.0
setuptools>=28.0.0
Expand Down
1 change: 0 additions & 1 deletion requirements-repair.txt

This file was deleted.

209 changes: 0 additions & 209 deletions scripts/convert_to_generic_platform_wheel.py

This file was deleted.

91 changes: 0 additions & 91 deletions scripts/repair_wheel.py

This file was deleted.

42 changes: 41 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
# -*- coding: utf-8 -*-

import os
import re
import sys
from distutils.text_file import TextFile

from skbuild import setup
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel_base

# Add current folder to path
# This is required to import versioneer in an isolated pip build
Expand All @@ -29,11 +31,49 @@ def parse_requirements(filename):
test_requirements = parse_requirements('requirements-test.txt')


def fixup_platform_tag(plat):
if sys.platform.startswith("darwin"):
platforms = [plat]
# first, get the target macOS deployment target from the wheel
match = re.match(r"^macosx_(\d+)_(\d+)_.*$", plat)
assert match is not None, "Couldn't match on {}".format(plat)
target = tuple(map(int, match.groups()))
# given pip support for universal2 was added after x86_64 introduction
# let's also add x86_64 platform.
platforms.append("macosx_{}_{}_x86_64".format(*target))
# given pip support for universal2 was added after arm64 introduction
# let's also add arm64 platform.
arm64_target = target
if arm64_target < (11, 0):
arm64_target = (11, 0)
platforms.append("macosx_{}_{}_arm64".format(*arm64_target))
if target < (11, 0):
# They're were also issues with pip not picking up some universal2 wheels, tag twice
platforms.append("macosx_11_0_universal2")
return ".".join(platforms)
return plat


class bdist_wheel(_bdist_wheel_base):
def finalize_options(self):
_bdist_wheel_base.finalize_options(self)
self.root_is_pure = False

def get_tag(self):
_, _, plat = _bdist_wheel_base.get_tag(self)
python, abi, plat = "py2.py3", "none", fixup_platform_tag(plat)
return python, abi, plat


cmdclass = {"bdist_wheel": bdist_wheel}
for k, v in versioneer.get_cmdclass().items():
cmdclass[k] = v

setup(
name='ninja',

version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
cmdclass=cmdclass,

author='Jean-Christophe Fillion-Robin',
author_email='[email protected]',
Expand Down

0 comments on commit fcdc13c

Please sign in to comment.