2017-05-16 12:16:30 +02:00
|
|
|
import glob
|
2010-08-06 20:10:16 +02:00
|
|
|
import os
|
2015-11-19 16:32:02 +01:00
|
|
|
import sys
|
2013-05-28 23:58:08 +02:00
|
|
|
import textwrap
|
2017-05-16 12:16:30 +02:00
|
|
|
from os.path import curdir, join, pardir
|
2011-03-20 18:12:04 +01:00
|
|
|
|
2013-08-18 11:59:44 +02:00
|
|
|
import pytest
|
2017-06-13 14:17:00 +02:00
|
|
|
|
2017-08-31 17:48:18 +02:00
|
|
|
from pip._internal import pep425tags
|
|
|
|
from pip._internal.status_codes import ERROR
|
|
|
|
from pip._internal.utils import appdirs
|
|
|
|
from pip._internal.utils.misc import rmtree
|
2017-05-16 12:16:30 +02:00
|
|
|
from tests.lib import (
|
|
|
|
_create_svn_repo, _create_test_package, create_test_package_with_setup,
|
|
|
|
path_to_url, pyversion, pyversion_tuple, requirements_file
|
|
|
|
)
|
2013-06-13 08:36:16 +02:00
|
|
|
from tests.lib.local_repos import local_checkout
|
|
|
|
from tests.lib.path import Path
|
2013-06-12 22:58:37 +02:00
|
|
|
|
|
|
|
|
2015-03-14 20:47:55 +01:00
|
|
|
def test_without_setuptools(script, data):
|
2016-01-02 04:20:14 +01:00
|
|
|
script.pip("uninstall", "setuptools", "-y")
|
2014-01-07 14:36:04 +01:00
|
|
|
result = script.run(
|
2014-01-07 15:03:43 +01:00
|
|
|
"python", "-c",
|
2017-08-31 17:48:18 +02:00
|
|
|
"import pip._internal; pip._internal.main(["
|
2015-03-14 20:47:55 +01:00
|
|
|
"'install', "
|
|
|
|
"'INITools==0.2', "
|
|
|
|
"'-f', '%s', "
|
2015-04-17 05:03:34 +02:00
|
|
|
"'--no-binary=:all:'])" % data.packages,
|
2014-01-07 14:36:04 +01:00
|
|
|
expect_error=True,
|
|
|
|
)
|
|
|
|
assert (
|
2015-10-19 17:04:02 +02:00
|
|
|
"Could not import setuptools which is required to install from a "
|
|
|
|
"source distribution."
|
2015-03-16 13:34:52 +01:00
|
|
|
in result.stderr
|
2014-01-07 14:36:04 +01:00
|
|
|
)
|
2015-10-23 23:49:38 +02:00
|
|
|
assert "Please install setuptools" in result.stderr
|
|
|
|
|
|
|
|
|
|
|
|
def test_with_setuptools_and_import_error(script, data):
|
|
|
|
# Make sure we get an ImportError while importing setuptools
|
|
|
|
setuptools_init_path = script.site_packages_path.join(
|
|
|
|
"setuptools", "__init__.py")
|
|
|
|
with open(setuptools_init_path, 'a') as f:
|
|
|
|
f.write('\nraise ImportError("toto")')
|
|
|
|
|
|
|
|
result = script.run(
|
|
|
|
"python", "-c",
|
2017-08-31 17:48:18 +02:00
|
|
|
"import pip._internal; pip._internal.main(["
|
2015-10-23 23:49:38 +02:00
|
|
|
"'install', "
|
|
|
|
"'INITools==0.2', "
|
|
|
|
"'-f', '%s', "
|
|
|
|
"'--no-binary=:all:'])" % data.packages,
|
|
|
|
expect_error=True,
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
"Could not import setuptools which is required to install from a "
|
|
|
|
"source distribution."
|
|
|
|
in result.stderr
|
|
|
|
)
|
|
|
|
assert "Traceback " in result.stderr
|
|
|
|
assert "ImportError: toto" in result.stderr
|
2014-01-07 14:36:04 +01:00
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2015-03-14 20:47:55 +01:00
|
|
|
def test_pip_second_command_line_interface_works(script, data):
|
2013-06-12 22:58:37 +02:00
|
|
|
"""
|
2013-07-14 16:32:36 +02:00
|
|
|
Check if ``pip<PYVERSION>`` commands behaves equally
|
2013-06-12 22:58:37 +02:00
|
|
|
"""
|
2015-03-15 15:56:08 +01:00
|
|
|
# On old versions of Python, urllib3/requests will raise a warning about
|
|
|
|
# the lack of an SSLContext.
|
|
|
|
kwargs = {}
|
2017-03-21 12:28:22 +01:00
|
|
|
if pyversion_tuple < (2, 7, 9) or pyversion_tuple[:2] == (3, 3):
|
2015-03-15 15:56:08 +01:00
|
|
|
kwargs['expect_stderr'] = True
|
|
|
|
|
2013-07-14 16:32:36 +02:00
|
|
|
args = ['pip%s' % pyversion]
|
2013-06-12 22:58:37 +02:00
|
|
|
args.extend(['install', 'INITools==0.2'])
|
2015-03-14 20:47:55 +01:00
|
|
|
args.extend(['-f', data.packages])
|
2015-03-15 15:56:08 +01:00
|
|
|
result = script.run(*args, **kwargs)
|
2014-01-28 15:17:51 +01:00
|
|
|
egg_info_folder = (
|
|
|
|
script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
|
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
initools_folder = script.site_packages / 'initools'
|
2013-06-12 22:58:37 +02:00
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
|
|
|
assert initools_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2017-01-06 23:21:46 +01:00
|
|
|
def test_install_exit_status_code_when_no_requirements(script):
|
|
|
|
"""
|
|
|
|
Test install exit status code when no requirements specified
|
|
|
|
"""
|
|
|
|
result = script.pip('install', expect_error=True)
|
|
|
|
assert "You must give at least one requirement to install" in result.stderr
|
|
|
|
assert result.returncode == ERROR
|
|
|
|
|
|
|
|
|
|
|
|
def test_install_exit_status_code_when_blank_requirements_file(script):
|
|
|
|
"""
|
|
|
|
Test install exit status code when blank requirements file specified
|
|
|
|
"""
|
|
|
|
script.scratch_path.join("blank.txt").write("\n")
|
|
|
|
script.pip('install', '-r', 'blank.txt')
|
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_install_from_pypi(script):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Test installing a package from PyPI.
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('install', '-vvv', 'INITools==0.2')
|
2014-01-28 15:17:51 +01:00
|
|
|
egg_info_folder = (
|
|
|
|
script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
|
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
initools_folder = script.site_packages / 'initools'
|
2010-06-09 01:09:37 +02:00
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
|
|
|
assert initools_folder in result.files_created, str(result)
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2017-06-26 22:45:47 +02:00
|
|
|
# Should not display where it's looking for files
|
|
|
|
assert "Looking in indexes: " not in result.stdout
|
|
|
|
assert "Looking in links: " not in result.stdout
|
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_editable_install(script):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Test editable installation.
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('install', '-e', 'INITools==0.2', expect_error=True)
|
2014-01-28 15:17:51 +01:00
|
|
|
assert (
|
|
|
|
"INITools==0.2 should either be a path to a local project or a VCS url"
|
2015-03-16 13:34:52 +01:00
|
|
|
in result.stderr
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2014-08-31 01:52:28 +02:00
|
|
|
assert not result.files_created
|
|
|
|
assert not result.files_updated
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.svn
|
2015-03-14 20:47:55 +01:00
|
|
|
def test_install_editable_from_svn(script):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Test checking out from svn.
|
|
|
|
"""
|
2015-03-14 20:47:55 +01:00
|
|
|
checkout_path = _create_test_package(script)
|
|
|
|
repo_url = _create_svn_repo(script, checkout_path)
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install',
|
2015-03-14 20:47:55 +01:00
|
|
|
'-e', 'svn+' + repo_url + '#egg=version-pkg'
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2015-03-14 20:47:55 +01:00
|
|
|
result.assert_installed('version-pkg', with_files=['.svn'])
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2017-05-14 00:23:17 +02:00
|
|
|
def _test_install_editable_from_git(script, tmpdir):
|
2015-03-19 11:54:09 +01:00
|
|
|
"""Test cloning from Git."""
|
|
|
|
pkg_path = _create_test_package(script, name='testpackage', vcs='git')
|
|
|
|
args = ['install', '-e', 'git+%s#egg=testpackage' % path_to_url(pkg_path)]
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip(*args, **{"expect_error": True})
|
2015-03-19 11:54:09 +01:00
|
|
|
result.assert_installed('testpackage', with_files=['.git'])
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2015-04-01 03:39:45 +02:00
|
|
|
def test_install_editable_from_git(script, tmpdir):
|
2017-05-14 00:23:17 +02:00
|
|
|
_test_install_editable_from_git(script, tmpdir)
|
2015-04-01 03:39:45 +02:00
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_editable_from_git_autobuild_wheel(
|
|
|
|
script, tmpdir, common_wheels):
|
|
|
|
script.pip('install', 'wheel', '--no-index', '-f', common_wheels)
|
|
|
|
_test_install_editable_from_git(script, tmpdir)
|
2015-04-01 03:39:45 +02:00
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2014-03-02 13:31:05 +01:00
|
|
|
def test_install_editable_uninstalls_existing(data, script, tmpdir):
|
|
|
|
"""
|
|
|
|
Test that installing an editable uninstalls a previously installed
|
|
|
|
non-editable version.
|
|
|
|
https://github.com/pypa/pip/issues/1548
|
|
|
|
https://github.com/pypa/pip/pull/1552
|
|
|
|
"""
|
|
|
|
to_install = data.packages.join("pip-test-package-0.1.tar.gz")
|
|
|
|
result = script.pip_install_local(to_install)
|
|
|
|
assert 'Successfully installed pip-test-package' in result.stdout
|
|
|
|
result.assert_installed('piptestpackage', editable=False)
|
|
|
|
|
|
|
|
result = script.pip(
|
|
|
|
'install', '-e',
|
|
|
|
'%s#egg=pip-test-package' %
|
|
|
|
local_checkout(
|
|
|
|
'git+http://github.com/pypa/pip-test-package.git',
|
|
|
|
tmpdir.join("cache"),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
result.assert_installed('pip-test-package', with_files=['.git'])
|
|
|
|
assert 'Found existing installation: pip-test-package 0.1' in result.stdout
|
2016-08-05 22:42:22 +02:00
|
|
|
assert 'Uninstalling pip-test-package-' in result.stdout
|
2014-03-02 13:31:05 +01:00
|
|
|
assert 'Successfully uninstalled pip-test-package' in result.stdout
|
|
|
|
|
|
|
|
|
2016-08-05 22:42:22 +02:00
|
|
|
def test_install_editable_uninstalls_existing_from_path(script, data):
|
|
|
|
"""
|
|
|
|
Test that installing an editable uninstalls a previously installed
|
|
|
|
non-editable version from path
|
|
|
|
"""
|
|
|
|
to_install = data.src.join('simplewheel-1.0')
|
|
|
|
result = script.pip_install_local(to_install)
|
|
|
|
assert 'Successfully installed simplewheel' in result.stdout
|
|
|
|
simple_folder = script.site_packages / 'simple'
|
|
|
|
result.assert_installed('simple', editable=False)
|
|
|
|
assert simple_folder in result.files_created, str(result.stdout)
|
|
|
|
|
|
|
|
result = script.pip(
|
|
|
|
'install', '-e',
|
|
|
|
to_install,
|
|
|
|
)
|
|
|
|
install_path = script.site_packages / 'simplewheel.egg-link'
|
|
|
|
assert install_path in result.files_created, str(result)
|
|
|
|
assert 'Found existing installation: simplewheel 1.0' in result.stdout
|
|
|
|
assert 'Uninstalling simplewheel-' in result.stdout
|
|
|
|
assert 'Successfully uninstalled simplewheel' in result.stdout
|
|
|
|
assert simple_folder in result.files_deleted, str(result.stdout)
|
|
|
|
|
|
|
|
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_install_editable_from_hg(script, tmpdir):
|
2015-03-19 11:54:09 +01:00
|
|
|
"""Test cloning from Mercurial."""
|
|
|
|
pkg_path = _create_test_package(script, name='testpackage', vcs='hg')
|
|
|
|
args = ['install', '-e', 'hg+%s#egg=testpackage' % path_to_url(pkg_path)]
|
|
|
|
result = script.pip(*args, **{"expect_error": True})
|
|
|
|
result.assert_installed('testpackage', with_files=['.hg'])
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_vcs_url_final_slash_normalization(script, tmpdir):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Test that presence or absence of final slash in VCS URL is normalized.
|
|
|
|
"""
|
2015-03-19 11:54:09 +01:00
|
|
|
pkg_path = _create_test_package(script, name='testpackage', vcs='hg')
|
|
|
|
args = ['install', '-e', 'hg+%s/#egg=testpackage' % path_to_url(pkg_path)]
|
|
|
|
result = script.pip(*args, **{"expect_error": True})
|
|
|
|
result.assert_installed('testpackage', with_files=['.hg'])
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.bzr
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_install_editable_from_bazaar(script, tmpdir):
|
2015-03-19 11:54:09 +01:00
|
|
|
"""Test checking out from Bazaar."""
|
|
|
|
pkg_path = _create_test_package(script, name='testpackage', vcs='bazaar')
|
|
|
|
args = ['install', '-e', 'bzr+%s/#egg=testpackage' % path_to_url(pkg_path)]
|
|
|
|
result = script.pip(*args, **{"expect_error": True})
|
|
|
|
result.assert_installed('testpackage', with_files=['.bzr'])
|
2010-04-13 00:34:38 +02:00
|
|
|
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.bzr
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_vcs_url_urlquote_normalization(script, tmpdir):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Test that urlquoted characters are normalized for repo URL comparison.
|
|
|
|
"""
|
2014-08-31 01:52:28 +02:00
|
|
|
script.pip(
|
2014-01-28 15:17:51 +01:00
|
|
|
'install', '-e',
|
|
|
|
'%s/#egg=django-wikiapp' %
|
|
|
|
local_checkout(
|
|
|
|
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp'
|
|
|
|
'/release-0.1',
|
|
|
|
tmpdir.join("cache"),
|
|
|
|
),
|
|
|
|
)
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_install_from_local_directory(script, data):
|
2010-04-13 08:59:43 +02:00
|
|
|
"""
|
|
|
|
Test installing from a local directory.
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
to_install = data.packages.join("FSPkg")
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('install', to_install, expect_error=False)
|
2014-02-24 22:52:23 +01:00
|
|
|
fspkg_folder = script.site_packages / 'fspkg'
|
2014-01-28 15:17:51 +01:00
|
|
|
egg_info_folder = (
|
2014-11-19 23:05:14 +01:00
|
|
|
script.site_packages / 'FSPkg-0.1.dev0-py%s.egg-info' % pyversion
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2010-06-09 01:09:37 +02:00
|
|
|
assert fspkg_folder in result.files_created, str(result.stdout)
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
2010-04-13 08:59:43 +02:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2017-04-06 00:32:36 +02:00
|
|
|
def test_install_relative_directory(script, data):
|
2017-04-05 17:58:21 +02:00
|
|
|
"""
|
2017-04-06 00:32:36 +02:00
|
|
|
Test installing a requirement using a relative path.
|
2017-04-05 17:58:21 +02:00
|
|
|
"""
|
2017-04-06 00:32:36 +02:00
|
|
|
egg_info_file = (
|
2017-04-05 17:58:21 +02:00
|
|
|
script.site_packages / 'FSPkg-0.1.dev0-py%s.egg-info' % pyversion
|
|
|
|
)
|
|
|
|
egg_link_file = (
|
|
|
|
script.site_packages / 'FSPkg.egg-link'
|
|
|
|
)
|
2017-04-06 00:32:36 +02:00
|
|
|
package_folder = script.site_packages / 'fspkg'
|
|
|
|
|
|
|
|
# Compute relative install path to FSPkg from scratch path.
|
|
|
|
full_rel_path = data.packages.join('FSPkg') - script.scratch_path
|
|
|
|
embedded_rel_path = script.scratch_path.join(full_rel_path)
|
|
|
|
|
|
|
|
# For each relative path, install as either editable or not using either
|
|
|
|
# URLs with egg links or not.
|
|
|
|
for req_path in (full_rel_path,
|
2017-04-06 15:49:57 +02:00
|
|
|
'file:' + full_rel_path + '#egg=FSPkg',
|
|
|
|
embedded_rel_path):
|
2017-04-06 00:32:36 +02:00
|
|
|
# Regular install.
|
|
|
|
result = script.pip('install', req_path,
|
|
|
|
cwd=script.scratch_path)
|
|
|
|
assert egg_info_file in result.files_created, str(result)
|
|
|
|
assert package_folder in result.files_created, str(result)
|
2017-04-05 17:58:21 +02:00
|
|
|
script.pip('uninstall', '-y', 'fspkg')
|
|
|
|
|
2017-04-06 00:32:36 +02:00
|
|
|
# Editable install.
|
|
|
|
result = script.pip('install', '-e' + req_path,
|
|
|
|
cwd=script.scratch_path)
|
|
|
|
assert egg_link_file in result.files_created, str(result)
|
|
|
|
script.pip('uninstall', '-y', 'fspkg')
|
2017-04-05 17:58:21 +02:00
|
|
|
|
|
|
|
|
2016-02-01 21:36:49 +01:00
|
|
|
def test_install_quiet(script, data):
|
|
|
|
"""
|
|
|
|
Test that install -q is actually quiet.
|
|
|
|
"""
|
|
|
|
# Apparently if pip install -q is not actually quiet, then it breaks
|
|
|
|
# everything. See:
|
|
|
|
# https://github.com/pypa/pip/issues/3418
|
|
|
|
# https://github.com/docker-library/python/issues/83
|
|
|
|
to_install = data.packages.join("FSPkg")
|
2017-03-25 00:10:52 +01:00
|
|
|
result = script.pip('install', '-qqq', to_install, expect_error=False)
|
2016-02-01 21:36:49 +01:00
|
|
|
assert result.stdout == ""
|
|
|
|
assert result.stderr == ""
|
|
|
|
|
|
|
|
|
Add checks against requirements-file-dwelling hashes for most kinds of packages. Close #1175.
* Add --require-hashes option. This is handy in deployment scripts to force application authors to hash their requirements. It is also a convenient way to get pip to show computed hashes for a virgin, unhashed requirements file. Eventually, additions to `pip freeze` should fill a superset of this use case.
* In --require-hashes mode, at least one hash is required to match for each requirement.
* Option-based requirements (--sha256=...) turn on --require-hashes mode implicitly.
* Internet-derived URL-based hashes are "necessary but not sufficient": they do not satisfy --require-hashes mode when they match, but they are still used to guard against transmission errors.
* Other URL-based requirements (#md5=...) are treated just like flag-based ones, except they don't turn on --require-hashes.
* Complain informatively, with the most devastating errors first so you don't chase your tail all day only to run up against a brick wall at the end. This also means we don't complain that a hash is missing, only for the user to find, after fixing it, that we have no idea how to even compute a hash for that type of requirement.
* Complain about unpinned requirements when hash-checking mode is on, lest they cause the user surprise later.
* Complain about missing hashes.
* Complain about requirement types we don't know how to hash (like VCS ones and local dirs).
* Have InstallRequirement keep its original Link around (original_link) so we can differentiate between URL hashes from requirements files and ones downloaded from the (untrustworthy) internet.
* Remove test_download_hashes, which is obsolete. Similar coverage is provided in test_utils.TestHashes and the various hash cases in test_req.py.
2015-09-09 19:01:53 +02:00
|
|
|
def test_hashed_install_success(script, data, tmpdir):
|
|
|
|
"""
|
|
|
|
Test that installing various sorts of requirements with correct hashes
|
|
|
|
works.
|
|
|
|
|
|
|
|
Test file URLs and index packages (which become HTTP URLs behind the
|
|
|
|
scenes).
|
|
|
|
|
|
|
|
"""
|
|
|
|
file_url = path_to_url(
|
|
|
|
(data.packages / 'simple-1.0.tar.gz').abspath)
|
2015-09-25 00:53:39 +02:00
|
|
|
with requirements_file(
|
|
|
|
'simple2==1.0 --hash=sha256:9336af72ca661e6336eb87bc7de3e8844d853e'
|
|
|
|
'3848c2b9bbd2e8bf01db88c2c7\n'
|
|
|
|
'{simple} --hash=sha256:393043e672415891885c9a2a0929b1af95fb866d6c'
|
|
|
|
'a016b42d2e6ce53619b653'.format(simple=file_url),
|
|
|
|
tmpdir) as reqs_file:
|
|
|
|
script.pip_install_local('-r', reqs_file.abspath, expect_error=False)
|
Add checks against requirements-file-dwelling hashes for most kinds of packages. Close #1175.
* Add --require-hashes option. This is handy in deployment scripts to force application authors to hash their requirements. It is also a convenient way to get pip to show computed hashes for a virgin, unhashed requirements file. Eventually, additions to `pip freeze` should fill a superset of this use case.
* In --require-hashes mode, at least one hash is required to match for each requirement.
* Option-based requirements (--sha256=...) turn on --require-hashes mode implicitly.
* Internet-derived URL-based hashes are "necessary but not sufficient": they do not satisfy --require-hashes mode when they match, but they are still used to guard against transmission errors.
* Other URL-based requirements (#md5=...) are treated just like flag-based ones, except they don't turn on --require-hashes.
* Complain informatively, with the most devastating errors first so you don't chase your tail all day only to run up against a brick wall at the end. This also means we don't complain that a hash is missing, only for the user to find, after fixing it, that we have no idea how to even compute a hash for that type of requirement.
* Complain about unpinned requirements when hash-checking mode is on, lest they cause the user surprise later.
* Complain about missing hashes.
* Complain about requirement types we don't know how to hash (like VCS ones and local dirs).
* Have InstallRequirement keep its original Link around (original_link) so we can differentiate between URL hashes from requirements files and ones downloaded from the (untrustworthy) internet.
* Remove test_download_hashes, which is obsolete. Similar coverage is provided in test_utils.TestHashes and the various hash cases in test_req.py.
2015-09-09 19:01:53 +02:00
|
|
|
|
|
|
|
|
2017-10-02 19:33:52 +02:00
|
|
|
def test_hashed_install_failure(script, tmpdir):
|
Add checks against requirements-file-dwelling hashes for most kinds of packages. Close #1175.
* Add --require-hashes option. This is handy in deployment scripts to force application authors to hash their requirements. It is also a convenient way to get pip to show computed hashes for a virgin, unhashed requirements file. Eventually, additions to `pip freeze` should fill a superset of this use case.
* In --require-hashes mode, at least one hash is required to match for each requirement.
* Option-based requirements (--sha256=...) turn on --require-hashes mode implicitly.
* Internet-derived URL-based hashes are "necessary but not sufficient": they do not satisfy --require-hashes mode when they match, but they are still used to guard against transmission errors.
* Other URL-based requirements (#md5=...) are treated just like flag-based ones, except they don't turn on --require-hashes.
* Complain informatively, with the most devastating errors first so you don't chase your tail all day only to run up against a brick wall at the end. This also means we don't complain that a hash is missing, only for the user to find, after fixing it, that we have no idea how to even compute a hash for that type of requirement.
* Complain about unpinned requirements when hash-checking mode is on, lest they cause the user surprise later.
* Complain about missing hashes.
* Complain about requirement types we don't know how to hash (like VCS ones and local dirs).
* Have InstallRequirement keep its original Link around (original_link) so we can differentiate between URL hashes from requirements files and ones downloaded from the (untrustworthy) internet.
* Remove test_download_hashes, which is obsolete. Similar coverage is provided in test_utils.TestHashes and the various hash cases in test_req.py.
2015-09-09 19:01:53 +02:00
|
|
|
"""Test that wrong hashes stop installation.
|
|
|
|
|
|
|
|
This makes sure prepare_files() is called in the course of installation
|
|
|
|
and so has the opportunity to halt if hashes are wrong. Checks on various
|
|
|
|
kinds of hashes are in test_req.py.
|
|
|
|
|
|
|
|
"""
|
2015-09-25 00:53:39 +02:00
|
|
|
with requirements_file('simple2==1.0 --hash=sha256:9336af72ca661e6336eb87b'
|
|
|
|
'c7de3e8844d853e3848c2b9bbd2e8bf01db88c2c\n',
|
Add checks against requirements-file-dwelling hashes for most kinds of packages. Close #1175.
* Add --require-hashes option. This is handy in deployment scripts to force application authors to hash their requirements. It is also a convenient way to get pip to show computed hashes for a virgin, unhashed requirements file. Eventually, additions to `pip freeze` should fill a superset of this use case.
* In --require-hashes mode, at least one hash is required to match for each requirement.
* Option-based requirements (--sha256=...) turn on --require-hashes mode implicitly.
* Internet-derived URL-based hashes are "necessary but not sufficient": they do not satisfy --require-hashes mode when they match, but they are still used to guard against transmission errors.
* Other URL-based requirements (#md5=...) are treated just like flag-based ones, except they don't turn on --require-hashes.
* Complain informatively, with the most devastating errors first so you don't chase your tail all day only to run up against a brick wall at the end. This also means we don't complain that a hash is missing, only for the user to find, after fixing it, that we have no idea how to even compute a hash for that type of requirement.
* Complain about unpinned requirements when hash-checking mode is on, lest they cause the user surprise later.
* Complain about missing hashes.
* Complain about requirement types we don't know how to hash (like VCS ones and local dirs).
* Have InstallRequirement keep its original Link around (original_link) so we can differentiate between URL hashes from requirements files and ones downloaded from the (untrustworthy) internet.
* Remove test_download_hashes, which is obsolete. Similar coverage is provided in test_utils.TestHashes and the various hash cases in test_req.py.
2015-09-09 19:01:53 +02:00
|
|
|
tmpdir) as reqs_file:
|
|
|
|
result = script.pip_install_local('-r',
|
|
|
|
reqs_file.abspath,
|
|
|
|
expect_error=True)
|
|
|
|
assert len(result.files_created) == 0
|
|
|
|
|
|
|
|
|
2014-01-28 15:17:51 +01:00
|
|
|
def test_install_from_local_directory_with_symlinks_to_directories(
|
|
|
|
script, data):
|
2013-11-10 00:57:34 +01:00
|
|
|
"""
|
|
|
|
Test installing from a local directory containing symlinks to directories.
|
|
|
|
"""
|
|
|
|
to_install = data.packages.join("symlinks")
|
|
|
|
result = script.pip('install', to_install, expect_error=False)
|
2014-02-24 22:52:23 +01:00
|
|
|
pkg_folder = script.site_packages / 'symlinks'
|
2014-01-28 15:17:51 +01:00
|
|
|
egg_info_folder = (
|
2014-11-19 23:05:14 +01:00
|
|
|
script.site_packages / 'symlinks-0.1.dev0-py%s.egg-info' % pyversion
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2013-11-10 00:57:34 +01:00
|
|
|
assert pkg_folder in result.files_created, str(result.stdout)
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_install_from_local_directory_with_no_setup_py(script, data):
|
2010-04-13 18:12:50 +02:00
|
|
|
"""
|
|
|
|
Test installing from a local directory with no 'setup.py'.
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
result = script.pip('install', data.root, expect_error=True)
|
2014-08-31 01:52:28 +02:00
|
|
|
assert not result.files_created
|
2015-03-16 13:34:52 +01:00
|
|
|
assert "is not installable. File 'setup.py' not found." in result.stderr
|
2010-04-13 18:12:50 +02:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_editable_install_from_local_directory_with_no_setup_py(script, data):
|
2012-05-31 14:49:19 +02:00
|
|
|
"""
|
|
|
|
Test installing from a local directory with no 'setup.py'.
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
result = script.pip('install', '-e', data.root, expect_error=True)
|
2014-08-31 01:52:28 +02:00
|
|
|
assert not result.files_created
|
2015-03-16 13:34:52 +01:00
|
|
|
assert "is not installable. File 'setup.py' not found." in result.stderr
|
2012-05-31 14:49:19 +02:00
|
|
|
|
|
|
|
|
2017-03-18 19:42:32 +01:00
|
|
|
@pytest.mark.skipif("sys.version_info >= (3,4)")
|
2016-01-21 15:08:36 +01:00
|
|
|
@pytest.mark.xfail
|
2017-10-02 19:33:52 +02:00
|
|
|
def test_install_argparse_shadowed(script):
|
2016-01-20 21:26:06 +01:00
|
|
|
# When argparse is in the stdlib, we support installing it
|
2016-06-10 21:27:07 +02:00
|
|
|
# even though that's pretty useless because older packages did need to
|
2016-01-20 21:26:06 +01:00
|
|
|
# depend on it, and not having its metadata will cause pkg_resources
|
|
|
|
# requirements checks to fail // trigger easy-install, both of which are
|
|
|
|
# bad.
|
|
|
|
# XXX: Note, this test hits the outside-environment check, not the
|
|
|
|
# in-stdlib check, because our tests run in virtualenvs...
|
|
|
|
result = script.pip('install', 'argparse>=1.4')
|
|
|
|
assert "Not uninstalling argparse" in result.stdout
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif("sys.version_info < (3,4)")
|
2017-10-02 19:33:52 +02:00
|
|
|
def test_upgrade_argparse_shadowed(script):
|
2016-01-20 21:26:06 +01:00
|
|
|
# If argparse is installed - even if shadowed for imported - we support
|
|
|
|
# upgrading it and properly remove the older versions files.
|
|
|
|
script.pip('install', 'argparse==1.3')
|
|
|
|
result = script.pip('install', 'argparse>=1.4')
|
|
|
|
assert "Not uninstalling argparse" not in result.stdout
|
|
|
|
|
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_install_curdir(script, data):
|
2010-04-10 11:57:49 +02:00
|
|
|
"""
|
|
|
|
Test installing current directory ('.').
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
run_from = data.packages.join("FSPkg")
|
2011-03-23 06:08:14 +01:00
|
|
|
# Python 2.4 Windows balks if this exists already
|
|
|
|
egg_info = join(run_from, "FSPkg.egg-info")
|
|
|
|
if os.path.isdir(egg_info):
|
|
|
|
rmtree(egg_info)
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('install', curdir, cwd=run_from, expect_error=False)
|
2014-02-24 22:52:23 +01:00
|
|
|
fspkg_folder = script.site_packages / 'fspkg'
|
2014-01-28 15:17:51 +01:00
|
|
|
egg_info_folder = (
|
2014-11-19 23:05:14 +01:00
|
|
|
script.site_packages / 'FSPkg-0.1.dev0-py%s.egg-info' % pyversion
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2010-06-09 01:09:37 +02:00
|
|
|
assert fspkg_folder in result.files_created, str(result.stdout)
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
2010-04-10 11:57:49 +02:00
|
|
|
|
2010-08-19 17:40:21 +02:00
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_install_pardir(script, data):
|
2010-04-10 11:57:49 +02:00
|
|
|
"""
|
|
|
|
Test installing parent directory ('..').
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
run_from = data.packages.join("FSPkg", "fspkg")
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('install', pardir, cwd=run_from, expect_error=False)
|
2014-02-24 22:52:23 +01:00
|
|
|
fspkg_folder = script.site_packages / 'fspkg'
|
2014-01-28 15:17:51 +01:00
|
|
|
egg_info_folder = (
|
2014-11-19 23:05:14 +01:00
|
|
|
script.site_packages / 'FSPkg-0.1.dev0-py%s.egg-info' % pyversion
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2010-06-09 01:09:37 +02:00
|
|
|
assert fspkg_folder in result.files_created, str(result.stdout)
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
2010-05-30 14:39:11 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_install_global_option(script):
|
2010-05-30 14:39:11 +02:00
|
|
|
"""
|
2010-06-09 01:09:37 +02:00
|
|
|
Test using global distutils options.
|
|
|
|
(In particular those that disable the actual install action)
|
2010-05-30 14:39:11 +02:00
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--global-option=--version', "INITools==0.1",
|
2015-04-22 01:53:05 +02:00
|
|
|
expect_stderr=True)
|
2010-05-30 14:39:11 +02:00
|
|
|
assert '0.1\n' in result.stdout
|
2010-08-06 17:41:49 +02:00
|
|
|
|
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_install_with_pax_header(script, data):
|
2010-09-07 19:26:13 +02:00
|
|
|
"""
|
|
|
|
test installing from a tarball with pax header for python<2.6
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
script.pip('install', 'paxpkg.tar.bz2', cwd=data.packages)
|
2010-09-07 19:26:13 +02:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_install_with_hacked_egg_info(script, data):
|
2012-06-25 17:47:12 +02:00
|
|
|
"""
|
|
|
|
test installing a package which defines its own egg_info class
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
run_from = data.packages.join("HackedEggInfo")
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('install', '.', cwd=run_from)
|
2014-12-23 12:14:35 +01:00
|
|
|
assert 'Successfully installed hackedegginfo-0.0.0\n' in result.stdout
|
2012-06-25 17:47:12 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_install_using_install_option_and_editable(script, tmpdir):
|
2010-08-19 03:29:36 +02:00
|
|
|
"""
|
|
|
|
Test installing a tool using -e and --install-option
|
|
|
|
"""
|
2010-08-19 04:11:08 +02:00
|
|
|
folder = 'script_folder'
|
2013-08-21 11:16:07 +02:00
|
|
|
script.scratch_path.join(folder).mkdir()
|
2014-04-16 01:55:45 +02:00
|
|
|
url = 'git+git://github.com/pypa/pip-test-package'
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
2014-04-16 01:55:45 +02:00
|
|
|
'install', '-e', '%s#egg=pip-test-package' %
|
2014-01-28 15:17:51 +01:00
|
|
|
local_checkout(url, tmpdir.join("cache")),
|
2015-04-22 01:53:05 +02:00
|
|
|
'--install-option=--script-dir=%s' % folder,
|
|
|
|
expect_stderr=True)
|
2014-04-16 01:55:45 +02:00
|
|
|
script_file = (
|
|
|
|
script.venv / 'src' / 'pip-test-package' /
|
|
|
|
folder / 'pip-test-package' + script.exe
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2014-04-16 01:55:45 +02:00
|
|
|
assert script_file in result.files_created
|
2010-08-19 03:29:36 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_install_global_option_using_editable(script, tmpdir):
|
2010-08-19 03:29:36 +02:00
|
|
|
"""
|
|
|
|
Test using global distutils options, but in an editable installation
|
|
|
|
"""
|
2011-03-19 04:19:22 +01:00
|
|
|
url = 'hg+http://bitbucket.org/runeh/anyjson'
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--global-option=--version', '-e',
|
2015-04-22 01:53:05 +02:00
|
|
|
'%s@0.2.5#egg=anyjson' % local_checkout(url, tmpdir.join("cache")),
|
|
|
|
expect_stderr=True)
|
2015-03-05 21:59:59 +01:00
|
|
|
assert 'Successfully installed anyjson' in result.stdout
|
2010-08-19 03:29:36 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_install_package_with_same_name_in_curdir(script):
|
2010-08-06 17:41:49 +02:00
|
|
|
"""
|
|
|
|
Test installing a package with the same name of a local folder
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
script.scratch_path.join("mock==0.6").mkdir()
|
|
|
|
result = script.pip('install', 'mock==0.6')
|
|
|
|
egg_folder = script.site_packages / 'mock-0.6.0-py%s.egg-info' % pyversion
|
2010-08-06 17:41:49 +02:00
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
|
|
|
mock100_setup_py = textwrap.dedent('''\
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='mock',
|
|
|
|
version='100.1')''')
|
|
|
|
|
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_install_folder_using_dot_slash(script):
|
2010-08-06 17:41:49 +02:00
|
|
|
"""
|
|
|
|
Test installing a folder using pip install ./foldername
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
script.scratch_path.join("mock").mkdir()
|
2014-02-24 22:52:23 +01:00
|
|
|
pkg_path = script.scratch_path / 'mock'
|
2013-08-21 11:16:07 +02:00
|
|
|
pkg_path.join("setup.py").write(mock100_setup_py)
|
|
|
|
result = script.pip('install', './mock')
|
|
|
|
egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
|
2010-08-06 17:41:49 +02:00
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_install_folder_using_slash_in_the_end(script):
|
2010-08-06 20:05:00 +02:00
|
|
|
r"""
|
|
|
|
Test installing a folder using pip install foldername/ or foldername\
|
2010-08-06 17:41:49 +02:00
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
script.scratch_path.join("mock").mkdir()
|
2014-02-24 22:52:23 +01:00
|
|
|
pkg_path = script.scratch_path / 'mock'
|
2013-08-21 11:16:07 +02:00
|
|
|
pkg_path.join("setup.py").write(mock100_setup_py)
|
|
|
|
result = script.pip('install', 'mock' + os.path.sep)
|
|
|
|
egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
|
2010-08-06 17:41:49 +02:00
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_install_folder_using_relative_path(script):
|
2010-08-06 17:41:49 +02:00
|
|
|
"""
|
|
|
|
Test installing a folder using pip install folder1/folder2
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
script.scratch_path.join("initools").mkdir()
|
|
|
|
script.scratch_path.join("initools", "mock").mkdir()
|
2014-02-24 22:52:23 +01:00
|
|
|
pkg_path = script.scratch_path / 'initools' / 'mock'
|
2013-08-21 11:16:07 +02:00
|
|
|
pkg_path.join("setup.py").write(mock100_setup_py)
|
2014-02-24 22:52:23 +01:00
|
|
|
result = script.pip('install', Path('initools') / 'mock')
|
2013-08-21 11:16:07 +02:00
|
|
|
egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
|
2010-08-06 17:41:49 +02:00
|
|
|
assert egg_folder in result.files_created, str(result)
|
2010-12-09 04:15:53 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_install_package_which_contains_dev_in_name(script):
|
2010-12-09 04:15:53 +01:00
|
|
|
"""
|
2011-03-19 04:19:22 +01:00
|
|
|
Test installing package from pypi which contains 'dev' in name
|
2010-12-09 04:15:53 +01:00
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('install', 'django-devserver==0.0.4')
|
2014-02-24 22:52:23 +01:00
|
|
|
devserver_folder = script.site_packages / 'devserver'
|
2014-01-28 15:17:51 +01:00
|
|
|
egg_info_folder = (
|
2014-02-24 22:52:23 +01:00
|
|
|
script.site_packages / 'django_devserver-0.0.4-py%s.egg-info' %
|
|
|
|
pyversion
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2010-12-09 04:15:53 +01:00
|
|
|
assert devserver_folder in result.files_created, str(result.stdout)
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
2011-03-14 23:07:12 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_install_package_with_target(script):
|
2012-02-03 13:31:28 +01:00
|
|
|
"""
|
|
|
|
Test installing a package using pip install --target
|
|
|
|
"""
|
2014-02-24 22:52:23 +01:00
|
|
|
target_dir = script.scratch_path / 'target'
|
2015-03-19 21:49:58 +01:00
|
|
|
result = script.pip_install_local('-t', target_dir, "simple==1.0")
|
|
|
|
assert Path('scratch') / 'target' / 'simple' in result.files_created, (
|
2014-01-28 15:17:51 +01:00
|
|
|
str(result)
|
|
|
|
)
|
2012-02-03 13:31:28 +01:00
|
|
|
|
2014-08-31 02:15:32 +02:00
|
|
|
# Test repeated call without --upgrade, no files should have changed
|
2015-03-16 13:34:52 +01:00
|
|
|
result = script.pip_install_local(
|
|
|
|
'-t', target_dir, "simple==1.0", expect_stderr=True,
|
|
|
|
)
|
2015-03-19 21:49:58 +01:00
|
|
|
assert not Path('scratch') / 'target' / 'simple' in result.files_updated
|
2014-08-31 02:15:32 +02:00
|
|
|
|
|
|
|
# Test upgrade call, check that new version is installed
|
2015-03-19 21:49:58 +01:00
|
|
|
result = script.pip_install_local('--upgrade', '-t',
|
|
|
|
target_dir, "simple==2.0")
|
|
|
|
assert Path('scratch') / 'target' / 'simple' in result.files_updated, (
|
2014-08-31 02:15:32 +02:00
|
|
|
str(result)
|
|
|
|
)
|
2014-08-31 03:25:03 +02:00
|
|
|
egg_folder = (
|
2015-03-19 21:49:58 +01:00
|
|
|
Path('scratch') / 'target' / 'simple-2.0-py%s.egg-info' % pyversion)
|
2014-08-31 03:25:03 +02:00
|
|
|
assert egg_folder in result.files_created, (
|
2014-08-31 02:15:32 +02:00
|
|
|
str(result)
|
|
|
|
)
|
|
|
|
|
2014-08-31 18:11:27 +02:00
|
|
|
# Test install and upgrade of single-module package
|
2015-03-19 21:49:58 +01:00
|
|
|
result = script.pip_install_local('-t', target_dir, 'singlemodule==0.0.0')
|
|
|
|
singlemodule_py = Path('scratch') / 'target' / 'singlemodule.py'
|
|
|
|
assert singlemodule_py in result.files_created, str(result)
|
2014-08-31 18:11:27 +02:00
|
|
|
|
2015-03-19 21:49:58 +01:00
|
|
|
result = script.pip_install_local('-t', target_dir, 'singlemodule==0.0.1',
|
|
|
|
'--upgrade')
|
|
|
|
assert singlemodule_py in result.files_updated, str(result)
|
2014-08-31 18:11:27 +02:00
|
|
|
|
2012-02-03 13:31:28 +01:00
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_install_package_with_root(script, data):
|
2012-10-02 05:55:56 +02:00
|
|
|
"""
|
|
|
|
Test installing a package using pip install --root
|
|
|
|
"""
|
2014-02-24 22:52:23 +01:00
|
|
|
root_dir = script.scratch_path / 'root'
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--root', root_dir, '-f', data.find_links, '--no-index',
|
|
|
|
'simple==1.0',
|
|
|
|
)
|
|
|
|
normal_install_path = (
|
|
|
|
script.base_path / script.site_packages / 'simple-1.0-py%s.egg-info' %
|
|
|
|
pyversion
|
|
|
|
)
|
|
|
|
# use distutils to change the root exactly how the --root option does it
|
2013-02-14 04:17:28 +01:00
|
|
|
from distutils.util import change_root
|
2014-01-28 15:17:51 +01:00
|
|
|
root_path = change_root(
|
|
|
|
os.path.join(script.scratch, 'root'),
|
|
|
|
normal_install_path
|
|
|
|
)
|
2013-02-14 04:17:28 +01:00
|
|
|
assert root_path in result.files_created, str(result)
|
2012-10-02 05:55:56 +02:00
|
|
|
|
2017-06-26 22:45:47 +02:00
|
|
|
# Should show find-links location in output
|
|
|
|
assert "Looking in indexes: " not in result.stdout
|
|
|
|
assert "Looking in links: " in result.stdout
|
|
|
|
|
2012-10-02 05:55:56 +02:00
|
|
|
|
2015-11-19 16:32:02 +01:00
|
|
|
def test_install_package_with_prefix(script, data):
|
|
|
|
"""
|
|
|
|
Test installing a package using pip install --prefix
|
|
|
|
"""
|
|
|
|
prefix_path = script.scratch_path / 'prefix'
|
|
|
|
result = script.pip(
|
|
|
|
'install', '--prefix', prefix_path, '-f', data.find_links,
|
2015-11-23 18:36:57 +01:00
|
|
|
'--no-binary', 'simple', '--no-index', 'simple==1.0',
|
2015-11-19 16:32:02 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
if hasattr(sys, "pypy_version_info"):
|
|
|
|
path = script.scratch / 'prefix'
|
|
|
|
else:
|
|
|
|
path = script.scratch / 'prefix' / 'lib' / 'python{0}'.format(pyversion) # noqa
|
|
|
|
install_path = (
|
|
|
|
path / 'site-packages' / 'simple-1.0-py{0}.egg-info'.format(pyversion)
|
|
|
|
)
|
|
|
|
assert install_path in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2015-11-23 18:36:57 +01:00
|
|
|
def test_install_editable_with_prefix(script):
|
|
|
|
# make a dummy project
|
|
|
|
pkga_path = script.scratch_path / 'pkga'
|
|
|
|
pkga_path.mkdir()
|
|
|
|
pkga_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkga',
|
|
|
|
version='0.1')
|
|
|
|
"""))
|
|
|
|
|
|
|
|
site_packages = os.path.join(
|
|
|
|
'prefix', 'lib', 'python{0}'.format(pyversion), 'site-packages')
|
|
|
|
|
|
|
|
# make sure target path is in PYTHONPATH
|
|
|
|
pythonpath = script.scratch_path / site_packages
|
|
|
|
pythonpath.makedirs()
|
|
|
|
script.environ["PYTHONPATH"] = pythonpath
|
|
|
|
|
|
|
|
# install pkga package into the absolute prefix directory
|
|
|
|
prefix_path = script.scratch_path / 'prefix'
|
|
|
|
result = script.pip(
|
|
|
|
'install', '--editable', pkga_path, '--prefix', prefix_path)
|
|
|
|
|
|
|
|
# assert pkga is installed at correct location
|
|
|
|
install_path = script.scratch / site_packages / 'pkga.egg-link'
|
|
|
|
assert install_path in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2015-11-19 16:32:02 +01:00
|
|
|
def test_install_package_conflict_prefix_and_user(script, data):
|
|
|
|
"""
|
|
|
|
Test installing a package using pip install --prefix --user errors out
|
|
|
|
"""
|
|
|
|
prefix_path = script.scratch_path / 'prefix'
|
|
|
|
result = script.pip(
|
|
|
|
'install', '-f', data.find_links, '--no-index', '--user',
|
|
|
|
'--prefix', prefix_path, 'simple==1.0',
|
|
|
|
expect_error=True, quiet=True,
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
"Can not combine '--user' and '--prefix'" in result.stderr
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2013-08-18 11:59:44 +02:00
|
|
|
# skip on win/py3 for now, see issue #782
|
|
|
|
@pytest.mark.skipif("sys.platform == 'win32' and sys.version_info >= (3,)")
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_install_package_that_emits_unicode(script, data):
|
2011-04-28 06:01:08 +02:00
|
|
|
"""
|
2013-05-28 23:58:08 +02:00
|
|
|
Install a package with a setup.py that emits UTF-8 output and then fails.
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2013-05-28 23:58:08 +02:00
|
|
|
Refs https://github.com/pypa/pip/issues/326
|
2011-04-21 16:14:24 +02:00
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
to_install = data.packages.join("BrokenEmitsUTF8")
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', to_install, expect_error=True, expect_temp=True, quiet=True,
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
'FakeError: this package designed to fail on install' in result.stdout
|
|
|
|
)
|
2013-05-28 23:58:08 +02:00
|
|
|
assert 'UnicodeDecodeError' not in result.stdout
|
2011-04-26 14:35:17 +02:00
|
|
|
|
2014-01-28 15:17:51 +01:00
|
|
|
|
2013-12-01 05:38:41 +01:00
|
|
|
def test_install_package_with_utf8_setup(script, data):
|
|
|
|
"""Install a package with a setup.py that declares a utf-8 encoding."""
|
|
|
|
to_install = data.packages.join("SetupPyUTF8")
|
|
|
|
script.pip('install', to_install)
|
|
|
|
|
2014-01-28 15:17:51 +01:00
|
|
|
|
2013-12-01 05:38:41 +01:00
|
|
|
def test_install_package_with_latin1_setup(script, data):
|
|
|
|
"""Install a package with a setup.py that declares a latin-1 encoding."""
|
|
|
|
to_install = data.packages.join("SetupPyLatin1")
|
|
|
|
script.pip('install', to_install)
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2014-01-28 15:17:51 +01:00
|
|
|
|
2014-04-30 02:55:12 +02:00
|
|
|
def test_url_req_case_mismatch_no_index(script, data):
|
2011-04-26 14:35:17 +02:00
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
tar ball url requirements (with no egg fragment), that happen to have upper
|
|
|
|
case project names, should be considered equal to later requirements that
|
|
|
|
reference the project name using lower case.
|
2011-04-26 14:35:17 +02:00
|
|
|
|
2015-03-18 02:25:41 +01:00
|
|
|
tests/data/packages contains Upper-1.0.tar.gz and Upper-2.0.tar.gz
|
2013-05-28 23:58:08 +02:00
|
|
|
'requiresupper' has install_requires = ['upper']
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
Upper = os.path.join(data.find_links, 'Upper-1.0.tar.gz')
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--no-index', '-f', data.find_links, Upper, 'requiresupper'
|
|
|
|
)
|
2011-04-28 07:53:48 +02:00
|
|
|
|
2014-03-26 23:24:19 +01:00
|
|
|
# only Upper-1.0.tar.gz should get installed.
|
2013-08-21 11:16:07 +02:00
|
|
|
egg_folder = script.site_packages / 'Upper-1.0-py%s.egg-info' % pyversion
|
2013-05-28 23:58:08 +02:00
|
|
|
assert egg_folder in result.files_created, str(result)
|
2013-08-21 11:16:07 +02:00
|
|
|
egg_folder = script.site_packages / 'Upper-2.0-py%s.egg-info' % pyversion
|
2013-05-28 23:58:08 +02:00
|
|
|
assert egg_folder not in result.files_created, str(result)
|
2013-11-22 03:59:31 +01:00
|
|
|
|
|
|
|
|
2014-04-30 02:55:12 +02:00
|
|
|
def test_url_req_case_mismatch_file_index(script, data):
|
|
|
|
"""
|
|
|
|
tar ball url requirements (with no egg fragment), that happen to have upper
|
|
|
|
case project names, should be considered equal to later requirements that
|
|
|
|
reference the project name using lower case.
|
|
|
|
|
2015-03-18 02:25:41 +01:00
|
|
|
tests/data/packages3 contains Dinner-1.0.tar.gz and Dinner-2.0.tar.gz
|
2014-04-30 02:55:12 +02:00
|
|
|
'requiredinner' has install_requires = ['dinner']
|
|
|
|
|
|
|
|
This test is similar to test_url_req_case_mismatch_no_index; that test
|
|
|
|
tests behaviour when using "--no-index -f", while this one does the same
|
|
|
|
test when using "--index-url". Unfortunately this requires a different
|
|
|
|
set of packages as it requires a prepared index.html file and
|
|
|
|
subdirectory-per-package structure.
|
|
|
|
"""
|
2015-09-03 14:15:03 +02:00
|
|
|
Dinner = os.path.join(data.find_links3, 'dinner', 'Dinner-1.0.tar.gz')
|
2014-04-30 02:55:12 +02:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--index-url', data.find_links3, Dinner, 'requiredinner'
|
|
|
|
)
|
|
|
|
|
|
|
|
# only Upper-1.0.tar.gz should get installed.
|
|
|
|
egg_folder = script.site_packages / 'Dinner-1.0-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
egg_folder = script.site_packages / 'Dinner-2.0-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder not in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
|
|
|
def test_url_incorrect_case_no_index(script, data):
|
|
|
|
"""
|
|
|
|
Same as test_url_req_case_mismatch_no_index, except testing for the case
|
|
|
|
where the incorrect case is given in the name of the package to install
|
|
|
|
rather than in a requirements file.
|
|
|
|
"""
|
|
|
|
result = script.pip(
|
|
|
|
'install', '--no-index', '-f', data.find_links, "upper",
|
|
|
|
)
|
|
|
|
|
|
|
|
# only Upper-2.0.tar.gz should get installed.
|
|
|
|
egg_folder = script.site_packages / 'Upper-1.0-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder not in result.files_created, str(result)
|
|
|
|
egg_folder = script.site_packages / 'Upper-2.0-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
|
|
|
def test_url_incorrect_case_file_index(script, data):
|
|
|
|
"""
|
|
|
|
Same as test_url_req_case_mismatch_file_index, except testing for the case
|
|
|
|
where the incorrect case is given in the name of the package to install
|
|
|
|
rather than in a requirements file.
|
|
|
|
"""
|
|
|
|
result = script.pip(
|
|
|
|
'install', '--index-url', data.find_links3, "dinner",
|
2015-03-16 13:34:52 +01:00
|
|
|
expect_stderr=True,
|
2014-04-30 02:55:12 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# only Upper-2.0.tar.gz should get installed.
|
|
|
|
egg_folder = script.site_packages / 'Dinner-1.0-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder not in result.files_created, str(result)
|
|
|
|
egg_folder = script.site_packages / 'Dinner-2.0-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
|
2017-06-26 22:45:47 +02:00
|
|
|
# Should show index-url location in output
|
|
|
|
assert "Looking in indexes: " in result.stdout
|
|
|
|
assert "Looking in links: " not in result.stdout
|
|
|
|
|
2014-04-30 02:55:12 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-11-22 03:59:31 +01:00
|
|
|
def test_compiles_pyc(script):
|
|
|
|
"""
|
|
|
|
Test installing with --compile on
|
|
|
|
"""
|
|
|
|
del script.environ["PYTHONDONTWRITEBYTECODE"]
|
2015-04-17 05:03:34 +02:00
|
|
|
script.pip("install", "--compile", "--no-binary=:all:", "INITools==0.2")
|
2013-11-22 03:59:31 +01:00
|
|
|
|
|
|
|
# There are many locations for the __init__.pyc file so attempt to find
|
|
|
|
# any of them
|
|
|
|
exists = [
|
2014-02-24 22:52:23 +01:00
|
|
|
os.path.exists(script.site_packages_path / "initools/__init__.pyc"),
|
2013-11-22 03:59:31 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
exists += glob.glob(
|
2014-02-24 22:52:23 +01:00
|
|
|
script.site_packages_path / "initools/__pycache__/__init__*.pyc"
|
2013-11-22 03:59:31 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
assert any(exists)
|
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2017-10-02 19:33:52 +02:00
|
|
|
def test_no_compiles_pyc(script):
|
2013-11-22 03:59:31 +01:00
|
|
|
"""
|
|
|
|
Test installing from wheel with --compile on
|
|
|
|
"""
|
|
|
|
del script.environ["PYTHONDONTWRITEBYTECODE"]
|
2015-04-17 05:03:34 +02:00
|
|
|
script.pip("install", "--no-compile", "--no-binary=:all:", "INITools==0.2")
|
2013-11-22 03:59:31 +01:00
|
|
|
|
|
|
|
# There are many locations for the __init__.pyc file so attempt to find
|
|
|
|
# any of them
|
|
|
|
exists = [
|
2014-02-24 22:52:23 +01:00
|
|
|
os.path.exists(script.site_packages_path / "initools/__init__.pyc"),
|
2013-11-22 03:59:31 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
exists += glob.glob(
|
2014-02-24 22:52:23 +01:00
|
|
|
script.site_packages_path / "initools/__pycache__/__init__*.pyc"
|
2013-11-22 03:59:31 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
assert not any(exists)
|
2015-03-13 09:52:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_install_upgrade_editable_depending_on_other_editable(script):
|
|
|
|
script.scratch_path.join("pkga").mkdir()
|
|
|
|
pkga_path = script.scratch_path / 'pkga'
|
|
|
|
pkga_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkga',
|
|
|
|
version='0.1')
|
|
|
|
"""))
|
|
|
|
script.pip('install', '--editable', pkga_path)
|
2016-05-14 13:03:53 +02:00
|
|
|
result = script.pip('list', '--format=freeze')
|
|
|
|
assert "pkga==0.1" in result.stdout
|
2015-03-13 09:52:50 +01:00
|
|
|
|
|
|
|
script.scratch_path.join("pkgb").mkdir()
|
|
|
|
pkgb_path = script.scratch_path / 'pkgb'
|
|
|
|
pkgb_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkgb',
|
|
|
|
version='0.1',
|
|
|
|
install_requires=['pkga'])
|
|
|
|
"""))
|
2016-05-14 13:03:53 +02:00
|
|
|
script.pip('install', '--upgrade', '--editable', pkgb_path, '--no-index')
|
|
|
|
result = script.pip('list', '--format=freeze')
|
|
|
|
assert "pkgb==0.1" in result.stdout
|
2015-03-25 01:53:10 +01:00
|
|
|
|
2016-02-23 02:15:14 +01:00
|
|
|
|
|
|
|
def test_install_subprocess_output_handling(script, data):
|
|
|
|
args = ['install', data.src.join('chattymodule')]
|
|
|
|
|
|
|
|
# Regular install should not show output from the chatty setup.py
|
|
|
|
result = script.pip(*args)
|
|
|
|
assert 0 == result.stdout.count("HELLO FROM CHATTYMODULE")
|
|
|
|
script.pip("uninstall", "-y", "chattymodule")
|
|
|
|
|
|
|
|
# With --verbose we should show the output.
|
|
|
|
# Only count examples with sys.argv[1] == egg_info, because we call
|
|
|
|
# setup.py multiple times, which should not count as duplicate output.
|
|
|
|
result = script.pip(*(args + ["--verbose"]))
|
|
|
|
assert 1 == result.stdout.count("HELLO FROM CHATTYMODULE egg_info")
|
|
|
|
script.pip("uninstall", "-y", "chattymodule")
|
|
|
|
|
|
|
|
# If the install fails, then we *should* show the output... but only once,
|
|
|
|
# even if --verbose is given.
|
|
|
|
result = script.pip(*(args + ["--global-option=--fail"]),
|
|
|
|
expect_error=True)
|
|
|
|
assert 1 == result.stdout.count("I DIE, I DIE")
|
|
|
|
|
|
|
|
result = script.pip(*(args + ["--global-option=--fail", "--verbose"]),
|
|
|
|
expect_error=True)
|
|
|
|
assert 1 == result.stdout.count("I DIE, I DIE")
|
|
|
|
|
2016-05-11 01:05:42 +02:00
|
|
|
|
|
|
|
def test_install_log(script, data, tmpdir):
|
|
|
|
# test that verbose logs go to "--log" file
|
|
|
|
f = tmpdir.join("log.txt")
|
|
|
|
args = ['--log=%s' % f,
|
|
|
|
'install', data.src.join('chattymodule')]
|
|
|
|
result = script.pip(*args)
|
|
|
|
assert 0 == result.stdout.count("HELLO FROM CHATTYMODULE")
|
|
|
|
with open(f, 'r') as fp:
|
|
|
|
# one from egg_info, one from install
|
|
|
|
assert 2 == fp.read().count("HELLO FROM CHATTYMODULE")
|
|
|
|
|
2015-03-25 01:53:10 +01:00
|
|
|
|
|
|
|
def test_install_topological_sort(script, data):
|
2016-12-04 17:30:31 +01:00
|
|
|
args = ['install', 'TopoRequires4', '--no-index', '-f', data.packages]
|
2015-03-25 01:53:10 +01:00
|
|
|
res = str(script.pip(*args, expect_error=False))
|
|
|
|
order1 = 'TopoRequires, TopoRequires2, TopoRequires3, TopoRequires4'
|
|
|
|
order2 = 'TopoRequires, TopoRequires3, TopoRequires2, TopoRequires4'
|
|
|
|
assert order1 in res or order2 in res, res
|
2015-03-31 02:52:08 +02:00
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_wheel_broken(script, data, common_wheels):
|
|
|
|
script.pip('install', 'wheel', '--no-index', '-f', common_wheels)
|
2015-03-31 02:52:08 +02:00
|
|
|
res = script.pip(
|
2017-05-14 00:23:17 +02:00
|
|
|
'install', '--no-index', '-f', data.find_links, '-f', common_wheels,
|
|
|
|
'wheelbroken',
|
2015-04-01 03:39:45 +02:00
|
|
|
expect_stderr=True)
|
2015-03-31 02:52:08 +02:00
|
|
|
assert "Successfully installed wheelbroken-0.1" in str(res), str(res)
|
2015-04-01 03:39:45 +02:00
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_cleanup_after_failed_wheel(script, data, common_wheels):
|
|
|
|
script.pip('install', 'wheel', '--no-index', '-f', common_wheels)
|
2015-09-09 21:12:04 +02:00
|
|
|
res = script.pip(
|
2017-05-14 00:23:17 +02:00
|
|
|
'install', '--no-index', '-f', data.find_links, '-f', common_wheels,
|
|
|
|
'wheelbrokenafter',
|
2015-09-09 21:12:04 +02:00
|
|
|
expect_stderr=True)
|
|
|
|
# One of the effects of not cleaning up is broken scripts:
|
|
|
|
script_py = script.bin_path / "script.py"
|
|
|
|
assert script_py.exists, script_py
|
|
|
|
shebang = open(script_py, 'r').readline().strip()
|
|
|
|
assert shebang != '#!python', shebang
|
|
|
|
# OK, assert that we *said* we were cleaning up:
|
|
|
|
assert "Running setup.py clean for wheelbrokenafter" in str(res), str(res)
|
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_builds_wheels(script, data, common_wheels):
|
2015-04-01 03:39:45 +02:00
|
|
|
# NB This incidentally tests a local tree + tarball inputs
|
|
|
|
# see test_install_editable_from_git_autobuild_wheel for editable
|
|
|
|
# vcs coverage.
|
2017-05-14 00:23:17 +02:00
|
|
|
script.pip('install', 'wheel', '--no-index', '-f', common_wheels)
|
2015-04-01 03:39:45 +02:00
|
|
|
to_install = data.packages.join('requires_wheelbroken_upper')
|
|
|
|
res = script.pip(
|
2017-05-14 00:23:17 +02:00
|
|
|
'install', '--no-index', '-f', data.find_links, '-f', common_wheels,
|
2015-04-01 03:39:45 +02:00
|
|
|
to_install, expect_stderr=True)
|
|
|
|
expected = ("Successfully installed requires-wheelbroken-upper-0"
|
|
|
|
" upper-2.0 wheelbroken-0.1")
|
|
|
|
# Must have installed it all
|
|
|
|
assert expected in str(res), str(res)
|
|
|
|
root = appdirs.user_cache_dir('pip')
|
|
|
|
wheels = []
|
2015-11-04 14:11:13 +01:00
|
|
|
for top, dirs, files in os.walk(os.path.join(root, "wheels")):
|
2015-04-01 03:39:45 +02:00
|
|
|
wheels.extend(files)
|
|
|
|
# and built wheels for upper and wheelbroken
|
|
|
|
assert "Running setup.py bdist_wheel for upper" in str(res), str(res)
|
|
|
|
assert "Running setup.py bdist_wheel for wheelb" in str(res), str(res)
|
2017-05-19 20:10:32 +02:00
|
|
|
# Wheels are built for local directories, but not cached.
|
|
|
|
assert "Running setup.py bdist_wheel for requir" in str(res), str(res)
|
2015-04-01 03:39:45 +02:00
|
|
|
# wheelbroken has to run install
|
|
|
|
# into the cache
|
|
|
|
assert wheels != [], str(res)
|
|
|
|
# and installed from the wheel
|
|
|
|
assert "Running setup.py install for upper" not in str(res), str(res)
|
2017-05-19 20:10:32 +02:00
|
|
|
# Wheels are built for local directories, but not cached.
|
|
|
|
assert "Running setup.py install for requir" not in str(res), str(res)
|
2015-04-01 03:39:45 +02:00
|
|
|
# wheelbroken has to run install
|
|
|
|
assert "Running setup.py install for wheelb" in str(res), str(res)
|
2015-11-04 14:11:13 +01:00
|
|
|
# We want to make sure we used the correct implementation tag
|
|
|
|
assert wheels == [
|
|
|
|
"Upper-2.0-{0}-none-any.whl".format(pep425tags.implementation_tag),
|
|
|
|
]
|
2015-04-17 05:03:34 +02:00
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_no_binary_disables_building_wheels(
|
|
|
|
script, data, common_wheels):
|
|
|
|
script.pip('install', 'wheel', '--no-index', '-f', common_wheels)
|
2015-04-17 05:03:34 +02:00
|
|
|
to_install = data.packages.join('requires_wheelbroken_upper')
|
|
|
|
res = script.pip(
|
|
|
|
'install', '--no-index', '--no-binary=upper', '-f', data.find_links,
|
2017-05-14 00:23:17 +02:00
|
|
|
'-f', common_wheels,
|
2015-04-17 05:03:34 +02:00
|
|
|
to_install, expect_stderr=True)
|
|
|
|
expected = ("Successfully installed requires-wheelbroken-upper-0"
|
|
|
|
" upper-2.0 wheelbroken-0.1")
|
|
|
|
# Must have installed it all
|
|
|
|
assert expected in str(res), str(res)
|
|
|
|
# and built wheels for wheelbroken only
|
|
|
|
assert "Running setup.py bdist_wheel for wheelb" in str(res), str(res)
|
2017-05-19 20:12:28 +02:00
|
|
|
# Wheels are built for local directories, but not cached
|
|
|
|
assert "Running setup.py bdist_wheel for requir" in str(res), str(res)
|
2015-04-17 05:03:34 +02:00
|
|
|
# Nor upper, which was blacklisted
|
|
|
|
assert "Running setup.py bdist_wheel for upper" not in str(res), str(res)
|
|
|
|
# wheelbroken has to run install
|
|
|
|
# into the cache
|
|
|
|
assert wheels != [], str(res)
|
2017-05-19 20:12:28 +02:00
|
|
|
# Wheels are built for local directories, but not cached
|
2017-10-04 13:28:31 +02:00
|
|
|
assert "Running setup.py install for requires-wheel" not in str(res), str(res)
|
2015-04-17 05:03:34 +02:00
|
|
|
# And these two fell back to sdist based installed.
|
|
|
|
assert "Running setup.py install for wheelb" in str(res), str(res)
|
|
|
|
assert "Running setup.py install for upper" in str(res), str(res)
|
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_no_binary_disables_cached_wheels(script, data, common_wheels):
|
|
|
|
script.pip('install', 'wheel', '--no-index', '-f', common_wheels)
|
2015-04-17 05:03:34 +02:00
|
|
|
# Seed the cache
|
|
|
|
script.pip(
|
2017-05-14 00:23:17 +02:00
|
|
|
'install', '--no-index', '-f', data.find_links, '-f', common_wheels,
|
2015-04-17 05:03:34 +02:00
|
|
|
'upper')
|
|
|
|
script.pip('uninstall', 'upper', '-y')
|
|
|
|
res = script.pip(
|
|
|
|
'install', '--no-index', '--no-binary=:all:', '-f', data.find_links,
|
|
|
|
'upper', expect_stderr=True)
|
|
|
|
assert "Successfully installed upper-2.0" in str(res), str(res)
|
|
|
|
# No wheel building for upper, which was blacklisted
|
|
|
|
assert "Running setup.py bdist_wheel for upper" not in str(res), str(res)
|
|
|
|
# Must have used source, not a cached wheel to install upper.
|
|
|
|
assert "Running setup.py install for upper" in str(res), str(res)
|
2015-09-30 22:04:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_install_editable_with_wrong_egg_name(script):
|
|
|
|
script.scratch_path.join("pkga").mkdir()
|
|
|
|
pkga_path = script.scratch_path / 'pkga'
|
|
|
|
pkga_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkga',
|
|
|
|
version='0.1')
|
|
|
|
"""))
|
|
|
|
result = script.pip(
|
|
|
|
'install', '--editable', 'file://%s#egg=pkgb' % pkga_path,
|
|
|
|
expect_error=True)
|
|
|
|
assert ("egg_info for package pkgb produced metadata "
|
2016-01-08 00:13:58 +01:00
|
|
|
"for project name pkga. Fix your #egg=pkgb "
|
|
|
|
"fragments.") in result.stderr
|
|
|
|
assert "Successfully installed pkga" in str(result), str(result)
|
2015-10-23 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_install_tar_xz(script, data):
|
|
|
|
try:
|
|
|
|
import lzma # noqa
|
|
|
|
except ImportError:
|
|
|
|
pytest.skip("No lzma support")
|
|
|
|
res = script.pip('install', data.packages / 'singlemodule-0.0.1.tar.xz')
|
|
|
|
assert "Successfully installed singlemodule-0.0.1" in res.stdout, res
|
|
|
|
|
|
|
|
|
|
|
|
def test_install_tar_lzma(script, data):
|
|
|
|
try:
|
|
|
|
import lzma # noqa
|
|
|
|
except ImportError:
|
|
|
|
pytest.skip("No lzma support")
|
|
|
|
res = script.pip('install', data.packages / 'singlemodule-0.0.1.tar.lzma')
|
|
|
|
assert "Successfully installed singlemodule-0.0.1" in res.stdout, res
|
2016-01-19 00:30:26 +01:00
|
|
|
|
|
|
|
|
2017-10-02 19:33:52 +02:00
|
|
|
def test_double_install(script):
|
2016-01-19 00:30:26 +01:00
|
|
|
"""
|
|
|
|
Test double install passing with two same version requirements
|
|
|
|
"""
|
|
|
|
result = script.pip('install', 'pip', 'pip', expect_error=False)
|
|
|
|
msg = "Double requirement given: pip (already in pip, name='pip')"
|
|
|
|
assert msg not in result.stderr
|
|
|
|
|
|
|
|
|
2017-10-02 19:33:52 +02:00
|
|
|
def test_double_install_fail(script):
|
2016-01-19 00:30:26 +01:00
|
|
|
"""
|
|
|
|
Test double install failing with two different version requirements
|
|
|
|
"""
|
|
|
|
result = script.pip('install', 'pip==*', 'pip==7.1.2', expect_error=True)
|
|
|
|
msg = ("Double requirement given: pip==7.1.2 (already in pip==*, "
|
|
|
|
"name='pip')")
|
|
|
|
assert msg in result.stderr
|
2016-07-21 14:43:02 +02:00
|
|
|
|
|
|
|
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_incompatible_python_requires(script, common_wheels):
|
2016-07-21 14:43:02 +02:00
|
|
|
script.scratch_path.join("pkga").mkdir()
|
|
|
|
pkga_path = script.scratch_path / 'pkga'
|
|
|
|
pkga_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkga',
|
|
|
|
python_requires='<1.0',
|
|
|
|
version='0.1')
|
|
|
|
"""))
|
2017-05-14 00:23:17 +02:00
|
|
|
script.pip(
|
|
|
|
'install', 'setuptools>24.2', # This should not be needed
|
|
|
|
'--no-index', '-f', common_wheels,
|
|
|
|
)
|
2016-07-21 14:43:02 +02:00
|
|
|
result = script.pip('install', pkga_path, expect_error=True)
|
|
|
|
assert ("pkga requires Python '<1.0' "
|
|
|
|
"but the running Python is ") in result.stderr
|
|
|
|
|
|
|
|
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_incompatible_python_requires_editable(script, common_wheels):
|
2016-07-21 14:43:02 +02:00
|
|
|
script.scratch_path.join("pkga").mkdir()
|
|
|
|
pkga_path = script.scratch_path / 'pkga'
|
|
|
|
pkga_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkga',
|
|
|
|
python_requires='<1.0',
|
|
|
|
version='0.1')
|
|
|
|
"""))
|
2017-05-14 00:23:17 +02:00
|
|
|
script.pip(
|
|
|
|
'install', 'setuptools>24.2', # This should not be needed
|
|
|
|
'--no-index', '-f', common_wheels,
|
|
|
|
)
|
2016-07-21 14:43:02 +02:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--editable=%s' % pkga_path, expect_error=True)
|
|
|
|
assert ("pkga requires Python '<1.0' "
|
|
|
|
"but the running Python is ") in result.stderr
|
|
|
|
|
|
|
|
|
2016-12-04 17:30:31 +01:00
|
|
|
@pytest.mark.network
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_incompatible_python_requires_wheel(script, common_wheels):
|
2016-07-21 14:43:02 +02:00
|
|
|
script.scratch_path.join("pkga").mkdir()
|
|
|
|
pkga_path = script.scratch_path / 'pkga'
|
|
|
|
pkga_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkga',
|
|
|
|
python_requires='<1.0',
|
|
|
|
version='0.1')
|
|
|
|
"""))
|
2017-05-14 00:23:17 +02:00
|
|
|
script.pip(
|
|
|
|
'install', 'setuptools>24.2', # This should not be needed
|
|
|
|
'--no-index', '-f', common_wheels,
|
|
|
|
)
|
|
|
|
script.pip('install', 'wheel', '--no-index', '-f', common_wheels)
|
2016-07-21 14:43:02 +02:00
|
|
|
script.run(
|
|
|
|
'python', 'setup.py', 'bdist_wheel', '--universal', cwd=pkga_path)
|
|
|
|
result = script.pip('install', './pkga/dist/pkga-0.1-py2.py3-none-any.whl',
|
|
|
|
expect_error=True)
|
|
|
|
assert ("pkga requires Python '<1.0' "
|
|
|
|
"but the running Python is ") in result.stderr
|
|
|
|
|
|
|
|
|
2017-05-14 00:23:17 +02:00
|
|
|
def test_install_compatible_python_requires(script, common_wheels):
|
2016-07-21 14:43:02 +02:00
|
|
|
script.scratch_path.join("pkga").mkdir()
|
|
|
|
pkga_path = script.scratch_path / 'pkga'
|
|
|
|
pkga_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkga',
|
|
|
|
python_requires='>1.0',
|
|
|
|
version='0.1')
|
|
|
|
"""))
|
2017-05-14 00:23:17 +02:00
|
|
|
script.pip(
|
|
|
|
'install', 'setuptools>24.2', # This should not be needed
|
|
|
|
'--no-index', '-f', common_wheels,
|
|
|
|
)
|
2016-07-21 14:43:02 +02:00
|
|
|
res = script.pip('install', pkga_path, expect_error=True)
|
|
|
|
assert "Successfully installed pkga-0.1" in res.stdout, res
|
2016-11-02 13:28:17 +01:00
|
|
|
|
|
|
|
|
2017-10-02 19:33:52 +02:00
|
|
|
def test_install_environment_markers(script):
|
2016-11-02 13:28:17 +01:00
|
|
|
# make a dummy project
|
|
|
|
pkga_path = script.scratch_path / 'pkga'
|
|
|
|
pkga_path.mkdir()
|
|
|
|
pkga_path.join("setup.py").write(textwrap.dedent("""
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='pkga',
|
|
|
|
version='0.1',
|
|
|
|
install_requires=[
|
|
|
|
'missing_pkg; python_version=="1.0"',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
"""))
|
|
|
|
|
|
|
|
res = script.pip('install', '--no-index', pkga_path, expect_stderr=True)
|
|
|
|
# missing_pkg should be ignored
|
|
|
|
assert ("Ignoring missing-pkg: markers 'python_version == \"1.0\"' don't "
|
|
|
|
"match your environment") in res.stderr, str(res)
|
|
|
|
assert "Successfully installed pkga-0.1" in res.stdout, str(res)
|
2017-02-05 12:22:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.network
|
|
|
|
def test_install_pep508_with_url(script):
|
|
|
|
res = script.pip(
|
|
|
|
'install', '--no-index',
|
|
|
|
'packaging@https://files.pythonhosted.org/packages/2f/2b/'
|
|
|
|
'c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/'
|
|
|
|
'packaging-15.3-py2.py3-none-any.whl#sha256='
|
|
|
|
'ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4'
|
|
|
|
)
|
|
|
|
assert "Successfully installed packaging-15.3" in str(res), str(res)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.network
|
|
|
|
def test_install_pep508_with_url_in_install_requires(script):
|
|
|
|
pkga_path = create_test_package_with_setup(
|
|
|
|
script, name='pkga', version='1.0',
|
|
|
|
install_requires=[
|
|
|
|
'packaging@https://files.pythonhosted.org/packages/2f/2b/'
|
|
|
|
'c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/'
|
|
|
|
'packaging-15.3-py2.py3-none-any.whl#sha256='
|
|
|
|
'ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4'
|
|
|
|
],
|
|
|
|
)
|
|
|
|
res = script.pip('install', pkga_path, expect_error=True)
|
|
|
|
assert "Direct url requirement " in res.stderr, str(res)
|
|
|
|
assert "are not allowed for dependencies" in res.stderr, str(res)
|
2017-10-02 18:54:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_installing_scripts_outside_path_prints_warning(script):
|
|
|
|
result = script.pip_install_local(
|
|
|
|
"--prefix", script.scratch_path, "script_wheel1", expect_error=True
|
|
|
|
)
|
|
|
|
assert "Successfully installed script-wheel1" in result.stdout, str(result)
|
|
|
|
assert "--no-warn-script-location" in result.stderr
|
|
|
|
|
|
|
|
|
|
|
|
def test_installing_scripts_outside_path_can_suppress_warning(script):
|
|
|
|
result = script.pip_install_local(
|
|
|
|
"--prefix", script.scratch_path, "--no-warn-script-location",
|
|
|
|
"script_wheel1"
|
|
|
|
)
|
|
|
|
assert "Successfully installed script-wheel1" in result.stdout, str(result)
|
|
|
|
assert "--no-warn-script-location" not in result.stderr
|
|
|
|
|
|
|
|
|
|
|
|
def test_installing_scripts_on_path_does_not_print_warning(script):
|
|
|
|
result = script.pip_install_local("script_wheel1")
|
|
|
|
assert "Successfully installed script-wheel1" in result.stdout, str(result)
|
|
|
|
assert "--no-warn-script-location" not in result.stderr
|