2013-05-28 23:58:08 +02:00
|
|
|
"""'pip wheel' tests"""
|
2012-10-17 00:57:10 +02:00
|
|
|
import os
|
2012-10-17 01:39:56 +02:00
|
|
|
import sys
|
2012-10-17 00:57:10 +02:00
|
|
|
import textwrap
|
2013-05-28 23:58:08 +02:00
|
|
|
from os.path import exists
|
2012-10-17 01:39:56 +02:00
|
|
|
|
|
|
|
from nose import SkipTest
|
|
|
|
from pip import wheel
|
2013-03-21 06:34:07 +01:00
|
|
|
from pip.download import path_to_url as path_to_url_d
|
2013-05-28 23:58:08 +02:00
|
|
|
from tests.lib import tests_data, reset_env, run_pip, pyversion_nodot, write_file, path_to_url, find_links, pip_install_local
|
|
|
|
|
|
|
|
|
|
|
|
def test_pip_wheel_fails_without_wheel():
|
|
|
|
"""
|
|
|
|
Test 'pip wheel' fails without wheel
|
|
|
|
"""
|
|
|
|
env = reset_env(use_distribute=True)
|
|
|
|
result = run_pip('wheel', '--no-index', '-f', find_links, 'simple==3.0', expect_error=True)
|
|
|
|
assert "'pip wheel' requires bdist_wheel" in result.stdout
|
|
|
|
|
|
|
|
def test_pip_wheel_setuptools_fails():
|
|
|
|
"""
|
|
|
|
Test 'pip wheel' fails with setuptools
|
|
|
|
"""
|
|
|
|
if sys.version_info >= (3, 0):
|
|
|
|
# virtualenv installs distribute in py3
|
|
|
|
raise SkipTest()
|
|
|
|
env = reset_env(use_distribute=False)
|
|
|
|
pip_install_local('wheel')
|
|
|
|
result = run_pip('wheel', '--no-index', '-f', find_links, 'simple==3.0', expect_error=True)
|
|
|
|
assert "'pip wheel' requires %s" % wheel.distribute_requirement in result.stdout, result.stdout
|
|
|
|
|
|
|
|
def test_pip_wheel_success():
|
|
|
|
"""
|
|
|
|
Test 'pip wheel' success.
|
|
|
|
"""
|
|
|
|
env = reset_env(use_distribute=True)
|
|
|
|
pip_install_local('wheel')
|
|
|
|
result = run_pip('wheel', '--no-index', '-f', find_links, 'simple==3.0')
|
|
|
|
wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
|
|
|
|
wheel_file_path = env.scratch/'wheelhouse'/wheel_file_name
|
|
|
|
assert wheel_file_path in result.files_created, result.stdout
|
|
|
|
assert "Successfully built simple" in result.stdout, result.stdout
|
|
|
|
|
|
|
|
|
|
|
|
def test_pip_wheel_fail():
|
|
|
|
"""
|
|
|
|
Test 'pip wheel' failure.
|
|
|
|
"""
|
|
|
|
env = reset_env(use_distribute=True)
|
|
|
|
pip_install_local('wheel')
|
|
|
|
result = run_pip('wheel', '--no-index', '-f', find_links, 'wheelbroken==0.1')
|
|
|
|
wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion_nodot
|
|
|
|
wheel_file_path = env.scratch/'wheelhouse'/wheel_file_name
|
|
|
|
assert wheel_file_path not in result.files_created, (wheel_file_path, result.files_created)
|
|
|
|
assert "FakeError" in result.stdout, result.stdout
|
|
|
|
assert "Failed to build wheelbroken" in result.stdout, result.stdout
|
|
|
|
|
|
|
|
|
|
|
|
def test_pip_wheel_ignore_wheels_editables():
|
|
|
|
"""
|
|
|
|
Test 'pip wheel' ignores editables and *.whl files in requirements
|
|
|
|
"""
|
|
|
|
env = reset_env(use_distribute=True)
|
|
|
|
pip_install_local('wheel')
|
|
|
|
|
|
|
|
local_wheel = '%s/simple.dist-0.1-py2.py3-none-any.whl' % find_links
|
|
|
|
local_editable = os.path.abspath(os.path.join(tests_data, 'packages', 'FSPkg'))
|
|
|
|
write_file('reqs.txt', textwrap.dedent("""\
|
|
|
|
%s
|
|
|
|
-e %s
|
|
|
|
simple
|
|
|
|
""" % (local_wheel, local_editable)))
|
|
|
|
result = run_pip('wheel', '--no-index', '-f', find_links, '-r', env.scratch_path / 'reqs.txt')
|
|
|
|
wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
|
|
|
|
wheel_file_path = env.scratch/'wheelhouse'/wheel_file_name
|
|
|
|
assert wheel_file_path in result.files_created, (wheel_file_path, result.files_created)
|
|
|
|
assert "Successfully built simple" in result.stdout, result.stdout
|
|
|
|
assert "Failed to build" not in result.stdout, result.stdout
|
|
|
|
assert "ignoring %s" % local_wheel in result.stdout
|
|
|
|
ignore_editable = "ignoring %s" % path_to_url(local_editable)
|
|
|
|
#TODO: understand this divergence
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
ignore_editable = "ignoring %s" % path_to_url_d(local_editable)
|
|
|
|
assert ignore_editable in result.stdout, result.stdout
|
|
|
|
|
|
|
|
|
|
|
|
def test_no_clean_option_blocks_cleaning_after_wheel():
|
|
|
|
"""
|
|
|
|
Test --no-clean option blocks cleaning after wheel build
|
|
|
|
"""
|
|
|
|
env = reset_env(use_distribute=True)
|
|
|
|
pip_install_local('wheel')
|
|
|
|
result = run_pip('wheel', '--no-clean', '--no-index', '--find-links=%s' % find_links, 'simple')
|
|
|
|
build = env.venv_path/'build'/'simple'
|
|
|
|
assert exists(build), "build/simple should still exist %s" % str(result)
|