Skip to content
rlsbl.targets.pypi
On this page

PyPI release target that manages version tracking in pyproject.toml and scaffolds CI workflows for OIDC-based publishing to the PyPI index.

#rlsbl.targets.pypi

#rlsbl.targets.pypi

PyPI release target that manages version tracking in pyproject.toml and scaffolds CI workflows for OIDC-based publishing to the PyPI index.

#find_dunder_version_node

python
def find_dunder_version_node(content: str) -> 'ast.Constant | None'

Find an __version__ assignment with a static string literal via AST.

Handles both plain assignments (__version__ = "1.0.0") and typed annotations (__version__: str = "1.0.0"). Returns the ast.Constant node for the string value, or None if not found or the file has a syntax error.

#has_any_dunder_version

python
def has_any_dunder_version(content: str) -> bool

Check whether the source contains any form of __version__ definition.

Returns True if the content contains any assignment, annotated assignment, or import of __version__ -- regardless of whether the value is a static literal. Returns False on SyntaxError or if no __version__ definition is found.

#PypiTarget

Release target for Python projects (pyproject.toml).

#name

python
def name(self)

#detect

python
def detect(self, dir_path)

Return True if dir_path contains a pyproject.toml with a [project] table.

#read_name

python
def read_name(self, dir_path, ctx)

Read the project name from pyproject.toml.

#read_metadata

python
def read_metadata(self, dir_path)

Read license and description from pyproject.toml.

#publication_probe

python
def publication_probe(self, dir_path, version, ctx=None)

Probe PyPI for a specific version of this package.

#format_version

python
def format_version(self, version)

Translate semver pre-release to PEP 440 format.

  • 1.2.3-alpha.0 -> 1.2.3a0
  • 1.2.3-beta.1 -> 1.2.3b1
  • 1.2.3-rc.2 -> 1.2.3rc2
  • Stable versions pass through unchanged.

#_pep440_to_semver

python
def _pep440_to_semver(version)

Translate PEP 440 pre-release back to semver format.

  • 1.2.3a0 -> 1.2.3-alpha.0
  • 1.2.3b1 -> 1.2.3-beta.1
  • 1.2.3rc2 -> 1.2.3-rc.2
  • Stable versions pass through unchanged.

#read_version

python
def read_version(self, dir_path)

Read the version from pyproject.toml in the given directory.

If the version is in PEP 440 pre-release format (e.g. 1.2.3a0), it is converted back to semver format (1.2.3-alpha.0) so that all internal version handling uses a consistent semver representation.

#write_version

python
def write_version(self, dir_path, version, ctx)

Write a new version to pyproject.toml and __version__ in package source.

Translates semver pre-release versions to PEP 440 format before writing (e.g. 1.2.3-alpha.0 -> 1.2.3a0).

Returns a list of relative file paths (relative to dir_path) that were modified.

#_update_dunder_version

python
def _update_dunder_version(self, dir_path, doc, version)

Update __version__ in the package's __init__.py if present.

Uses AST parsing to find __version__ assignments with static string literals, handling plain assignments and typed annotations.

Returns the relative path (relative to dir_path) of the file that was modified, or None if no file was updated.

#version_file

python
def version_file(self, dir_path=None)

Return the version file name for PyPI projects.

#tag_format

python
def tag_format(self, version)

Return the git tag string for a PyPI release version.

#template_dir

python
def template_dir(self)

Return the path to the PyPI-specific template directory.

#template_vars

python
def template_vars(self, dir_path, ctx)

Extract template variables from the target project's pyproject.toml.

#template_mappings

python
def template_mappings(self, ctx)

Return the PyPI-specific CI workflow template mapping.

#build

python
def build(self, dir_path, version, *, config=None)

Build the package, rewriting path deps if in a monorepo context.

When the project has path dependencies (e.g., sibling packages in a monorepo), copies the project to a temp directory with rewritten pyproject.toml so the working tree is never modified. Otherwise runs uv build in place.

