Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload-pypi: allow dry running the script with a dev version #9886

Merged
merged 1 commit into from Jan 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions misc/upload-pypi.py
Expand Up @@ -59,7 +59,15 @@ def check_sdist(dist: Path, version: str) -> None:
with tarfile.open(sdist) as f:
version_py = f.extractfile(f"{sdist.name[:-len('.tar.gz')]}/mypy/version.py")
assert version_py is not None
assert f"'{version}'" in version_py.read().decode("utf-8")
version_py_contents = version_py.read().decode("utf-8")

# strip a git hash from our version, if necessary, since that's not present in version.py
match = re.match(r"(.*\+dev).*$", version)
hashless_version = match.group(1) if match else version

assert (
f"'{hashless_version}'" in version_py_contents
), "Version does not match version.py in sdist"


def spot_check_dist(dist: Path, version: str) -> None:
Expand Down Expand Up @@ -92,7 +100,11 @@ def upload_dist(dist: Path, dry_run: bool = True) -> None:


def upload_to_pypi(version: str, dry_run: bool = True) -> None:
assert re.match(r"0\.[0-9]{3}$", version)
assert re.match(r"v?0\.[0-9]{3}(\+\S+)?$", version)
if "dev" in version:
assert dry_run, "Must use --dry-run with dev versions of mypy"
if version.startswith("v"):
version = version[1:]

target_dir = tempfile.mkdtemp()
dist = Path(target_dir) / "dist"
Expand Down