summarylogtreecommitdiffstats
path: root/conda_install.patch
blob: f8f9a73072bfdd94ee53e8ad056bed19c120823e (plain)
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
93
94
95
96
97
98
99
100
--- a/pkgs/conda-3.14.1-py34_0/lib/python3.4/site-packages/conda/install.py	2015-07-03 11:04:48.348322309 +0200
+++ b/pkgs/conda-3.14.1-py34_0/lib/python3.4/site-packages/conda/install.py	2015-07-03 11:04:52.078277806 +0200
@@ -251,21 +251,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)
 
@@ -550,7 +552,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).
@@ -569,6 +571,8 @@
         # linking or unlinking some packages
         log.warn('Ignored: %s' % dist)
         return
+    if instdir is None:
+        instdir = prefix
 
     source_dir = join(pkgs_dir, dist)
     if not run_script(source_dir, dist, 'pre-link', prefix):
@@ -614,7 +618,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))
@@ -749,6 +753,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'),
@@ -778,9 +786,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)))
@@ -795,14 +808,14 @@
         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:
         extract(pkgs_dir, dist)
 
     elif opts.link:
-        link(pkgs_dir, prefix, dist)
+        link(pkgs_dir, prefix, dist, instdir=instdir)
 
     elif opts.unlink:
         unlink(prefix, dist)