mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Covering case of single-module packages.
Behavior is now to overwrite files or folders if --upgrade is specified, however, links will not be overwritten.
This commit is contained in:
parent
12ff251d2d
commit
ecb3049b8d
2 changed files with 19 additions and 4 deletions
|
@ -357,15 +357,19 @@ class InstallCommand(Command):
|
|||
% target_item_dir
|
||||
)
|
||||
continue
|
||||
if not os.path.isdir(target_item_dir):
|
||||
if os.path.islink(target_item_dir):
|
||||
logger.warn(
|
||||
'Target directory %s already exists and is '
|
||||
'not a directory. Please remove in order '
|
||||
'for replacement.'
|
||||
'a link. Pip will not automatically replace '
|
||||
'links, please remove if replacement is '
|
||||
'desired.'
|
||||
% target_item_dir
|
||||
)
|
||||
continue
|
||||
shutil.rmtree(target_item_dir)
|
||||
if os.path.isdir(target_item_dir):
|
||||
shutil.rmtree(target_item_dir)
|
||||
else:
|
||||
os.remove(target_item_dir)
|
||||
|
||||
shutil.move(
|
||||
os.path.join(lib_dir, item),
|
||||
|
|
|
@ -543,6 +543,17 @@ def test_install_package_with_target(script):
|
|||
str(result)
|
||||
)
|
||||
|
||||
# Test install and upgrade of single-module package
|
||||
result = script.pip('install', '-t', target_dir, 'six')
|
||||
assert Path('scratch') / 'target' / 'six.py' in result.files_created, (
|
||||
str(result)
|
||||
)
|
||||
|
||||
result = script.pip('install', '-t', target_dir, '--upgrade', 'six')
|
||||
assert Path('scratch') / 'target' / 'six.py' in result.files_updated, (
|
||||
str(result)
|
||||
)
|
||||
|
||||
|
||||
def test_install_package_with_root(script, data):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue