CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-lastversion

A CLI tool to find the latest stable version of an arbitrary project

Pending
Overview
Eval results
Files

core-functions.mddocs/

Core Functions

Primary API functions for version discovery and update checking across multiple hosting platforms. These functions provide the main programmatic interface for determining latest versions and checking for available updates.

Capabilities

Latest Version Discovery

Discovers the latest stable version of a software project from various hosting platforms including GitHub, GitLab, PyPI, BitBucket, and others. Supports extensive filtering and output formatting options.

def latest(
    repo: str,
    output_format: str = "version",
    pre_ok: bool = False,
    assets_filter: Union[str, Pattern] = None,
    short_urls: bool = False,
    major: str = None,
    only: str = None,
    at: str = None,
    having_asset: str = None,
    exclude: str = None,
    even: bool = False,
    formal: bool = False
) -> Union[Version, dict, str, None]:
    """
    Find the latest release version for a project.

    Parameters:
    - repo: Repository specifier (URL, owner/name, or package name)
    - output_format: Return format - "version" (default), "json", "dict", "assets", "source", "tag"
    - pre_ok: Whether to accept pre-release versions as latest
    - assets_filter: Regex pattern for filtering release assets
    - short_urls: Return shorter URLs when possible
    - major: Only consider versions descended from this major version
    - only: Only consider tags containing this text (supports regex with ~ prefix, negation with !)
    - at: Platform hint ("github", "gitlab", "pip", etc.) for disambiguation
    - having_asset: Only consider releases that have assets matching this pattern
    - exclude: Exclude versions matching this pattern
    - even: Only consider even version numbers
    - formal: Only consider formal releases (no pre-release indicators)

    Returns:
    - With output_format="version": Version object or None
    - With output_format="dict": Dictionary with version info or False
    - With output_format="json": JSON string representation
    - With output_format="assets": List of asset URLs
    - With output_format="source": Source download URL
    - With output_format="tag": Tag name string
    """

Update Availability Check

Checks whether a newer version is available for a given current version of a software project.

def has_update(
    repo: str,
    current_version: str,
    pre_ok: bool = False,
    at: str = None
) -> Union[Version, bool]:
    """
    Check if there is an update available for the current version.

    Parameters:
    - repo: Repository specifier in any supported format
    - current_version: Current version string to check against
    - pre_ok: Whether pre-releases can be accepted as newer versions
    - at: Platform hint for disambiguation when repo is ambiguous

    Returns:
    - Version object if newer version found
    - False if no update available or current version is latest
    """

Version Validation

Validates and normalizes version strings according to packaging standards with lastversion-specific enhancements.

def check_version(value: str) -> Version:
    """
    Validate and parse a version string.

    Parameters:
    - value: Version string to validate and parse

    Returns:
    - Version object with normalized version
    
    Raises:
    - InvalidVersion: If version string cannot be parsed
    """

Command Line Interface

Main entry point for command-line usage providing access to all functionality through CLI arguments.

def main(argv: List[str] = None) -> None:
    """
    Main entry point for CLI usage.

    Parameters:
    - argv: Command line arguments (uses sys.argv if None)
    
    Provides CLI access to:
    - Version discovery with various output formats
    - Asset downloading and extraction
    - Update checking
    - Installation of discovered releases
    - RPM spec file integration
    """

Usage Examples

Basic Version Discovery

from lastversion import latest

# Get latest version of a GitHub project
version = latest("mautic/mautic")
print(f"Latest version: {version}")  # e.g., "4.4.5"

# Get detailed release information
release_info = latest("mautic/mautic", output_format="dict")
print(f"Release date: {release_info.get('date')}")
print(f"Download URL: {release_info.get('download_url')}")

Platform-Specific Queries

from lastversion import latest

# Check PyPI package version
requests_version = latest("requests", at="pip")
print(f"Latest requests: {requests_version}")

# Check GitLab project
gitlab_version = latest("gitlab-org/gitlab", at="gitlab")
print(f"Latest GitLab: {gitlab_version}")

Update Checking

from lastversion import has_update

# Check for updates
current = "1.2.3"
update = has_update("owner/project", current)

if update:
    print(f"Update available: {current} → {update}")
else:
    print("Already at latest version")

Advanced Filtering

from lastversion import latest

# Only stable releases from a major version
version = latest("kubernetes/kubernetes", major="1.28", pre_ok=False)

# Filter by asset availability
version = latest("project/name", having_asset=r".*\.dmg$")

# Only even version numbers
version = latest("project/name", even=True)

# Exclude specific patterns
version = latest("project/name", exclude=r".*beta.*")

Output Format Options

from lastversion import latest

repo = "apache/httpd"

# Get Version object (default)
version_obj = latest(repo)

# Get as dictionary
version_dict = latest(repo, output_format="dict")

# Get as JSON string
version_json = latest(repo, output_format="json")

# Get source download URL
source_url = latest(repo, output_format="source")

# Get release assets
assets = latest(repo, output_format="assets")

# Get git tag name
tag = latest(repo, output_format="tag")

Install with Tessl CLI

npx tessl i tessl/pypi-lastversion

docs

core-functions.md

exceptions.md

index.md

repository-holders.md

utilities.md

version-handling.md

tile.json