Skip to content

Packs / package-publishing-public

claim-or-update-a-pypi-name

Before you upload: check a PyPI/TestPyPI name (PEP 503 normalization, PEP 508 syntax, taken or free) and plan the next version (refuses versions that exist, were deleted, or sort older than the latest).

L2 Checks passed 3 of 3 runsv1.0.0Tech-Realm/space-package-publishing-public

Install

logicpacks pack use package-publishing-public/claim-or-update-a-pypi-name
get_pack package-publishing-public/claim-or-update-a-pypi-name

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

  • PYPI_TOKEN

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: json-apiclaim-by-upload
  • Checks: 5 in outcome/checks.yaml
  • Code: pypi_name.py
  • Tools: python3

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Decide whether a package name can be claimed on PyPI (or TestPyPI), and whether a planned version can be uploaded, before running the publish pack.

Goal

pypi_name.py status NAME says taken or available (normalized), and pypi_name.py plan NAME VERSION says ok, or refuses with the reason and the next usable version.

Steps

  1. Syntax: python3 code/pypi_name.py valid NAME (letters, digits, . _ -, start and end alphanumeric).
  2. Normalize: python3 code/pypi_name.py normalize NAME. PyPI treats Foo_Bar.baz and foo-bar-baz as one name.
  3. Look up: python3 code/pypi_name.py status NAME (add --test for test.pypi.org; the two indexes are separate, so claim the TestPyPI name too if you rehearse there).
  4. Claim a free name: the first successful upload claims it (publish-python-package-to-pypi), or create a pending trusted publisher on pypi.org (GitHub Actions OIDC) to reserve it without a token.
  5. Update a name you own: python3 code/pypi_name.py plan NAME VERSION; if refused, python3 code/pypi_name.py bump <latest> patch and bump pyproject + __version__.
  6. A taken but abandoned name: PEP 541 request on the pypi/support tracker; there is no other transfer path.

Edge cases

  • "Available" from the JSON API is not a guarantee: PyPI blocks names too similar to existing projects (confusables) and prohibited names; only the upload proves the claim.
  • The releases map keeps versions whose files were deleted. Those versions can never be uploaded again.
  • An upload with a version lower than the latest is allowed, but installers keep resolving the latest, so the plan refuses it unless you mean a backport.
  • The JSON API is CDN-cached: a version uploaded a minute ago may still look missing.

Don'ts

  • Don't register throwaway names to squat them (PyPI terms; PEP 541 removes them).
  • Don't delete a release to "fix" it: the version number is burned. Upload a .post or patch release.