2010-06-09 01:09:37 +02:00
|
|
|
import re
|
2010-08-06 20:10:16 +02:00
|
|
|
import os
|
2010-06-09 01:09:37 +02:00
|
|
|
import filecmp
|
2010-08-06 17:41:49 +02:00
|
|
|
import textwrap
|
2010-08-19 18:59:10 +02:00
|
|
|
import sys
|
2010-06-09 02:03:48 +02:00
|
|
|
from os.path import abspath, join, curdir, pardir
|
2011-03-15 20:49:48 +01:00
|
|
|
from tests.test_pip import (here, reset_env, run_pip, pyversion, mkdir,
|
2011-03-19 01:31:36 +01:00
|
|
|
src_folder, write_file)
|
2011-03-15 20:49:48 +01:00
|
|
|
from tests.local_repos import local_checkout
|
|
|
|
from tests.path import Path
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_correct_pip_version():
|
|
|
|
"""
|
|
|
|
Check we are running proper version of pip in run_pip.
|
|
|
|
"""
|
2010-02-24 11:24:54 +01:00
|
|
|
reset_env()
|
2010-04-13 02:48:37 +02:00
|
|
|
|
2010-06-09 01:09:37 +02:00
|
|
|
# output is like:
|
|
|
|
# pip PIPVERSION from PIPDIRECTORY (python PYVERSION)
|
2010-02-24 11:24:54 +01:00
|
|
|
result = run_pip('--version')
|
2010-04-13 02:48:37 +02:00
|
|
|
|
|
|
|
# compare the directory tree of the invoked pip with that of this source distribution
|
2011-03-20 15:36:07 +01:00
|
|
|
dir = re.match(r'pip \d(\.[\d])+(\.(pre|post)\d+)? from (.*) \(python \d(.[\d])+\)$',
|
|
|
|
result.stdout).group(4)
|
2010-06-09 01:09:37 +02:00
|
|
|
pip_folder = join(src_folder, 'pip')
|
|
|
|
pip_folder_outputed = join(dir, 'pip')
|
2010-06-09 01:57:29 +02:00
|
|
|
|
2010-06-09 01:09:37 +02:00
|
|
|
diffs = filecmp.dircmp(pip_folder, pip_folder_outputed)
|
2010-04-13 02:48:37 +02:00
|
|
|
|
|
|
|
# If any non-matching .py files exist, we have a problem: run_pip
|
|
|
|
# is picking up some other version! N.B. if this project acquires
|
|
|
|
# primary resources other than .py files, this code will need
|
|
|
|
# maintenance
|
|
|
|
mismatch_py = [x for x in diffs.left_only + diffs.right_only + diffs.diff_files if x.endswith('.py')]
|
2010-06-09 01:09:37 +02:00
|
|
|
assert not mismatch_py, 'mismatched source files in %r and %r'% (pip_folder, pip_folder_outputed)
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-08-03 01:54:25 +02:00
|
|
|
def test_pip_second_command_line_interface_works():
|
|
|
|
"""
|
|
|
|
Check if ``pip-<PYVERSION>`` commands behaves equally
|
|
|
|
"""
|
|
|
|
e = reset_env()
|
|
|
|
result = e.run('pip-%s' % pyversion, 'install', 'INITools==0.2')
|
|
|
|
egg_info_folder = e.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
|
|
|
|
initools_folder = e.site_packages / 'initools'
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
|
|
|
assert initools_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2011-03-19 04:19:22 +01:00
|
|
|
#def test_distutils_configuration_setting():
|
|
|
|
# """
|
|
|
|
# Test the distutils-configuration-setting command (which is distinct from other commands).
|
|
|
|
# """
|
2010-02-24 11:24:54 +01:00
|
|
|
#print run_pip('-vv', '--distutils-cfg=easy_install:index_url:http://download.zope.org/ppix/', expect_error=True)
|
|
|
|
#Script result: python ../../poacheggs.py -E .../poacheggs-tests/test-scratch -vv --distutils-cfg=easy_install:index_url:http://download.zope.org/ppix/
|
|
|
|
#-- stdout: --------------------
|
|
|
|
#Distutils config .../poacheggs-tests/test-scratch/lib/python.../distutils/distutils.cfg is writable
|
|
|
|
#Replaced setting index_url
|
|
|
|
#Updated .../poacheggs-tests/test-scratch/lib/python.../distutils/distutils.cfg
|
|
|
|
#<BLANKLINE>
|
|
|
|
#-- updated: -------------------
|
|
|
|
# lib/python2.4/distutils/distutils.cfg (346 bytes)
|
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_install_from_pypi():
|
|
|
|
"""
|
|
|
|
Test installing a package from PyPI.
|
|
|
|
"""
|
2010-04-28 17:41:55 +02:00
|
|
|
e = reset_env()
|
2010-05-20 08:35:04 +02:00
|
|
|
result = run_pip('install', '-vvv', 'INITools==0.2')
|
2010-06-09 01:09:37 +02:00
|
|
|
egg_info_folder = e.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
|
|
|
|
initools_folder = e.site_packages / 'initools'
|
|
|
|
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
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-08-16 01:46:23 +02:00
|
|
|
def test_install_from_mirrors():
|
|
|
|
"""
|
|
|
|
Test installing a package from the PyPI mirrors.
|
|
|
|
"""
|
|
|
|
e = reset_env()
|
|
|
|
result = run_pip('install', '-vvv', '--use-mirrors', '--no-index', 'INITools==0.2')
|
|
|
|
egg_info_folder = e.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
|
|
|
|
initools_folder = e.site_packages / 'initools'
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
|
|
|
assert initools_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
|
|
|
def test_install_from_mirrors_with_specific_mirrors():
|
|
|
|
"""
|
|
|
|
Test installing a package from a specific PyPI mirror.
|
|
|
|
"""
|
|
|
|
e = reset_env()
|
|
|
|
result = run_pip('install', '-vvv', '--use-mirrors', '--mirrors', "http://d.pypi.python.org/", '--no-index', 'INITools==0.2')
|
|
|
|
egg_info_folder = e.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
|
|
|
|
initools_folder = e.site_packages / 'initools'
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
|
|
|
assert initools_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_editable_install():
|
|
|
|
"""
|
|
|
|
Test editable installation.
|
|
|
|
"""
|
2010-02-24 11:24:54 +01:00
|
|
|
reset_env()
|
|
|
|
result = run_pip('install', '-e', 'INITools==0.2', expect_error=True)
|
|
|
|
assert "--editable=INITools==0.2 should be formatted with svn+URL" in result.stdout
|
2010-02-24 11:24:54 +01:00
|
|
|
assert len(result.files_created) == 1, result.files_created
|
2010-02-24 11:24:54 +01:00
|
|
|
assert not result.files_updated, result.files_updated
|
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_install_editable_from_svn():
|
|
|
|
"""
|
|
|
|
Test checking out from svn.
|
|
|
|
"""
|
2010-06-04 02:58:16 +02:00
|
|
|
reset_env()
|
2010-06-09 01:09:37 +02:00
|
|
|
result = run_pip('install',
|
|
|
|
'-e',
|
2010-06-22 00:48:28 +02:00
|
|
|
'%s#egg=initools-dev' %
|
|
|
|
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
|
2010-04-28 22:55:10 +02:00
|
|
|
result.assert_installed('INITools', with_files=['.svn'])
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-04-15 13:01:36 +02:00
|
|
|
def test_download_editable_to_custom_path():
|
|
|
|
"""
|
|
|
|
Test downloading an editable using a relative custom src folder.
|
|
|
|
"""
|
|
|
|
reset_env()
|
|
|
|
mkdir('customdl')
|
2010-06-09 01:09:37 +02:00
|
|
|
result = run_pip('install',
|
|
|
|
'-e',
|
2010-06-22 00:48:28 +02:00
|
|
|
'%s#egg=initools-dev' %
|
|
|
|
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
|
2010-06-09 01:09:37 +02:00
|
|
|
'--src',
|
|
|
|
'customsrc',
|
|
|
|
'--download',
|
|
|
|
'customdl')
|
2010-04-28 22:55:10 +02:00
|
|
|
customsrc = Path('scratch')/'customsrc'/'initools'
|
|
|
|
assert customsrc in result.files_created, sorted(result.files_created.keys())
|
|
|
|
assert customsrc/'setup.py' in result.files_created, sorted(result.files_created.keys())
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-04-28 22:55:10 +02:00
|
|
|
customdl = Path('scratch')/'customdl'/'initools'
|
2010-06-09 01:09:37 +02:00
|
|
|
customdl_files_created = [filename for filename in result.files_created
|
|
|
|
if filename.startswith(customdl)]
|
|
|
|
assert customdl_files_created
|
2010-04-15 13:01:36 +02:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-04-15 15:26:21 +02:00
|
|
|
def test_editable_no_install_followed_by_no_download():
|
|
|
|
"""
|
|
|
|
Test installing an editable in two steps (first with --no-install, then with --no-download).
|
|
|
|
"""
|
|
|
|
reset_env()
|
|
|
|
|
2010-06-09 01:09:37 +02:00
|
|
|
result = run_pip('install',
|
|
|
|
'-e',
|
2010-06-22 00:48:28 +02:00
|
|
|
'%s#egg=initools-dev' %
|
|
|
|
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
|
2010-06-09 01:09:37 +02:00
|
|
|
'--no-install', expect_error=True)
|
2010-04-28 22:55:10 +02:00
|
|
|
result.assert_installed('INITools', without_egg_link=True, with_files=['.svn'])
|
2010-04-15 15:26:21 +02:00
|
|
|
|
2010-06-09 01:09:37 +02:00
|
|
|
result = run_pip('install',
|
|
|
|
'-e',
|
2010-06-22 00:48:28 +02:00
|
|
|
'%s#egg=initools-dev' %
|
|
|
|
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
|
2010-06-14 18:54:44 +02:00
|
|
|
'--no-download', expect_error=True)
|
2010-04-28 22:55:10 +02:00
|
|
|
result.assert_installed('INITools', without_files=[curdir, '.svn'])
|
2010-04-15 15:26:21 +02:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-04-15 15:26:21 +02:00
|
|
|
def test_no_install_followed_by_no_download():
|
|
|
|
"""
|
|
|
|
Test installing in two steps (first with --no-install, then with --no-download).
|
|
|
|
"""
|
2010-04-28 22:55:10 +02:00
|
|
|
env = reset_env()
|
2010-04-15 15:26:21 +02:00
|
|
|
|
2010-06-09 01:09:37 +02:00
|
|
|
egg_info_folder = env.site_packages/'INITools-0.2-py%s.egg-info' % pyversion
|
|
|
|
initools_folder = env.site_packages/'initools'
|
2010-05-02 20:11:45 +02:00
|
|
|
build_dir = env.venv/'build'/'INITools'
|
2010-04-15 15:26:21 +02:00
|
|
|
|
2010-06-09 01:57:29 +02:00
|
|
|
result1 = run_pip('install', 'INITools==0.2', '--no-install', expect_error=True)
|
2010-06-09 01:09:37 +02:00
|
|
|
assert egg_info_folder not in result1.files_created, str(result1)
|
|
|
|
assert initools_folder not in result1.files_created, sorted(result1.files_created)
|
|
|
|
assert build_dir in result1.files_created, result1.files_created
|
|
|
|
assert build_dir/'INITools.egg-info' in result1.files_created
|
|
|
|
|
|
|
|
result2 = run_pip('install', 'INITools==0.2', '--no-download', expect_error=True)
|
|
|
|
assert egg_info_folder in result2.files_created, str(result2)
|
|
|
|
assert initools_folder in result2.files_created, sorted(result2.files_created)
|
|
|
|
assert build_dir not in result2.files_created
|
|
|
|
assert build_dir/'INITools.egg-info' not in result2.files_created
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-04-15 17:08:02 +02:00
|
|
|
def test_bad_install_with_no_download():
|
|
|
|
"""
|
|
|
|
Test that --no-download behaves sensibly if the package source can't be found.
|
|
|
|
"""
|
|
|
|
reset_env()
|
2010-06-03 04:25:26 +02:00
|
|
|
result = run_pip('install', 'INITools==0.2', '--no-download', expect_error=True)
|
2010-06-09 01:09:37 +02:00
|
|
|
assert "perhaps --no-download was used without first running "\
|
|
|
|
"an equivalent install with --no-install?" in result.stdout
|
2010-04-15 17:08:02 +02:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_install_dev_version_from_pypi():
|
|
|
|
"""
|
|
|
|
Test using package==dev.
|
|
|
|
"""
|
2010-04-28 17:41:55 +02:00
|
|
|
e = reset_env()
|
2010-02-24 11:24:54 +01:00
|
|
|
result = run_pip('install', 'INITools==dev', expect_error=True)
|
2010-04-28 17:41:55 +02:00
|
|
|
assert (e.site_packages / 'initools') in result.files_created, str(result.stdout)
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_install_editable_from_git():
|
|
|
|
"""
|
|
|
|
Test cloning from Git.
|
|
|
|
"""
|
2010-06-04 02:58:16 +02:00
|
|
|
reset_env()
|
2011-03-15 20:49:48 +01:00
|
|
|
args = ['install']
|
|
|
|
args.extend(['-e',
|
|
|
|
'%s#egg=django-feedutil' %
|
|
|
|
local_checkout('git+http://github.com/jezdez/django-feedutil.git')])
|
2011-03-19 04:19:22 +01:00
|
|
|
result = run_pip(*args, **{"expect_error": True})
|
2010-04-28 22:55:10 +02:00
|
|
|
result.assert_installed('django-feedutil', with_files=['.git'])
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_install_editable_from_hg():
|
|
|
|
"""
|
|
|
|
Test cloning from Mercurial.
|
|
|
|
"""
|
2010-06-04 02:58:16 +02:00
|
|
|
reset_env()
|
2010-06-09 01:09:37 +02:00
|
|
|
result = run_pip('install', '-e',
|
2010-06-22 00:48:28 +02:00
|
|
|
'%s#egg=django-registration' %
|
|
|
|
local_checkout('hg+http://bitbucket.org/ubernostrum/django-registration'),
|
2010-06-09 01:09:37 +02:00
|
|
|
expect_error=True)
|
2010-04-28 22:55:10 +02:00
|
|
|
result.assert_installed('django-registration', with_files=['.hg'])
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_vcs_url_final_slash_normalization():
|
|
|
|
"""
|
|
|
|
Test that presence or absence of final slash in VCS URL is normalized.
|
|
|
|
"""
|
2010-02-24 11:24:54 +01:00
|
|
|
reset_env()
|
2010-06-09 01:09:37 +02:00
|
|
|
result = run_pip('install', '-e',
|
2010-06-22 00:48:28 +02:00
|
|
|
'%s/#egg=django-registration' %
|
|
|
|
local_checkout('hg+http://bitbucket.org/ubernostrum/django-registration'),
|
2010-06-09 01:09:37 +02:00
|
|
|
expect_error=True)
|
2010-02-24 11:24:54 +01:00
|
|
|
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
|
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_install_editable_from_bazaar():
|
|
|
|
"""
|
|
|
|
Test checking out from Bazaar.
|
|
|
|
"""
|
2010-06-04 02:58:16 +02:00
|
|
|
reset_env()
|
2010-06-09 01:09:37 +02:00
|
|
|
result = run_pip('install', '-e',
|
2010-06-22 00:48:28 +02:00
|
|
|
'%s/@174#egg=django-wikiapp' %
|
|
|
|
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
|
2010-06-09 01:09:37 +02:00
|
|
|
expect_error=True)
|
2010-04-28 22:55:10 +02:00
|
|
|
result.assert_installed('django-wikiapp', with_files=['.bzr'])
|
2010-04-13 00:34:38 +02:00
|
|
|
|
2010-02-24 11:24:54 +01:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_vcs_url_urlquote_normalization():
|
|
|
|
"""
|
|
|
|
Test that urlquoted characters are normalized for repo URL comparison.
|
|
|
|
"""
|
2010-02-24 11:24:54 +01:00
|
|
|
reset_env()
|
2010-06-09 01:09:37 +02:00
|
|
|
result = run_pip('install', '-e',
|
2010-06-22 00:48:28 +02:00
|
|
|
'%s/#egg=django-wikiapp' %
|
|
|
|
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
|
2010-06-09 01:09:37 +02:00
|
|
|
expect_error=True)
|
2010-02-24 11:24:54 +01:00
|
|
|
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
|
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-04-13 08:59:43 +02:00
|
|
|
def test_install_from_local_directory():
|
|
|
|
"""
|
|
|
|
Test installing from a local directory.
|
|
|
|
"""
|
2010-04-28 22:55:10 +02:00
|
|
|
env = reset_env()
|
2010-04-13 08:59:43 +02:00
|
|
|
to_install = abspath(join(here, 'packages', 'FSPkg'))
|
|
|
|
result = run_pip('install', to_install, expect_error=False)
|
2010-06-09 01:09:37 +02:00
|
|
|
fspkg_folder = env.site_packages/'fspkg'
|
|
|
|
egg_info_folder = env.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion
|
|
|
|
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
|
|
|
|
2010-04-13 18:12:50 +02:00
|
|
|
def test_install_from_local_directory_with_no_setup_py():
|
|
|
|
"""
|
|
|
|
Test installing from a local directory with no 'setup.py'.
|
|
|
|
"""
|
|
|
|
reset_env()
|
|
|
|
result = run_pip('install', here, expect_error=True)
|
|
|
|
assert len(result.files_created) == 1, result.files_created
|
|
|
|
assert 'pip-log.txt' in result.files_created, result.files_created
|
|
|
|
assert "is not installable. File 'setup.py' not found." in result.stdout
|
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2010-04-10 11:57:49 +02:00
|
|
|
def test_install_curdir():
|
|
|
|
"""
|
|
|
|
Test installing current directory ('.').
|
|
|
|
"""
|
2010-06-09 01:09:37 +02:00
|
|
|
env = reset_env()
|
2010-04-10 11:57:49 +02:00
|
|
|
run_from = abspath(join(here, 'packages', 'FSPkg'))
|
2010-04-13 08:59:43 +02:00
|
|
|
result = run_pip('install', curdir, cwd=run_from, expect_error=False)
|
2010-06-09 01:09:37 +02:00
|
|
|
fspkg_folder = env.site_packages/'fspkg'
|
|
|
|
egg_info_folder = env.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion
|
|
|
|
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
|
|
|
|
2010-08-19 18:59:10 +02:00
|
|
|
# user-site only exists in Python 2.6+
|
2010-11-21 16:27:37 +01:00
|
|
|
# and --user is _only_ possible using distribute!
|
2010-08-19 18:59:10 +02:00
|
|
|
if sys.version_info < (2, 6):
|
|
|
|
def test_install_curdir_usersite_fails_in_old_python():
|
|
|
|
"""
|
|
|
|
Test --user option on older Python versions (pre 2.6) fails intelligibly
|
|
|
|
"""
|
2011-03-19 04:19:22 +01:00
|
|
|
reset_env()
|
2010-08-19 18:59:10 +02:00
|
|
|
run_from = abspath(join(here, 'packages', 'FSPkg'))
|
|
|
|
result = run_pip('install', '--user', curdir, cwd=run_from, expect_error=True)
|
|
|
|
assert '--user is only supported in Python version 2.6 and newer' in result.stdout
|
|
|
|
|
|
|
|
else:
|
|
|
|
def test_install_curdir_usersite():
|
|
|
|
"""
|
|
|
|
Test installing current directory ('.') into usersite
|
|
|
|
"""
|
2011-03-19 04:19:22 +01:00
|
|
|
env = reset_env(use_distribute=True)
|
2010-08-19 18:59:10 +02:00
|
|
|
run_from = abspath(join(here, 'packages', 'FSPkg'))
|
|
|
|
result = run_pip('install', '--user', curdir, cwd=run_from, expect_error=False)
|
|
|
|
fspkg_folder = env.user_site/'fspkg'
|
|
|
|
egg_info_folder = env.user_site/'FSPkg-0.1dev-py%s.egg-info' % pyversion
|
|
|
|
assert fspkg_folder in result.files_created, str(result.stdout)
|
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2011-03-15 20:49:48 +01:00
|
|
|
def test_install_subversion_usersite_editable_with_distribute(): # VMS fails because abiflags not in environment
|
2010-08-19 18:59:10 +02:00
|
|
|
"""
|
|
|
|
Test installing current directory ('.') into usersite after installing distribute
|
|
|
|
"""
|
2011-03-19 04:19:22 +01:00
|
|
|
env = reset_env(use_distribute=True)
|
2010-08-19 18:59:10 +02:00
|
|
|
(env.lib_path/'no-global-site-packages.txt').rm() # this one reenables user_site
|
|
|
|
|
|
|
|
result = run_pip('install', '--user', '-e',
|
|
|
|
'%s#egg=initools-dev' %
|
|
|
|
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
|
|
|
|
result.assert_installed('INITools', use_user_site=True)
|
|
|
|
|
|
|
|
|
2011-03-15 20:49:48 +01:00
|
|
|
if sys.version_info < (3,):
|
|
|
|
# We don't try to use setuptools for 3.X.
|
|
|
|
def test_install_subversion_usersite_editable_with_setuptools_fails():
|
|
|
|
"""
|
|
|
|
Test installing current directory ('.') into usersite using setuptools
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
(env.lib_path/'no-global-site-packages.txt').rm() # this one reenables user_site
|
2010-08-19 18:59:10 +02:00
|
|
|
|
2011-03-15 20:49:48 +01:00
|
|
|
result = run_pip('install', '--user', '-e',
|
|
|
|
'%s#egg=initools-dev' %
|
|
|
|
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
|
|
|
|
expect_error=True)
|
|
|
|
assert '--user --editable not supported with setuptools, use distribute' in result.stdout
|
2010-08-19 17:40:21 +02:00
|
|
|
|
2010-04-10 11:57:49 +02:00
|
|
|
def test_install_pardir():
|
|
|
|
"""
|
|
|
|
Test installing parent directory ('..').
|
|
|
|
"""
|
2010-06-09 01:09:37 +02:00
|
|
|
env = reset_env()
|
2010-04-10 11:57:49 +02:00
|
|
|
run_from = abspath(join(here, 'packages', 'FSPkg', 'fspkg'))
|
2010-04-13 08:59:43 +02:00
|
|
|
result = run_pip('install', pardir, cwd=run_from, expect_error=False)
|
2010-06-09 01:09:37 +02:00
|
|
|
fspkg_folder = env.site_packages/'fspkg'
|
|
|
|
egg_info_folder = env.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
def test_install_global_option():
|
|
|
|
"""
|
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
|
|
|
"""
|
|
|
|
reset_env()
|
|
|
|
result = run_pip('install', '--global-option=--version', "INITools==0.1")
|
|
|
|
assert '0.1\n' in result.stdout
|
2010-08-06 17:41:49 +02:00
|
|
|
|
|
|
|
|
2010-09-07 19:26:13 +02:00
|
|
|
def test_install_with_pax_header():
|
|
|
|
"""
|
|
|
|
test installing from a tarball with pax header for python<2.6
|
|
|
|
"""
|
|
|
|
reset_env()
|
|
|
|
run_from = abspath(join(here, 'packages'))
|
2011-03-19 04:19:22 +01:00
|
|
|
run_pip('install', 'paxpkg.tar.bz2', cwd=run_from)
|
2010-09-07 19:26:13 +02:00
|
|
|
|
2010-08-19 03:29:36 +02:00
|
|
|
def test_install_using_install_option_and_editable():
|
|
|
|
"""
|
|
|
|
Test installing a tool using -e and --install-option
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
2010-08-19 04:11:08 +02:00
|
|
|
folder = 'script_folder'
|
|
|
|
mkdir(folder)
|
2011-03-19 04:19:22 +01:00
|
|
|
url = 'git+git://github.com/pypa/virtualenv'
|
2010-08-19 03:29:36 +02:00
|
|
|
result = run_pip('install', '-e', '%s#egg=virtualenv' %
|
2011-03-15 20:49:48 +01:00
|
|
|
local_checkout(url),
|
2010-08-19 04:11:08 +02:00
|
|
|
'--install-option=--script-dir=%s' % folder)
|
|
|
|
virtualenv_bin = env.venv/'src'/'virtualenv'/folder/'virtualenv'+env.exe
|
|
|
|
assert virtualenv_bin in result.files_created
|
2010-08-19 03:29:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_install_global_option_using_editable():
|
|
|
|
"""
|
|
|
|
Test using global distutils options, but in an editable installation
|
|
|
|
"""
|
|
|
|
reset_env()
|
2011-03-19 04:19:22 +01:00
|
|
|
url = 'hg+http://bitbucket.org/runeh/anyjson'
|
2010-08-19 03:29:36 +02:00
|
|
|
result = run_pip('install', '--global-option=--version',
|
2011-03-19 04:19:22 +01:00
|
|
|
'-e', '%s@0.2.5#egg=anyjson' %
|
2011-03-15 20:49:48 +01:00
|
|
|
local_checkout(url))
|
2011-03-19 04:19:22 +01:00
|
|
|
assert '0.2.5\n' in result.stdout
|
2010-08-19 03:29:36 +02:00
|
|
|
|
|
|
|
|
2010-08-06 17:41:49 +02:00
|
|
|
def test_install_package_with_same_name_in_curdir():
|
|
|
|
"""
|
|
|
|
Test installing a package with the same name of a local folder
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
mkdir('mock==0.6')
|
|
|
|
result = run_pip('install', 'mock==0.6')
|
|
|
|
egg_folder = env.site_packages / 'mock-0.6.0-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
|
|
|
mock100_setup_py = textwrap.dedent('''\
|
|
|
|
from setuptools import setup
|
|
|
|
setup(name='mock',
|
|
|
|
version='100.1')''')
|
|
|
|
|
|
|
|
|
|
|
|
def test_install_folder_using_dot_slash():
|
|
|
|
"""
|
|
|
|
Test installing a folder using pip install ./foldername
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
mkdir('mock')
|
|
|
|
pkg_path = env.scratch_path/'mock'
|
|
|
|
write_file('setup.py', mock100_setup_py, pkg_path)
|
|
|
|
result = run_pip('install', './mock')
|
|
|
|
egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
|
|
|
def test_install_folder_using_slash_in_the_end():
|
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
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
mkdir('mock')
|
|
|
|
pkg_path = env.scratch_path/'mock'
|
|
|
|
write_file('setup.py', mock100_setup_py, pkg_path)
|
2010-08-06 20:05:00 +02:00
|
|
|
result = run_pip('install', 'mock' + os.path.sep)
|
2010-08-06 17:41:49 +02:00
|
|
|
egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
|
|
|
def test_install_folder_using_relative_path():
|
|
|
|
"""
|
|
|
|
Test installing a folder using pip install folder1/folder2
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
mkdir('initools')
|
|
|
|
mkdir(Path('initools')/'mock')
|
|
|
|
pkg_path = env.scratch_path/'initools'/'mock'
|
|
|
|
write_file('setup.py', mock100_setup_py, pkg_path)
|
|
|
|
result = run_pip('install', Path('initools')/'mock')
|
|
|
|
egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
|
|
|
|
assert egg_folder in result.files_created, str(result)
|
2010-12-09 04:15:53 +01:00
|
|
|
|
|
|
|
def test_install_package_which_contains_dev_in_name():
|
|
|
|
"""
|
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
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
result = run_pip('install', 'django-devserver==0.0.4')
|
|
|
|
devserver_folder = env.site_packages/'devserver'
|
|
|
|
egg_info_folder = env.site_packages/'django_devserver-0.0.4-py%s.egg-info' % pyversion
|
|
|
|
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
|
|
|
|
|
|
|
def test_find_command_folder_in_path():
|
|
|
|
"""
|
|
|
|
If a folder named e.g. 'git' is in PATH, and find_command is looking for
|
|
|
|
the 'git' executable, it should not match the folder, but rather keep
|
|
|
|
looking.
|
|
|
|
"""
|
|
|
|
env = reset_env()
|
|
|
|
mkdir('path_one'); path_one = env.scratch_path/'path_one'
|
|
|
|
mkdir(path_one/'foo')
|
|
|
|
mkdir('path_two'); path_two = env.scratch_path/'path_two'
|
|
|
|
write_file(path_two/'foo', '# nothing')
|
|
|
|
from pip.util import find_command
|
|
|
|
found_path = find_command('foo', map(str, [path_one, path_two]))
|
|
|
|
assert found_path == path_two/'foo'
|