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
|
--- a/pkgs/conda-4.0.5-py35_0/lib/python3.5/site-packages/conda/install.py 2016-03-16 20:47:12.000000000 +0100
+++ b/pkgs/conda-4.0.5-py35_0/lib/python3.5/site-packages/conda/install.py 2016-04-05 11:34:17.102042633 +0200
@@ -267,21 +267,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)
@@ -604,7 +606,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).
@@ -657,7 +659,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))
@@ -802,6 +804,10 @@
default=sys.prefix,
help="prefix (defaults to %default)")
+ p.add_option('--instdir',
+ action="store",
+ help="install dir (defaults to prefix)")
+
p.add_option('-v', '--verbose',
action="store_true")
@@ -812,9 +818,14 @@
logging.basicConfig()
prefix = opts.prefix
+ if not opts.instdir:
+ instdir = prefix
+ else:
+ instdir = opts.instdir
pkgs_dir = join(prefix, 'pkgs')
if opts.verbose:
print("prefix: %r" % prefix)
+ print("instdir : %r" % instdir)
if opts.file:
idists = list(yield_lines(join(prefix, opts.file)))
@@ -830,7 +841,7 @@
for dist in idists:
if opts.verbose:
print("linking: %s" % dist)
- link(pkgs_dir, prefix, dist, linktype)
+ link(pkgs_dir, prefix, dist, linktype, instdir=instdir)
messages(prefix)
|