Skip to content

Commit

Permalink
Handle tarball installs from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg1969 committed Jun 29, 2016
1 parent 767c0a9 commit 676650a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
1 change: 0 additions & 1 deletion conda/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import tarfile
import tempfile
import time
import tempfile
import traceback
from os.path import (abspath, basename, dirname, isdir, isfile, islink,
join, normpath)
Expand Down
6 changes: 5 additions & 1 deletion conda/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ def explicit(specs, prefix, verbose=False, force_extract=True, fetch_args=None,
prefix = pkg_path = dir_path = None
if url.startswith('file://'):
prefix = cached_url(url)
if prefix is not None:
schannel = 'defaults' if prefix == '' else prefix[:-2]
is_file = False

# If not, determine the channel name from the URL
if prefix is None:
channel, schannel = url_channel(url)
is_file = schannel.startswith('file:') and schannel.endswith('/')
prefix = '' if schannel == 'defaults' else schannel + '::'

fn = prefix + fn
dist = fn[:-8]
is_file = schannel.startswith('file:') and schannel.endswith('/')
# Add explicit file to index so we'll see it later
if is_file:
index[fn] = {'fn': dist2filename(fn), 'url': url, 'md5': None}
Expand Down
42 changes: 27 additions & 15 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,32 @@ def test_tarball_install_and_bad_metadata(self):
assert not package_is_installed(prefix, 'flask-0.10.1')
assert_package_is_installed(prefix, 'python')

# Regression test for 2812
# install from local channel
from conda.config import pkgs_dirs
flask_fname = flask_data['fn']
tar_old_path = join(pkgs_dirs[0], flask_fname)

# regression test for #2886 (part 1 of 2)
# install tarball from package cache, default channel
run_command(Commands.INSTALL, prefix, tar_old_path)
assert_package_is_installed(prefix, 'flask-0.')

# regression test for #2626
# install tarball with full path, outside channel
tar_new_path = join(prefix, flask_fname)
copyfile(tar_old_path, tar_new_path)
run_command(Commands.INSTALL, prefix, tar_new_path)
assert_package_is_installed(prefix, 'flask-0')

# regression test for #2626
# install tarball with relative path, outside channel
run_command(Commands.REMOVE, prefix, 'flask')
assert not package_is_installed(prefix, 'flask-0.10.1')
tar_new_path = relpath(tar_new_path)
run_command(Commands.INSTALL, prefix, tar_new_path)
assert_package_is_installed(prefix, 'flask-0.')

# Regression test for 2812
# install from local channel
for field in ('url', 'channel', 'schannel'):
del flask_data[field]
repodata = {'info': {}, 'packages':{flask_fname: flask_data}}
Expand All @@ -279,21 +300,12 @@ def test_tarball_install_and_bad_metadata(self):
run_command(Commands.INSTALL, prefix, '-c', channel, 'flask')
assert_package_is_installed(prefix, channel + '::' + 'flask-')

# regression test for #2626
# install tarball with full path
tar_new_path = join(prefix, flask_fname)
copyfile(tar_old_path, tar_new_path)
run_command(Commands.INSTALL, prefix, tar_new_path)
assert_package_is_installed(prefix, 'flask-0')

# regression test for #2886 (part 2 of 2)
# install tarball from package cache, local channel
run_command(Commands.REMOVE, prefix, 'flask')
assert not package_is_installed(prefix, 'flask-0')

# regression test for #2626
# install tarball with relative path
tar_new_path = relpath(tar_new_path)
run_command(Commands.INSTALL, prefix, tar_new_path)
assert_package_is_installed(prefix, 'flask-0.')
run_command(Commands.INSTALL, prefix, tar_old_path)
assert_package_is_installed(prefix, channel + '::' + 'flask-')

# regression test for #2599
linked_data_.clear()
Expand Down

0 comments on commit 676650a

Please sign in to comment.