unpack.py 673 B

12345678910111213141516171819202122232425
  1. from __future__ import print_function
  2. import os.path
  3. import sys
  4. from ..wheelfile import WheelFile
  5. def unpack(path, dest='.'):
  6. """Unpack a wheel.
  7. Wheel content will be unpacked to {dest}/{name}-{ver}, where {name}
  8. is the package name and {ver} its version.
  9. :param path: The path to the wheel.
  10. :param dest: Destination directory (default to current directory).
  11. """
  12. with WheelFile(path) as wf:
  13. namever = wf.parsed_filename.group('namever')
  14. destination = os.path.join(dest, namever)
  15. print("Unpacking to: {}...".format(destination), end='')
  16. sys.stdout.flush()
  17. wf.extractall(destination)
  18. print('OK')