Skip to content

Commit

Permalink
rely on wheel>=0.34.0 to be installed
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Sep 5, 2023
1 parent b4f2914 commit d7be206
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from distutils.errors import CompileError
import distutils.ccompiler
import distutils.sysconfig
from wheel.bdist_wheel import bdist_wheel, get_platform

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand All @@ -70,29 +71,17 @@
except Exception:
cpuinfo_parse_arch = None

# Patch bdist_wheel
try:
from wheel.bdist_wheel import bdist_wheel
except ImportError:
BDistWheel = None
else:
from pkg_resources import parse_version
import wheel
from wheel.bdist_wheel import get_platform

class BDistWheel(bdist_wheel):
"""Override bdist_wheel to handle as pure python package"""

def finalize_options(self):
if parse_version(wheel.__version__) >= parse_version('0.34.0'):
self.plat_name = get_platform(self.bdist_dir)
else:
self.plat_name = get_platform()
bdist_wheel.finalize_options(self)

def get_tag(self):
"""Override the python and abi tag generation"""
return self.python_tag, "none", bdist_wheel.get_tag(self)[-1]
class BDistWheel(bdist_wheel):
"""Override bdist_wheel to handle as pure python package"""

def finalize_options(self):
self.plat_name = get_platform(self.bdist_dir)
bdist_wheel.finalize_options(self)

def get_tag(self):
"""Override the python and abi tag generation"""
return self.python_tag, "none", bdist_wheel.get_tag(self)[-1]


# Probe host capabilities and manage build config
Expand Down Expand Up @@ -1325,13 +1314,12 @@ def make_distribution(self):
"Topic :: Software Development :: Libraries :: Python Modules",
]
cmdclass = dict(
bdist_wheel=BDistWheel,
build=Build,
build_clib=BuildCLib,
build_ext=PluginBuildExt,
build_py=BuildPy,
debian_src=sdist_debian)
if BDistWheel is not None:
cmdclass['bdist_wheel'] = BDistWheel


if __name__ == "__main__":
Expand Down

0 comments on commit d7be206

Please sign in to comment.