2011-04-26 19:19:59 +02:00
|
|
|
import os.path
|
2010-02-24 11:24:55 +01:00
|
|
|
import textwrap
|
2013-08-18 11:59:44 +02:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2013-09-27 20:42:05 +02:00
|
|
|
from tests.lib import (pyversion, path_to_url,
|
2013-07-24 17:25:35 +02:00
|
|
|
_create_test_package_with_subdirectory)
|
2013-05-27 19:46:31 +02:00
|
|
|
from tests.lib.local_repos import local_checkout
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_requirements_file(script):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Test installing from a requirements file.
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2011-03-19 01:31:36 +01:00
|
|
|
other_lib_name, other_lib_version = 'anyjson', '0.3'
|
2013-08-21 11:16:07 +02:00
|
|
|
script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\
|
2010-02-24 11:24:55 +01:00
|
|
|
INITools==0.2
|
|
|
|
# and something else to test out:
|
2011-03-15 20:49:48 +01:00
|
|
|
%s<=%s
|
|
|
|
""" % (other_lib_name, other_lib_version)))
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '-r', script.scratch_path / 'initools-req.txt'
|
|
|
|
)
|
|
|
|
assert (
|
2014-02-24 22:52:23 +01:00
|
|
|
script.site_packages / 'INITools-0.2-py%s.egg-info' %
|
2014-01-28 15:17:51 +01:00
|
|
|
pyversion in result.files_created
|
|
|
|
)
|
2014-02-24 22:52:23 +01:00
|
|
|
assert script.site_packages / 'initools' in result.files_created
|
|
|
|
assert result.files_created[script.site_packages / other_lib_name].dir
|
2011-03-15 20:49:48 +01:00
|
|
|
fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
|
2014-02-24 22:52:23 +01:00
|
|
|
assert result.files_created[script.site_packages / fn].dir
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2013-03-18 17:43:59 +01:00
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_schema_check_in_requirements_file(script):
|
2012-03-13 23:38:47 +01:00
|
|
|
"""
|
|
|
|
Test installing from a requirements file with an invalid vcs schema..
|
|
|
|
|
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
script.scratch_path.join("file-egg-req.txt").write(
|
|
|
|
"\n%s\n" % (
|
|
|
|
"git://github.com/alex/django-fixture-generator.git"
|
|
|
|
"#egg=fixture_generator"
|
|
|
|
)
|
|
|
|
)
|
2013-08-18 11:59:44 +02:00
|
|
|
|
|
|
|
with pytest.raises(AssertionError):
|
2014-01-28 15:17:51 +01:00
|
|
|
script.pip(
|
|
|
|
"install", "-vvv", "-r", script.scratch_path / "file-egg-req.txt"
|
|
|
|
)
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2012-05-14 05:13:50 +02:00
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_relative_requirements_file(script, data):
|
2011-03-23 00:13:04 +01:00
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
Test installing from a requirements file with a relative path with an
|
|
|
|
egg= definition..
|
2011-03-23 00:13:04 +01:00
|
|
|
|
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
url = path_to_url(
|
|
|
|
os.path.join(data.root, "packages", "..", "packages", "FSPkg")
|
|
|
|
) + '#egg=FSPkg'
|
2013-08-21 11:16:07 +02:00
|
|
|
script.scratch_path.join("file-egg-req.txt").write(textwrap.dedent("""\
|
2011-03-23 00:13:04 +01:00
|
|
|
%s
|
|
|
|
""" % url))
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '-vvv', '-r', script.scratch_path / 'file-egg-req.txt'
|
|
|
|
)
|
|
|
|
assert (
|
2014-02-24 22:52:23 +01:00
|
|
|
script.site_packages / 'FSPkg-0.1dev-py%s.egg-info' % pyversion
|
2014-01-28 15:17:51 +01:00
|
|
|
) in result.files_created, str(result)
|
2014-02-24 22:52:23 +01:00
|
|
|
assert (script.site_packages / 'fspkg') in result.files_created, (
|
2014-01-28 15:17:51 +01:00
|
|
|
str(result.stdout)
|
|
|
|
)
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_multiple_requirements_files(script, tmpdir):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Test installing from multiple nested requirements files.
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2011-03-19 01:31:36 +01:00
|
|
|
other_lib_name, other_lib_version = 'anyjson', '0.3'
|
2014-01-28 15:17:51 +01:00
|
|
|
script.scratch_path.join("initools-req.txt").write(
|
|
|
|
textwrap.dedent("""
|
|
|
|
-e %s@10#egg=INITools-dev
|
|
|
|
-r %s-req.txt
|
|
|
|
""") %
|
|
|
|
(
|
|
|
|
local_checkout(
|
|
|
|
'svn+http://svn.colorstudy.com/INITools/trunk',
|
|
|
|
tmpdir.join("cache"),
|
|
|
|
),
|
|
|
|
other_lib_name
|
|
|
|
),
|
|
|
|
)
|
|
|
|
script.scratch_path.join("%s-req.txt" % other_lib_name).write(
|
|
|
|
"%s<=%s" % (other_lib_name, other_lib_version)
|
|
|
|
)
|
|
|
|
result = script.pip(
|
|
|
|
'install', '-r', script.scratch_path / 'initools-req.txt'
|
|
|
|
)
|
2014-02-24 22:52:23 +01:00
|
|
|
assert result.files_created[script.site_packages / other_lib_name].dir
|
2011-03-15 20:49:48 +01:00
|
|
|
fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
|
2014-02-24 22:52:23 +01:00
|
|
|
assert result.files_created[script.site_packages / fn].dir
|
|
|
|
assert script.venv / 'src' / 'initools' in result.files_created
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2011-01-04 06:05:10 +01:00
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_respect_order_in_requirements_file(script, data):
|
2013-08-21 11:16:07 +02:00
|
|
|
script.scratch_path.join("frameworks-req.txt").write(textwrap.dedent("""\
|
2012-10-04 03:51:49 +02:00
|
|
|
parent
|
|
|
|
child
|
|
|
|
simple
|
2011-01-04 06:05:10 +01:00
|
|
|
"""))
|
2012-10-04 03:51:49 +02:00
|
|
|
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--no-index', '-f', data.find_links, '-r',
|
|
|
|
script.scratch_path / 'frameworks-req.txt'
|
|
|
|
)
|
2012-10-04 03:51:49 +02:00
|
|
|
|
2011-01-04 06:05:10 +01:00
|
|
|
downloaded = [line for line in result.stdout.split('\n')
|
|
|
|
if 'Downloading/unpacking' in line]
|
2011-03-19 01:31:36 +01:00
|
|
|
|
2014-01-28 15:17:51 +01:00
|
|
|
assert 'parent' in downloaded[0], (
|
|
|
|
'First download should be "parent" but was "%s"' % downloaded[0]
|
|
|
|
)
|
|
|
|
assert 'child' in downloaded[1], (
|
|
|
|
'Second download should be "child" but was "%s"' % downloaded[1]
|
|
|
|
)
|
|
|
|
assert 'simple' in downloaded[2], (
|
|
|
|
'Third download should be "simple" but was "%s"' % downloaded[2]
|
|
|
|
)
|
2011-01-04 06:05:10 +01:00
|
|
|
|
|
|
|
|
2014-08-01 22:20:23 +02:00
|
|
|
def test_install_local_editable_with_extras(script, data):
|
|
|
|
to_install = data.packages.join("LocalExtras")
|
|
|
|
res = script.pip(
|
|
|
|
'install', '-e', to_install + '[bar]', '--process-dependency-links',
|
|
|
|
expect_error=False,
|
|
|
|
)
|
|
|
|
assert script.site_packages / 'easy-install.pth' in res.files_updated, (
|
|
|
|
str(res)
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
script.site_packages / 'LocalExtras.egg-link' in res.files_created
|
|
|
|
), str(res)
|
|
|
|
assert script.site_packages / 'simple' in res.files_created, str(res)
|
|
|
|
|
|
|
|
|
2013-09-27 20:42:05 +02:00
|
|
|
def test_install_local_editable_with_subdirectory(script):
|
|
|
|
version_pkg_path = _create_test_package_with_subdirectory(script,
|
2014-03-08 19:33:05 +01:00
|
|
|
'version_subdir')
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '-e',
|
2014-03-08 19:33:05 +01:00
|
|
|
'%s#egg=version_subpkg&subdirectory=version_subdir' %
|
2014-01-28 15:17:51 +01:00
|
|
|
('git+file://%s' % version_pkg_path,)
|
|
|
|
)
|
2012-11-14 06:29:58 +01:00
|
|
|
|
2014-03-08 19:33:05 +01:00
|
|
|
result.assert_installed('version-subpkg', sub_dir='version_subdir')
|