How to use the shiv.bootstrap.extract_site_packages function in shiv

To help you get started, we’ve selected a few shiv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linkedin / shiv / test / test_bootstrap.py View on Github external
def test_extract_site_packages(self, tmpdir, zip_location, nested, compile_pyc, force):

        zipfile = ZipFile(str(zip_location))
        target = Path(tmpdir, "test")

        if nested:
            # we want to test for not-yet-created shiv root dirs
            target = target / "nested" / "root"

        if force:
            # we want to make sure we overwrite if the target exists when using force
            target.mkdir(parents=True, exist_ok=True)

        # Do the extraction (of our empty zip file)
        extract_site_packages(zipfile, target, compile_pyc, force=force)

        site_packages = target / "site-packages"
        assert site_packages.exists()
        assert site_packages.is_dir()
        assert Path(site_packages, "test").exists()
        assert Path(site_packages, "test").is_file()