Michele Lacchia avatar Michele Lacchia committed d8143f8

Wheel unpack

Comments (0)

Files changed (2)


 Wheel command-line utility.
+import os
 import baker
 import ed25519ll
 import sys
 wb = baker.Baker()
 def keygen():
     """Generate a public/private key pair."""
     keypair = ed25519ll.crypto_sign_keypair()
     if sk2 != sk:
         raise Exception("Keyring is broken. Could not retrieve secret key.")
 def sign(wheelfile, replace=False):
     """Sign a wheel"""
     import hashlib    
     wf.zipfile.writestr(sig_name, json.dumps(sig, sort_keys=True))
 def verify(wheelfile):
     """Verify a wheel."""
     import pprint
     sys.stdout.write("Signatures are internally consistent.\n%s\n" % (
-def main():
-    wb.run()
+@wb.command(shortopts={'dest': 'd'})
+def unpack(wheelfile, dest='.'):
+    """Unpack a wheel.
+    Wheel content will be unpacked to {dest}/{name}-{ver}, where {name}
+    is the package name and {ver} its version.
+    :param wheelfile: The path to the wheel.
+    :param dest: Destination directory (default to current directory).
+    """
+    wf = wheel.install.WheelFile(wheelfile)
+    namever = wf.parsed_filename.group('namever')
+    destination = os.path.join(dest, namever)
+    sys.stdout.write("Unpacking to: %s\n" % (destination))
+    wf.zipfile.extractall(destination)
+    wf.zipfile.close()
 if __name__ == "__main__":
 class BadWheelFile(ValueError):
 class WheelFile(object):
     """Parse wheel-specific attributes from a wheel (.whl) file"""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.