def extract(self, path, to_folder): if to_folder is not None: root = ReentrantFileLock(to_folder()) else: root = self.lock / "unzip" / __version__ with root.lock_for_key(path.name): dest = root.path / path.name if not dest.exists(): extract(path, dest) yield dest
def acquire_from_bundle(packages, for_py_version, to_folder): for pkg, version in list(packages.items()): bundle = get_bundled_wheel(pkg, for_py_version) if bundle is not None: pkg_version = bundle.stem.split("-")[1] exact_version_match = version == pkg_version if exact_version_match: del packages[pkg] if version is None or exact_version_match: bundled_wheel_file = to_folder / bundle.name if not bundled_wheel_file.exists(): logging.debug("get bundled wheel %s", bundle) if IS_ZIPAPP: from virtualenv.util.zipapp import extract extract(bundle, bundled_wheel_file) else: copy2(str(bundle), str(bundled_wheel_file))