Blame SOURCES/pip-1.5rc1-allow-stripping-prefix-from-wheel-RECORD-files.patch

f08a46
commit aefacbb76661520415a1c35028f2984e70cfe0bf
f08a46
Author: Slavek Kabrda <bkabrda@redhat.com>
f08a46
Date:   Fri Nov 29 13:24:58 2013 +0100
f08a46
f08a46
    Allow stripping given prefix from wheel RECORD files
f08a46
f08a46
diff --git a/pip/commands/install.py b/pip/commands/install.py
f08a46
index 1693d01..0287c06 100644
f08a46
--- a/pip/commands/install.py
f08a46
+++ b/pip/commands/install.py
f08a46
@@ -137,6 +137,14 @@ class InstallCommand(Command):
f08a46
             help="Install everything relative to this alternate root directory.")
f08a46
 
f08a46
         cmd_opts.add_option(
f08a46
+            '--strip-file-prefix',
f08a46
+            dest='strip_file_prefix',
f08a46
+            metavar='prefix',
f08a46
+            default=None,
f08a46
+            help="Strip given prefix from script paths in wheel RECORD."
f08a46
+        )
f08a46
+
f08a46
+        cmd_opts.add_option(
f08a46
             "--compile",
f08a46
             action="store_true",
f08a46
             dest="compile",
f08a46
@@ -273,7 +281,11 @@ class InstallCommand(Command):
f08a46
                 requirement_set.locate_files()
f08a46
 
f08a46
             if not options.no_install and not self.bundle:
f08a46
-                requirement_set.install(install_options, global_options, root=options.root_path)
f08a46
+                requirement_set.install(
f08a46
+                    install_options,
f08a46
+                    global_options,
f08a46
+                    root=options.root_path,
f08a46
+                    strip_file_prefix=options.strip_file_prefix)
f08a46
                 installed = ' '.join([req.name for req in
f08a46
                                       requirement_set.successfully_installed])
f08a46
                 if installed:
f08a46
diff --git a/pip/req.py b/pip/req.py
f08a46
index 3ae306d..c171130 100644
f08a46
--- a/pip/req.py
f08a46
+++ b/pip/req.py
f08a46
@@ -615,15 +615,19 @@ exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
f08a46
         name = name.replace(os.path.sep, '/')
f08a46
         return name
f08a46
 
f08a46
-    def install(self, install_options, global_options=(), root=None):
f08a46
+    def install(self, install_options, global_options=(), root=None, strip_file_prefix=None):
f08a46
         if self.editable:
f08a46
             self.install_editable(install_options, global_options)
f08a46
             return
f08a46
         if self.is_wheel:
f08a46
             version = pip.wheel.wheel_version(self.source_dir)
f08a46
             pip.wheel.check_compatibility(version, self.name)
f08a46
 
f08a46
-            self.move_wheel_files(self.source_dir, root=root)
f08a46
+            self.move_wheel_files(
f08a46
+                self.source_dir,
f08a46
+                root=root,
f08a46
+                strip_file_prefix=strip_file_prefix
f08a46
+            )
f08a46
             self.install_succeeded = True
f08a46
             return
f08a46
 
f08a46
@@ -844,13 +848,14 @@ exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
f08a46
         self._bundle_build_dirs = bundle_build_dirs
f08a46
         self._bundle_editable_dirs = bundle_editable_dirs
f08a46
 
f08a46
-    def move_wheel_files(self, wheeldir, root=None):
f08a46
+    def move_wheel_files(self, wheeldir, root=None, strip_file_prefix=None):
f08a46
         move_wheel_files(
f08a46
             self.name, self.req, wheeldir,
f08a46
             user=self.use_user_site,
f08a46
             home=self.target_dir,
f08a46
             root=root,
f08a46
             pycompile=self.pycompile,
f08a46
+            strip_file_prefix=strip_file_prefix,
f08a46
         )
f08a46
 
f08a46
     @property
f08a46
diff --git a/pip/wheel.py b/pip/wheel.py
f08a46
index fa3e270..3a366d0 100644
f08a46
--- a/pip/wheel.py
f08a46
+++ b/pip/wheel.py
f08a46
@@ -136,7 +136,7 @@ def get_entrypoints(filename):
f08a46
 
f08a46
 
f08a46
 def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None,
f08a46
-                     pycompile=True, scheme=None):
f08a46
+                     pycompile=True, scheme=None, strip_file_prefix=None):
f08a46
     """Install a wheel"""
f08a46
 
f08a46
     if not scheme:
f08a46
@@ -357,6 +357,8 @@ if __name__ == '__main__':
f08a46
                 writer.writerow(row)
f08a46
             for f in generated:
f08a46
                 h, l = rehash(f)
f08a46
+                if strip_file_prefix and f.startswith(strip_file_prefix):
f08a46
+                    f = os.path.join(os.sep, os.path.relpath(f, strip_file_prefix))
f08a46
                 writer.writerow((f, h, l))
f08a46
             for f in installed:
f08a46
                 writer.writerow((installed[f], '', ''))