mirror of https://github.com/pypa/pip
Support --python-tag for PEP 517 builds
This commit is contained in:
parent
f10be259ce
commit
3c94d81f68
|
@ -74,6 +74,14 @@ def open_for_csv(name, mode):
|
|||
return open(name, mode + bin, **nl)
|
||||
|
||||
|
||||
def replace_python_tag(wheelname, new_tag):
|
||||
"""Replace the Python tag in a wheel file name with a new value.
|
||||
"""
|
||||
parts = wheelname.split('-')
|
||||
parts[-3] = new_tag
|
||||
return '-'.join(parts)
|
||||
|
||||
|
||||
def fix_script(path):
|
||||
"""Replace #!python with #!/path/to/python
|
||||
Return True if file was changed."""
|
||||
|
@ -713,10 +721,19 @@ class WheelBuilder(object):
|
|||
spinner=spinner
|
||||
)
|
||||
with req.pep517_backend.subprocess_runner(runner):
|
||||
req.pep517_backend.build_wheel(
|
||||
wheelname = req.pep517_backend.build_wheel(
|
||||
tempd,
|
||||
metadata_directory=req.metadata_directory
|
||||
)
|
||||
if python_tag:
|
||||
# General PEP 517 backends don't necessarily support
|
||||
# a "--python-tag" option, so we rename the wheel
|
||||
# file directly.
|
||||
newname = replace_python_tag(wheelname, python_tag)
|
||||
os.rename(
|
||||
os.path.join(tempd, wheelname),
|
||||
os.path.join(tempd, newname)
|
||||
)
|
||||
return True
|
||||
except Exception:
|
||||
spinner.finish("error")
|
||||
|
|
|
@ -70,6 +70,21 @@ def test_wheel_version(tmpdir, data):
|
|||
assert not wheel.wheel_version(tmpdir + 'broken')
|
||||
|
||||
|
||||
def test_python_tag():
|
||||
wheelnames = [
|
||||
'simplewheel-1.0-py2.py3-none-any.whl',
|
||||
'simplewheel-1.0-py27-none-any.whl',
|
||||
'simplewheel-2.0-1-py2.py3-none-any.whl',
|
||||
]
|
||||
newnames = [
|
||||
'simplewheel-1.0-py37-none-any.whl',
|
||||
'simplewheel-1.0-py37-none-any.whl',
|
||||
'simplewheel-2.0-1-py37-none-any.whl',
|
||||
]
|
||||
for name, new in zip(wheelnames, newnames):
|
||||
assert wheel.replace_python_tag(name, 'py37') == new
|
||||
|
||||
|
||||
def test_check_compatibility():
|
||||
name = 'test'
|
||||
vc = wheel.VERSION_COMPATIBLE
|
||||
|
|
Loading…
Reference in New Issue