1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
--- a/pkgs/conda-3.18.3-py35_0/lib/python3.5/site-packages/conda/install.py 2015-11-25 09:59:32.301105554 +0100
+++ b/pkgs/conda-3.18.3-py35_0/lib/python3.5/site-packages/conda/install.py 2015-11-25 10:17:19.506243545 +0100
@@ -257,21 +257,23 @@
return res
def update_prefix(path, new_prefix, placeholder=prefix_placeholder,
- mode='text'):
+ mode='text', instdir=None):
+ if instdir is None:
+ instdir = new_prefix
if on_win and (placeholder != prefix_placeholder) and ('/' in placeholder):
# original prefix uses unix-style path separators
# replace with unix-style path separators
- new_prefix = new_prefix.replace('\\', '/')
+ instdir = instdir.replace('\\', '/')
path = os.path.realpath(path)
with open(path, 'rb') as fi:
data = fi.read()
if mode == 'text':
new_data = data.replace(placeholder.encode('utf-8'),
- new_prefix.encode('utf-8'))
+ instdir.encode('utf-8'))
elif mode == 'binary':
new_data = binary_replace(data, placeholder.encode('utf-8'),
- new_prefix.encode('utf-8'))
+ instdir.encode('utf-8'))
else:
sys.exit("Invalid mode:" % mode)
@@ -586,7 +588,7 @@
def load_meta(prefix, dist):
return is_linked(prefix, dist)
-def link(pkgs_dir, prefix, dist, linktype=LINK_HARD, index=None):
+def link(pkgs_dir, prefix, dist, linktype=LINK_HARD, index=None, instdir=None):
'''
Set up a package in a specified (environment) prefix. We assume that
the package has been extracted (using extract() above).
@@ -639,7 +641,7 @@
for f in sorted(has_prefix_files):
placeholder, mode = has_prefix_files[f]
try:
- update_prefix(join(prefix, f), prefix, placeholder, mode)
+ update_prefix(join(prefix, f), prefix, placeholder, mode, instdir=instdir)
except PaddingError:
sys.exit("ERROR: placeholder '%s' too short in: %s\n" %
(placeholder, dist))
@@ -767,6 +769,10 @@
default=sys.prefix,
help="prefix (defaults to %default)")
+ p.add_option('--instdir',
+ action="store",
+ help="install dir (defaults to prefix)")
+
p.add_option('--pkgs-dir',
action="store",
default=join(sys.prefix, 'pkgs'),
@@ -796,9 +802,14 @@
pkgs_dir = opts.pkgs_dir
prefix = opts.prefix
+ if not opts.instdir:
+ instdir = prefix
+ else:
+ instdir = opts.instdir
if opts.verbose:
print("pkgs_dir: %r" % pkgs_dir)
print("prefix : %r" % prefix)
+ print("instdir : %r" % instdir)
if opts.list:
pprint(sorted(linked(prefix)))
@@ -813,7 +824,7 @@
for dist in dists:
if opts.verbose or linktype == LINK_COPY:
print("linking: %s" % dist)
- link(pkgs_dir, prefix, dist, linktype)
+ link(pkgs_dir, prefix, dist, linktype, instdir=instdir)
messages(prefix)
elif opts.extract:
@@ -823,7 +834,7 @@
linktype = (LINK_HARD
if try_hard_link(pkgs_dir, prefix, dist) else
LINK_COPY)
- link(pkgs_dir, prefix, dist, linktype)
+ link(pkgs_dir, prefix, dist, linktype, instdir=instdir)
elif opts.unlink:
unlink(prefix, dist)
|