diff options
| author | Jason Maskell <Jason Maskell> | 2016-07-26 16:21:57 +0700 |
|---|---|---|
| committer | Jason Maskell <Jason Maskell> | 2016-07-26 16:21:57 +0700 |
| commit | 9d3f79f7e7e68ca9e296368587ab22494ffaf19b (patch) | |
| tree | eaa4190d763f6504ba5ba91fe367c937406a2a45 /packman/windows/configure/install_package.py | |
| parent | Modified finders to take Visual Studio platform into account when finding lib... (diff) | |
| download | waveworks_archive-9d3f79f7e7e68ca9e296368587ab22494ffaf19b.tar.xz waveworks_archive-9d3f79f7e7e68ca9e296368587ab22494ffaf19b.zip | |
Added Packman support - now the GenerateProjects.bat uses Packman to pull dependencies specified in WaveWorksDependencies.xml
Finders of these dependencies are modified to look in the Packman repo.
Diffstat (limited to 'packman/windows/configure/install_package.py')
| -rw-r--r-- | packman/windows/configure/install_package.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/packman/windows/configure/install_package.py b/packman/windows/configure/install_package.py new file mode 100644 index 0000000..5e30a03 --- /dev/null +++ b/packman/windows/configure/install_package.py @@ -0,0 +1,41 @@ +import logging +import zipfile +import tempfile +import sys +import shutil + +__author__ = 'hfannar' +logging.basicConfig(level=logging.WARNING, format="%(message)s") +logger = logging.getLogger('install_package') + + +class TemporaryDirectory: + def __init__(self): + self.path = None + + def __enter__(self): + self.path = tempfile.mkdtemp() + return self.path + + def __exit__(self, type, value, traceback ): + # Remove temporary data created + shutil.rmtree(self.path) + + +def install_package(package_src_path, package_dst_path): + with zipfile.ZipFile(package_src_path, allowZip64=True) as zip_file, TemporaryDirectory() as temp_dir: + zip_file.extractall(temp_dir) + # Recursively copy (temp_dir will be automatically cleaned up on exit) + try: + # Recursive copy is needed because both package name and version folder could be missing in + # target directory: + shutil.copytree(temp_dir, package_dst_path) + except OSError, exc: + logger.warning("Directory %s already present, unpacking failed (Exception message: %s)" % + (package_dst_path, exc.strerror)) + raise + else: + logger.info("Package successfully installed to %s" % package_dst_path) + + +install_package(sys.argv[1], sys.argv[2])
\ No newline at end of file |