2013-05-28 23:58:08 +02:00
|
|
|
"""'pip wheel' tests"""
|
2012-10-17 00:57:10 +02:00
|
|
|
import os
|
2015-01-15 00:53:15 +01:00
|
|
|
import pytest
|
2013-08-18 11:59:44 +02:00
|
|
|
|
2013-05-28 23:58:08 +02:00
|
|
|
from os.path import exists
|
2012-10-17 01:39:56 +02:00
|
|
|
|
2013-08-22 22:17:01 +02:00
|
|
|
from pip.locations import write_delete_marker_file
|
|
|
|
from pip.status_codes import PREVIOUS_BUILD_DIR_ERROR
|
2014-05-03 19:02:23 +02:00
|
|
|
from tests.lib import pyversion
|
2013-05-28 23:58:08 +02:00
|
|
|
|
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_pip_wheel_fails_without_wheel(script, data):
|
2013-05-28 23:58:08 +02:00
|
|
|
"""
|
|
|
|
Test 'pip wheel' fails without wheel
|
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'wheel', '--no-index', '-f', data.find_links, 'simple==3.0',
|
|
|
|
expect_error=True,
|
|
|
|
)
|
2015-03-16 13:34:52 +01:00
|
|
|
assert "'pip wheel' requires the 'wheel' package" in result.stderr
|
2013-05-28 23:58:08 +02:00
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_pip_wheel_success(script, data):
|
2013-05-28 23:58:08 +02:00
|
|
|
"""
|
|
|
|
Test 'pip wheel' success.
|
|
|
|
"""
|
2013-12-05 04:38:10 +01:00
|
|
|
script.pip('install', 'wheel')
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'wheel', '--no-index', '-f', data.find_links, 'simple==3.0',
|
|
|
|
)
|
2014-04-03 01:49:27 +02:00
|
|
|
wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion[0]
|
2016-01-19 22:42:22 +01:00
|
|
|
wheel_file_path = script.scratch / wheel_file_name
|
2013-05-28 23:58:08 +02:00
|
|
|
assert wheel_file_path in result.files_created, result.stdout
|
|
|
|
assert "Successfully built simple" in result.stdout, result.stdout
|
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2014-02-01 20:41:55 +01:00
|
|
|
def test_pip_wheel_downloads_wheels(script, data):
|
|
|
|
"""
|
|
|
|
Test 'pip wheel' downloads wheels
|
|
|
|
"""
|
|
|
|
script.pip('install', 'wheel')
|
|
|
|
result = script.pip(
|
|
|
|
'wheel', '--no-index', '-f', data.find_links, 'simple.dist',
|
|
|
|
)
|
|
|
|
wheel_file_name = 'simple.dist-0.1-py2.py3-none-any.whl'
|
2016-01-19 22:42:22 +01:00
|
|
|
wheel_file_path = script.scratch / wheel_file_name
|
2014-02-01 20:41:55 +01:00
|
|
|
assert wheel_file_path in result.files_created, result.stdout
|
|
|
|
assert "Saved" in result.stdout, result.stdout
|
|
|
|
|
|
|
|
|
2015-04-17 05:03:34 +02:00
|
|
|
@pytest.mark.network
|
|
|
|
def test_pip_wheel_builds_when_no_binary_set(script, data):
|
|
|
|
script.pip('install', 'wheel')
|
|
|
|
res = script.pip(
|
|
|
|
'wheel', '--no-index', '--no-binary', ':all:', '-f', data.find_links,
|
|
|
|
'setuptools==0.9.8')
|
|
|
|
assert "Running setup.py bdist_wheel for setuptools" in str(res), str(res)
|
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2014-05-03 19:02:23 +02:00
|
|
|
def test_pip_wheel_builds_editable_deps(script, data):
|
|
|
|
"""
|
|
|
|
Test 'pip wheel' finds and builds dependencies of editables
|
|
|
|
"""
|
|
|
|
script.pip('install', 'wheel')
|
|
|
|
editable_path = os.path.join(data.src, 'requires_simple')
|
|
|
|
result = script.pip(
|
|
|
|
'wheel', '--no-index', '-f', data.find_links, '-e', editable_path
|
|
|
|
)
|
|
|
|
wheel_file_name = 'simple-1.0-py%s-none-any.whl' % pyversion[0]
|
2016-01-19 22:42:22 +01:00
|
|
|
wheel_file_path = script.scratch / wheel_file_name
|
2014-05-03 19:02:23 +02:00
|
|
|
assert wheel_file_path in result.files_created, result.stdout
|
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_pip_wheel_fail(script, data):
|
2013-05-28 23:58:08 +02:00
|
|
|
"""
|
|
|
|
Test 'pip wheel' failure.
|
|
|
|
"""
|
2013-12-05 04:38:10 +01:00
|
|
|
script.pip('install', 'wheel')
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'wheel', '--no-index', '-f', data.find_links, 'wheelbroken==0.1',
|
2014-04-28 16:46:29 +02:00
|
|
|
expect_error=True,
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2014-04-03 01:49:27 +02:00
|
|
|
wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion[0]
|
2016-01-19 22:42:22 +01:00
|
|
|
wheel_file_path = script.scratch / wheel_file_name
|
2014-01-28 15:17:51 +01:00
|
|
|
assert wheel_file_path not in result.files_created, (
|
|
|
|
wheel_file_path,
|
|
|
|
result.files_created,
|
|
|
|
)
|
2013-05-28 23:58:08 +02:00
|
|
|
assert "FakeError" in result.stdout, result.stdout
|
|
|
|
assert "Failed to build wheelbroken" in result.stdout, result.stdout
|
2014-04-28 15:28:31 +02:00
|
|
|
assert result.returncode != 0
|
2013-05-28 23:58:08 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_no_clean_option_blocks_cleaning_after_wheel(script, data):
|
2013-05-28 23:58:08 +02:00
|
|
|
"""
|
|
|
|
Test --no-clean option blocks cleaning after wheel build
|
|
|
|
"""
|
2013-12-05 04:38:10 +01:00
|
|
|
script.pip('install', 'wheel')
|
2014-11-12 01:19:32 +01:00
|
|
|
build = script.venv_path / 'build'
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
2014-11-12 01:19:32 +01:00
|
|
|
'wheel', '--no-clean', '--no-index', '--build', build,
|
2014-01-28 15:17:51 +01:00
|
|
|
'--find-links=%s' % data.find_links, 'simple',
|
|
|
|
)
|
2014-11-12 01:19:32 +01:00
|
|
|
build = build / 'simple'
|
2013-05-28 23:58:08 +02:00
|
|
|
assert exists(build), "build/simple should still exist %s" % str(result)
|
2013-06-07 04:11:43 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_pip_wheel_source_deps(script, data):
|
2013-06-07 04:11:43 +02:00
|
|
|
"""
|
2015-04-20 03:27:27 +02:00
|
|
|
Test 'pip wheel' finds and builds source archive dependencies
|
2014-01-28 15:17:51 +01:00
|
|
|
of wheels
|
2013-06-07 04:11:43 +02:00
|
|
|
"""
|
|
|
|
# 'requires_source' is a wheel that depends on the 'source' project
|
2013-12-05 04:38:10 +01:00
|
|
|
script.pip('install', 'wheel')
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
2015-04-20 03:27:27 +02:00
|
|
|
'wheel', '--no-index', '-f', data.find_links, 'requires_source',
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2014-04-03 01:49:27 +02:00
|
|
|
wheel_file_name = 'source-1.0-py%s-none-any.whl' % pyversion[0]
|
2016-01-19 22:42:22 +01:00
|
|
|
wheel_file_path = script.scratch / wheel_file_name
|
2013-06-07 04:11:43 +02:00
|
|
|
assert wheel_file_path in result.files_created, result.stdout
|
|
|
|
assert "Successfully built source" in result.stdout, result.stdout
|
2013-08-22 22:17:01 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_pip_wheel_fail_cause_of_previous_build_dir(script, data):
|
2014-01-28 15:17:51 +01:00
|
|
|
"""
|
|
|
|
Test when 'pip wheel' tries to install a package that has a previous build
|
|
|
|
directory
|
|
|
|
"""
|
2013-08-22 22:17:01 +02:00
|
|
|
|
2013-12-05 04:38:10 +01:00
|
|
|
script.pip('install', 'wheel')
|
2013-08-22 22:17:01 +02:00
|
|
|
|
|
|
|
# Given that I have a previous build dir of the `simple` package
|
|
|
|
build = script.venv_path / 'build' / 'simple'
|
|
|
|
os.makedirs(build)
|
|
|
|
write_delete_marker_file(script.venv_path / 'build')
|
|
|
|
build.join('setup.py').write('#')
|
|
|
|
|
|
|
|
# When I call pip trying to install things again
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'wheel', '--no-index', '--find-links=%s' % data.find_links,
|
2014-11-12 01:19:32 +01:00
|
|
|
'--build', script.venv_path / 'build',
|
2014-01-28 15:17:51 +01:00
|
|
|
'simple==3.0', expect_error=True,
|
|
|
|
)
|
2013-08-22 22:17:01 +02:00
|
|
|
|
|
|
|
# Then I see that the error code is the right one
|
2014-05-03 19:02:23 +02:00
|
|
|
assert result.returncode == PREVIOUS_BUILD_DIR_ERROR, result
|
2015-11-26 22:36:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_wheel_package_with_latin1_setup(script, data):
|
|
|
|
"""Create a wheel from a package with latin-1 encoded setup.py."""
|
|
|
|
script.pip('install', 'wheel')
|
|
|
|
|
|
|
|
pkg_to_wheel = data.packages.join("SetupPyLatin1")
|
|
|
|
result = script.pip('wheel', pkg_to_wheel)
|
|
|
|
assert 'Successfully built SetupPyUTF8' in result.stdout
|