#_build_with_rewrite

python
def _build_with_rewrite(self, dir_path, pyproject_path, rewrite_map, *, timeout=120)

Copy project to a temp dir with rewritten deps, then build.

#check_project_exists

python
def check_project_exists(self, dir_path)

Return True if pyproject.toml exists in dir_path.

#get_project_init_hint

python
def get_project_init_hint(self)

Return a hint for initializing a Python project.

#dev_install_command

python
def dev_install_command(self, project_dir)

Return install specs for editable Python installs via uv.

#registry_display_name

python
def registry_display_name(self)

#run_tests

python
def run_tests(self, *, project_dir=None, workspace_root=None, skip_sync=False, config=None, check_timeout=None)

Run the Python suite via uv (or bare pytest when uv is absent).

#find_dead_modules

python
def find_dead_modules(self, root, *, exclude_dirs=None, suppress=frozenset())

Union-of-imports detector over the project's Python modules.

#find_circular_dependencies

python
def find_circular_dependencies(self, root, *, exclude_dirs=None)

Detect circular imports between the project's Python modules.

#normalize_package_name

python
def normalize_package_name(self, raw_name)

PyPI folds runs of -_. to a single hyphen (PEP 503).

#query_latest_version

python
def query_latest_version(self, name)

Ask PyPI for the latest published version.

#claim_placeholder

python
def claim_placeholder(self, name, tmpdir)

Build and publish a version 0.0.0 sdist/wheel to reserve name.

#yank

python
def yank(self, project_dir, version, tag, *, reason=None, dry_run=False)

Walk the operator through PyPI's manual yank.

PyPI exposes no yank API, so this target prints the steps and waits for the operator to confirm they performed them. The confirmation is the only honest answer available: nothing here can verify the yank.

More tools from this site

  • claudestream Drive Claude Code from Python: run it as a subprocess and read its output as typed events, with async and sync sessions, sandbox policies, and tools you define in Python
  • claudewheel A TUI Claude Code Launcher that lets you have more than one profile, manage sessions lifecycle, pick the exact CC version, model to use (even older unlisted ones), pick which GitHub account to use, etc.
  • dirstat Fast, single-binary directory statistics CLI: every file under a tree grouped by format, with counts, sizes, and lines of code, as a colored terminal table or as JSON
  • fastware A batteries-included ASGI framework: msgspec JSON, a managed Granian server, dependency injection, SSE, WebSockets, auth, and a test client
  • go-toml-edit Zero-dep TOML editing library for Go with comment preservation
  • howmuchleft The fastest Claude Code statusline: context window, 5-hour, and weekly limit usage as three customizable gradient bars, rendering in about 6 ms
  • orxtra
  • pgdesign
  • predraw Declarative rendering pipeline: describe a scene in JSON and get SVG, PNG and WebP out, with light and dark style tokens, reusable components and text converted to path outlines
  • reposummary Turn a git repository's history into a Markdown journal: pick a time window or revision range and get a readable digest of what changed, optionally narrated by an LLM
  • safegit git wrapper CLI that gives each commit its own temporary index and retries ref updates on conflict, so concurrent agents share one repository
  • saferm Command-line replacement for rm that archives every deletion with a mandatory reason and the context it ran in, so deleted files can be listed, inspected and restored
  • selfdoc Static Site Generator that builds a project's documentation site directly from its source code, so the docs can never drift from the code they describe, with SEO/AEO, first-class blog, search, and cross-project linking built in
  • strictcli
  • stricttest An always-on test-isolation floor: a pytest plugin and a Go env-hygiene module that make a test suite structurally unable to reach real credentials, the real HOME, the network, or the development repository.
  • wesktop A Python framework that turns an ASGI web app into a desktop application, serving it from a local Granian server and displaying it in a native OS window via pywebview
Search