Force the --python-tag when autobuilding wheels

A lot of existing tarballs will successfully build a wheel, but the
wheel will be implicitly broken because they will have dynamically
adjusted the install_requires inside of their setup.py. Typically
this is done for things like Python version, implementation, or what
OS this is being installed on. We don't consider cache directories
to be OS agnostic but we do consider them to be Python version and
implementation agnostic. To solve this, we'll force the cached
wheel to use a more specific Python tag that includes the major
version and the implementation.
This commit is contained in:
Donald Stufft 2015-11-04 08:11:13 -05:00
parent 4bc2480e85
commit 0e240d7dde
3 changed files with 28 additions and 5 deletions

View File

@ -55,6 +55,13 @@ def get_impl_version_info():
return sys.version_info[0], sys.version_info[1]
def get_impl_tag():
"""
Returns the Tag for this specific implementation.
"""
return "{0}{1}".format(get_abbr_impl(), get_impl_ver())
def get_flag(var, fallback, expected=True, warn=True):
"""Use a fallback method for determining SOABI flags if the needed config
var is unset or unavailable."""
@ -198,3 +205,5 @@ def get_supported(versions=None, noarch=False):
supported_tags = get_supported()
supported_tags_noarch = get_supported(noarch=True)
implementation_tag = get_impl_tag()

View File

@ -662,14 +662,14 @@ class WheelBuilder(object):
self.build_options = build_options or []
self.global_options = global_options or []
def _build_one(self, req, output_dir):
def _build_one(self, req, output_dir, python_tag=None):
"""Build one wheel.
:return: The filename of the built wheel, or None if the build failed.
"""
tempd = tempfile.mkdtemp('pip-wheel-')
try:
if self.__build_one(req, tempd):
if self.__build_one(req, tempd, python_tag=python_tag):
try:
wheel_name = os.listdir(tempd)[0]
wheel_path = os.path.join(output_dir, wheel_name)
@ -692,13 +692,17 @@ class WheelBuilder(object):
"__file__, 'exec'))" % req.setup_py
] + list(self.global_options)
def __build_one(self, req, tempd):
def __build_one(self, req, tempd, python_tag=None):
base_args = self._base_setup_args(req)
logger.info('Running setup.py bdist_wheel for %s', req.name)
logger.debug('Destination directory: %s', tempd)
wheel_args = base_args + ['bdist_wheel', '-d', tempd] \
+ self.build_options
if python_tag is not None:
wheel_args += ["--python-tag", python_tag]
try:
call_subprocess(wheel_args, cwd=req.source_dir, show_stdout=False)
return True
@ -776,7 +780,9 @@ class WheelBuilder(object):
with indent_log():
build_success, build_failure = [], []
for req in buildset:
python_tag = None
if autobuilding:
python_tag = pep425tags.implementation_tag
output_dir = _cache_for_link(self._cache_root, req.link)
try:
ensure_dir(output_dir)
@ -787,7 +793,10 @@ class WheelBuilder(object):
continue
else:
output_dir = self._wheel_dir
wheel_file = self._build_one(req, output_dir)
wheel_file = self._build_one(
req, output_dir,
python_tag=python_tag,
)
if wheel_file:
build_success.append(req)
if autobuilding:

View File

@ -7,6 +7,7 @@ from os.path import join, curdir, pardir
import pytest
from pip import pep425tags
from pip.utils import appdirs, rmtree
from tests.lib import (pyversion, pyversion_tuple,
_create_test_package, _create_svn_repo, path_to_url)
@ -737,7 +738,7 @@ def test_install_builds_wheels(script, data):
assert expected in str(res), str(res)
root = appdirs.user_cache_dir('pip')
wheels = []
for top, dirs, files in os.walk(root):
for top, dirs, files in os.walk(os.path.join(root, "wheels")):
wheels.extend(files)
# and built wheels for upper and wheelbroken
assert "Running setup.py bdist_wheel for upper" in str(res), str(res)
@ -754,6 +755,10 @@ def test_install_builds_wheels(script, data):
assert "Running setup.py install for requires-wheel" in str(res), str(res)
# wheelbroken has to run install
assert "Running setup.py install for wheelb" in str(res), str(res)
# We want to make sure we used the correct implementation tag
assert wheels == [
"Upper-2.0-{0}-none-any.whl".format(pep425tags.implementation_tag),
]
def test_install_no_binary_disables_building_wheels(script, data):