Ejemplo n.º 1
0
def analyze_dists(root: Path, dist_dir: str) -> Optional[DistInfo]:
    if not dist_dir:
        return None
    name = None
    version = None
    tarball_path = None
    dists = root / dist_dir
    for dist in dists.iterdir():
        if ".tar" in dist.suffixes:
            tmp_path = Path(tempfile.mkdtemp(suffix="tarfile"))
            shutil.unpack_archive(dist, tmp_path)
            tarball_path = tmp_path / dist.name
            # drop '.tar.gz' suffix
            tarball_path = tarball_path.with_suffix("").with_suffix("")
            assert tarball_path.is_dir()
            nam, ver = parse_sdist_filename(dist.name)
        else:
            nam, ver, build, tags = parse_wheel_filename(dist.name)
        if name is not None:
            assert name == nam, f"{nam} != {name} for {dist}"
        else:
            name = nam
        if version is not None:
            assert version == ver, f"{ver} != {version} for {dist}"
        else:
            version = ver

    assert version is not None
    assert name is not None
    assert tarball_path is not None
    return DistInfo(str(version), name, tarball_path)
Ejemplo n.º 2
0
def test_parse_sdist_invalid_filename(filename):
    with pytest.raises(InvalidSdistFilename):
        parse_sdist_filename(filename)
Ejemplo n.º 3
0
def test_parse_sdist_filename(filename, name, version):
    assert parse_sdist_filename(filename) == (name, version)