Skip to content

Commit

Permalink
Fix misc.install_local_packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg1969 committed May 5, 2016
1 parent 33612ce commit 300241a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion conda/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def url_channel(url):
return None, '<unknown>'
channel = url.rsplit('/', 2)[0]
schannel = canonical_channel_name(channel)
return channel, schannel
return channel + '/', schannel

# ----- allowed channels -----

Expand Down
4 changes: 3 additions & 1 deletion conda/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ def fetch_pkg(info, dst_dir=None, session=None):
session = session or CondaSession()

fn = info['fn']
url = info['channel'] + fn
url = info.get('url')
if url is None:
url = info['channel'] + fn
log.debug("url=%r" % url)
if dst_dir is None:
dst_dir = dirname(find_new_location(fn[:-8])[0])
Expand Down
25 changes: 16 additions & 9 deletions conda/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import shutil
import sys
from collections import defaultdict
from os.path import (abspath, basename, dirname, expanduser, exists,
from os.path import (abspath, dirname, expanduser, exists,
isdir, isfile, islink, join, relpath)

from conda import config
from conda import install
from conda import utils
from conda import fetch
from conda.api import get_index
from conda.compat import iteritems
from conda.instructions import RM_EXTRACTED, EXTRACT, UNLINK, LINK
Expand Down Expand Up @@ -253,17 +255,22 @@ def clone_env(prefix1, prefix2, verbose=True, quiet=False, index=None):

def install_local_packages(prefix, paths, verbose=False):
# copy packages to pkgs dir
pkgs_dir = config.pkgs_dirs[0]
dists = []
for src_path in paths:
assert src_path.endswith('.tar.bz2')
fn = basename(src_path)
dists.append(fn[:-8])
dst_path = join(pkgs_dir, fn)
if abspath(src_path) == abspath(dst_path):
continue
shutil.copyfile(src_path, dst_path)

src_path = abspath(src_path)
src_dir, fn = os.path.split(src_path)
dist = fn[:-8]
schannel = None
for dd in config.pkgs_dirs:
if src_dir == abspath(dd):
schannel = install.load_meta(dd, dist)
if not schannel:
url = utils.url_path(src_path)
_, schannel = config.url_channel(url)
info = {'fn': fn, 'url': url, 'schannel': schannel, 'md5': None}
fetch.fetch_pkg(info)
dists.append('%s::%s' % (schannel, dist))
force_extract_and_link(dists, prefix, verbose=verbose)


Expand Down

0 comments on commit 300241a

Please sign in to comment.