Esempio n. 1
0
def upload_zip(zip_file: str, package_path: str = None):
    packer = packaging.detect_packer_from_file(zip_file)
    package_path, _, _ = packaging.detect_archive_names(packer, package_path)

    resolved_fs, path = filesystem.resolve_filesystem_and_path(package_path)

    with tempfile.TemporaryDirectory() as tempdir:
        parsed_url = parse.urlparse(zip_file)
        if parsed_url.scheme == "http":
            tmp_zip_file = os.path.join(tempdir,
                                        os.path.basename(parsed_url.path))
            request.urlretrieve(zip_file, tmp_zip_file)
            zip_file = tmp_zip_file

        _upload_zip(zip_file, package_path, resolved_fs)

        return package_path
Esempio n. 2
0
def upload_env(package_path: str = None,
               packer=None,
               additional_packages: Dict[str, str] = {},
               ignored_packages: Collection[str] = []) -> Tuple[str, str]:
    if packer is None:
        packer = packaging.detect_packer_from_env()
    package_path, env_name, pex_file = packaging.detect_archive_names(
        packer, package_path)

    resolved_fs, path = filesystem.resolve_filesystem_and_path(package_path)

    if not packaging._running_from_pex():
        _upload_env_from_venv(package_path, packer, additional_packages,
                              ignored_packages, resolved_fs)
    else:
        _upload_zip(pex_file, package_path, resolved_fs)

    return (package_path, env_name)
Esempio n. 3
0
def upload_env(package_path: str = None,
               packer: packaging.Packer = None,
               additional_packages: Dict[str, str] = {},
               ignored_packages: Collection[str] = [],
               force_upload: bool = False,
               include_editable: bool = False,
               fs_args: Dict[str, Any] = {}) -> Tuple[str, str]:
    if packer is None:
        packer = packaging.detect_packer_from_env()
    package_path, env_name, pex_file = packaging.detect_archive_names(
        packer, package_path)

    resolved_fs, path = filesystem.resolve_filesystem_and_path(
        package_path, **fs_args)

    if not packaging._running_from_pex():
        _upload_env_from_venv(package_path, packer, additional_packages,
                              ignored_packages, resolved_fs, force_upload,
                              include_editable)
    else:
        _upload_zip(pex_file, package_path, resolved_fs, force_upload)

    return (package_path, env_name)