1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

make pip work when current or parent dir is given: 'pip install .' and 'pip install ..'

This commit is contained in:
Alexandre Conrad 2010-04-10 11:57:49 +02:00
parent 7b3ea5a9f9
commit c8b6fa50fb
3 changed files with 31 additions and 3 deletions

View file

@ -189,6 +189,8 @@ def is_filename(name):
if (splitext(name)[1].lower() in ('.zip', '.tar.gz', '.tar.bz2', '.tgz', '.tar', '.pybundle')
and os.path.exists(name)):
return True
if name in (os.path.curdir, os.path.pardir):
return True
if os.path.sep not in name and '/' not in name:
# Doesn't have any path components, probably a requirement like 'Foo'
return False

View file

@ -1,4 +1,3 @@
from os.path import abspath, join, dirname, pardir
from test_pip import here, reset_env, run_pip, pyversion, lib_py
@ -132,3 +131,24 @@ def test_vcs_url_urlquote_normalization():
result = run_pip('install', '-e', 'bzr+http://bazaar.launchpad.net/~django-wikiapp/django-wikiapp/release-0.1#egg=django-wikiapp', expect_error=True)
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
def test_install_curdir():
"""
Test installing current directory ('.').
"""
reset_env()
run_from = abspath(join(here, 'packages', 'FSPkg'))
result = run_pip('install', '.', run_from=run_from, expect_error=False)
assert (lib_py + 'site-packages/fspkg') in result.files_created, str(result.stdout)
assert (lib_py + 'site-packages/FSPkg-0.1dev-py%s.egg-info' % pyversion) in result.files_created, str(result)
def test_install_pardir():
"""
Test installing parent directory ('..').
"""
reset_env()
run_from = abspath(join(here, 'packages', 'FSPkg', 'fspkg'))
result = run_pip('install', '..', run_from=run_from, expect_error=False)
assert (lib_py + 'site-packages/fspkg') in result.files_created, str(result.stdout)
assert (lib_py + 'site-packages/FSPkg-0.1dev-py%s.egg-info' % pyversion) in result.files_created, str(result)

View file

@ -37,7 +37,7 @@ def reset_env(environ=None):
environ = clear_environ(environ)
environ['PIP_DOWNLOAD_CACHE'] = download_cache
environ['PIP_NO_INPUT'] = '1'
environ['PIP_LOG_FILE'] = './pip-log.txt'
environ['PIP_LOG_FILE'] = os.path.join(base_path, 'pip-log.txt')
environ['PYTHONPATH'] = os.path.abspath(os.path.join(__file__, os.path.pardir, os.path.pardir))
env = TestFileEnvironment(base_path, ignore_hidden=False, environ=environ)
env.run(sys.executable, '-m', 'virtualenv', '--no-site-packages', env.base_path)
@ -48,7 +48,13 @@ def reset_env(environ=None):
env.run('mkdir', 'src')
def run_pip(*args, **kw):
args = (sys.executable, '-c', 'import pip; pip.main()', '-E', env.base_path) + args
# Run pip from a specific directory
if 'run_from' in kw:
run_from = kw['run_from']
del kw['run_from']
else:
run_from = base_path
args = (sys.executable, '-c', 'import os, pip; os.chdir(%r); pip.main()' % run_from, '-E', env.base_path) + args
#print >> sys.__stdout__, 'running', ' '.join(args)
result = env.run(*args, **kw)
return result