harbor run -t openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-3784harbor download openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-3784PSEUDOCODE
Module: scripts/release.py
Define exception ReleaseError as subclass of ValueError
Define RX_VERSION as a compiled regular expression that matches semantic-like version strings of the form: major.minor.patch with optional qualifiers:
Function parse_version(version: STRING) -> OBJECT // Returns a structured object representing the version // Required by tests (and by other helpers) // The object must support: // - property is_prerelease indicating whether the version includes any prerelease qualifier // - property base_version returning the base "major.minor.patch" string // - comparison operators to compare two parsed versions (based on semantic ordering) // Behavior: // Validate version against RX_VERSION; on mismatch, raise ValueError with a clear message
Function split_version(version: STRING, base: BOOLEAN = TRUE) -> TUPLE // Validate with RX_VERSION; on mismatch raise ValueError("Invalid version: %s" % version) // If base is TRUE: // Return a 3-tuple (major:int, minor:int, patch:int) derived from the numeric parts // If base is FALSE: // Start with (major, minor, patch) as above // If a pre/post suffix exists (e.g., -rc1, -dev, .post1), append that exact suffix string as the next element // If a dev suffix exists (e.g., +dev or -rc1+dev), include it as an additional string in the next position // Examples: // '0.1.0-rc1' -> (0, 1, 0, '-rc1') // '0.1.0-rc1+dev' -> (0, 1, 0, '-rc1', '+dev') // '0.1.0.post1' -> (0, 1, 0, '.post1') // '0.1.0-dev' -> (0, 1, 0, '-dev') // '0.1.0+dev' -> (0, 1, 0, '+dev') // If the form is invalid for base=False, raise ValueError("Invalid version string: %s" % version)
Function propose_next_version(dev_version: STRING) -> STRING // If dev_version represents a prerelease (parse_version(dev_version).is_prerelease): // Return parse_version(dev_version).base_version // Else: // Let base_version = parse_version(dev_version).base_version // (major, minor, patch) = split_version(base_version) // Return string "%d.%d.%d" % (major, minor, patch + 1)
Function version_ok(version: STRING, dev_version: STRING, released_versions: LIST[STRING] = []) -> BOOLEAN // Determine if a candidate release version is acceptable given the current development version and previously released versions // Rules (aligned with tests): // If version matches RX_VERSION and contains a dev suffix (e.g., -dev, +dev, etc.): // echo a helpful message via click.echo (informational; tests do not assert on messages) // If version is in released_versions: // return False // If parse_version(version) > parse_version(dev_version): // return True // Otherwise: // echo an explanatory message and return False
Function get_package_name() -> STRING // Inspect repository's src/ directory // Find the first subdirectory that looks like a Python package, excluding egg-info // If found, return that directory name // If none found, raise ReleaseError("Cannot find package name")
Function get_pypi_versions(package_name: STRING) -> LIST[STRING] // Fetch JSON metadata from PyPI at "https://pypi.python.org/pypi/<package_name>/json" // Extract versions from data["releases"].keys() // Sort versions using parse_version // Return the sorted list // Do not suppress network errors; allow OSError (tests handle)
Function get_local_versions() -> LIST[STRING] // Use Git library (git.Repo) to read local tags // Collect versions from tags that start with 'v', stripping the leading 'v' // Return the list of versions // Propagate repository or tag errors to caller
Function get_version(filename: STRING) -> STRING // Open the given Python file // Find a line defining version = "..." (or similar) // Extract and return the string value (without quotes) // If not found, raise ReleaseError("Cannot extract version from %s" % filename)
Function list_versions(package_name: STRING) -> LIST[STRING] // Try to obtain PyPI versions // Try get_pypi_versions(package_name) // If an OSError occurs: // print "PyPI versions no available" // pypi_versions := [] // Obtain local versions: get_local_versions() // Compute union of pypi_versions and local_versions // Sort union by parse_version // For each version in the sorted list: // If in both PyPI and local: status := "PyPI/local" // Else if in PyPI only: status := "PyPI only!" // Else (local only): status := "local only!" // Print: left-justify version to width 20, followed by status // Return the complete list of versions (from both sources)
Notes on behavior and constraints
Non-functional requirements
Deliverable