Commit 4904f968 authored by Reinout van Rees's avatar Reinout van Rees

Using setuptools' wheel support directly

parent f603b11d
...@@ -37,6 +37,12 @@ import tempfile ...@@ -37,6 +37,12 @@ import tempfile
import zc.buildout import zc.buildout
import warnings import warnings
try:
from setuptools.wheel import Wheel
SETUPTOOLS_SUPPORTS_WHEELS = True
except ImportError:
SETUPTOOLS_SUPPORTS_WHEELS = False
warnings.filterwarnings( warnings.filterwarnings(
'ignore', '.+is being parsed as a legacy, non PEP 440, version') 'ignore', '.+is being parsed as a legacy, non PEP 440, version')
...@@ -1619,29 +1625,23 @@ def unpack_egg(location, dest): ...@@ -1619,29 +1625,23 @@ def unpack_egg(location, dest):
setuptools.archive_util.unpack_archive(location, dest) setuptools.archive_util.unpack_archive(location, dest)
WHEEL_TO_EGG_WARNING = """ WHEEL_WARNING = """
Using unpack_wheel() shim over the deprecated wheel_to_egg() hook. *.whl file detected (%s), you'll need setuptools > 38.2.0 for that
Please update your wheel extension implementation for one that installs a .whl or an extension like buildout.wheel
handler in %s.UNPACKERS """
""".strip() % (__name__,)
def unpack_wheel(location, dest): def unpack_wheel(location, dest):
# Deprecated backward compatibility shim. Please do not use. if SETUPTOOLS_SUPPORTS_WHEELS:
logger.warning(WHEEL_TO_EGG_WARNING) wheel = Wheel(location)
basename = os.path.basename(location) wheel.install_as_egg(os.path.join(dest, wheel.egg_name()))
dists = setuptools.package_index.distros_for_location(location, basename) else:
# `wheel_to_egg()` might generate zipped eggs, so we have to make sure we logger.warning(WHEEL_WARNING, location)
# get unpacked eggs in the end:
tmp_dest = tempfile.mkdtemp(dir=dest)
wheel_to_egg(list(dists)[0], tmp_dest)
[egg] = glob.glob(os.path.join(tmp_dest, '*.egg'))
unpack_egg(egg, dest)
shutil.rmtree(tmp_dest)
UNPACKERS = { UNPACKERS = {
'.egg': unpack_egg, '.egg': unpack_egg,
'.whl': unpack_egg, # Since 38.2, setuptools handles wheels, too. '.whl': unpack_wheel,
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment