Skip to main content

A friendly CLI tool to check and publish Python packages to TestPyPI/PyPI

Project description

๐Ÿš€ KX-Publish-PyPI

PyPI version Python 3.9+ License: MIT Build Status Code Coverage Website

โœจ A beautiful, intelligent CLI tool to streamline Python package publishing to PyPI and TestPyPI

KX-Publish-PyPI is an interactive command-line interface that simplifies the entire process of preparing, building, and publishing Python packages. With enhanced version detection supporting all modern build backends, rich visual feedback, intelligent error handling, and secure token management, it makes package publishing as smooth as a breeze.

๐ŸŽฏ Enhanced Version Detection System - Works with ANY modern Python package configuration including setuptools, scikit-build-core, setuptools-scm, flit, hatchling, and more!

๐ŸŒŸ Features

  • ๐ŸŽจ Beautiful Interface: Rich, colorful output with progress bars and interactive prompts
  • ๐Ÿ” Smart Pre-checks: Validates your package structure, version, and configuration before publishing
  • ๐Ÿ”ง Enhanced Version Detection: Comprehensive support for all modern Python packaging approaches
    • โœ… Static versions in pyproject.toml
    • โœ… Dynamic versions with setuptools, scikit-build-core, setuptools-scm, flit, hatchling
    • โœ… Intelligent fallback system with 5-stage detection process
    • โœ… Rich diagnostics showing detection method, source, and confidence scoring
  • ๐Ÿ” Secure Token Management: Uses your system's keyring for safe API token storage
  • ๐Ÿ“ฆ Dual Publishing: Supports both TestPyPI and PyPI with intelligent workflows
  • ๐Ÿš€ Interactive Workflow: Guided experience from check to publish
  • ๐Ÿ“ˆ Version Management: Smart version bumping (patch, minor, major)
  • ๐Ÿ› ๏ธ Build Integration: Works with modern build backends (setuptools, flit, hatchling, etc.)
  • ๐ŸŽฏ CI/CD Ready: Perfect for automation and continuous delivery pipelines

๐Ÿ†• What's New in Version 1.0.0

๐ŸŽŠ Major Release - Complete KX Rebranding

  • โœ… New Package Name: kx_publish_pypi (upgraded from legacy naming)
  • โœ… New CLI Command: kx-publish-pypi
  • โœ… Enhanced Repository: Now at github.com/Khader-X/kx-publish-pypi
  • โœ… Website Integration: Visit KhaderX.com for more tools and resources

๐Ÿš€ Enhanced Version Detection System

  • โœ… Universal compatibility with all modern Python build backends
  • โœ… Intelligent 5-stage fallback detection process- โœ… Rich diagnostics showing detection method, source, and confidence
  • โœ… Programmatic API for advanced integration
  • โœ… Comprehensive support for dynamic versioning configurations

๐Ÿ“Š Enhanced Output Example

๐Ÿ”ข Version .......................... โœ… (v1.0.0 (setuptools_dynamic_attr) dynamic backend:setuptools)

This shows you:

  • Version: 1.0.0
  • Detection Method: setuptools_dynamic_attr
  • Type: dynamic versioning
  • Build Backend: setuptools

๐Ÿ› ๏ธ Installation

From PyPI (Recommended)

pip install kx-publish-pypi

Verify Installation

kx-publish-pypi --version

From GitHub (Latest Development)

# Install from latest release
pip install git+https://github.com/Khader-X/kx-publish-pypi.git@main

# Install from specific version
pip install git+https://github.com/Khader-X/kx-publish-pypi.git@v1.0.0

From Source (Development)

git clone https://github.com/Khader-X/kx-publish-pypi.git
cd kx-publish-pypi
pip install -e .

Requirements

  • Python 3.9+
  • twine for uploads
  • build for package building
  • keyring for secure token storage

๐Ÿš€ Quick Start

  1. Install the package

    pip install kx-publish-pypi
    
  2. Set up your API tokens

    kx-publish-pypi setup-tokens
    
  3. Publish your package

    kx-publish-pypi run
    

That's it! The guided workflow will handle everything else.

๐Ÿ“– Usage

Interactive Publishing (Recommended)

kx-publish-pypi run

This command provides a complete guided experience:

  • โœ… Runs pre-publish checks with enhanced version detection
  • ๐Ÿ”‘ Manages API token configuration
  • ๐Ÿ“ˆ Offers version bumping options
  • ๐Ÿ—๏ธ Builds your package distributions
  • ๐Ÿ“ค Publishes to TestPyPI and/or PyPI

Individual Commands

# Run pre-publish checks with enhanced version detection
kx-publish-pypi check

# Bump version
kx-publish-pypi bump patch

# Publish to TestPyPI only
kx-publish-pypi publish-test

# Publish to PyPI only
kx-publish-pypi publish-prod

Programmatic API

KX-Publish-PyPI exposes a powerful programmatic API for version detection:

from kx_publish_pypi import detect_package_version, get_package_version
from pathlib import Path

# Simple version detection (legacy interface)
version = get_package_version(Path("."))
print(f"Version: {version}")

# Enhanced detection with full diagnostics
result = detect_package_version(Path("."))
if result.version_info:
    info = result.version_info
    print(f"Version: {info.version}")
    print(f"Method: {info.method}")
    print(f"Backend: {info.build_backend}")
    print(f"Confidence: {info.confidence}%")
    print(f"Source: {info.source}")
else:
    print("Version detection failed")
    for diagnostic in result.diagnostics:
        print(f"Tried {diagnostic.method}: {diagnostic.error}")

๐Ÿ“‹ Command Reference

Command Description
kx-publish-pypi --version Show CLI version
kx-publish-pypi check Run interactive pre-publish checks
kx-publish-pypi bump [patch|minor|major] Bump package version
kx-publish-pypi setup-tokens Configure API tokens interactively
kx-publish-pypi update-tokens Update existing tokens
kx-publish-pypi run Complete guided publishing workflow
kx-publish-pypi publish-test Publish to TestPyPI
kx-publish-pypi publish-prod Publish to PyPI

Command Options

Token Setup

# Interactive setup
kx-publish-pypi setup-tokens

# Non-interactive setup
kx-publish-pypi setup-tokens --test-token YOUR_TEST_TOKEN --prod-token YOUR_PROD_TOKEN

Version Bumping

kx-publish-pypi bump patch  # 1.0.0 โ†’ 1.0.1
kx-publish-pypi bump minor  # 1.0.1 โ†’ 1.1.0
kx-publish-pypi bump major  # 1.1.0 โ†’ 2.0.0

๐Ÿ” Token Management

KX-Publish-PyPI securely stores your PyPI API tokens using your system's keyring:

  • TestPyPI: Stored as kx-publish-testpypi
  • PyPI: Stored as kx-publish-pypi

Tokens are encrypted and stored safely in your system's credential manager (Windows Credential Manager, macOS Keychain, or Linux Secret Service).## ๐Ÿ”ง Enhanced Version Detection

KX-Publish-PyPI features a comprehensive version detection system that handles all modern Python packaging approaches:

Supported Build Backends

  • โœ… setuptools (static and dynamic versions)
  • โœ… setuptools-scm (Git-based versioning)
  • โœ… scikit-build-core (CMake integration)
  • โœ… flit (simple Python packaging)
  • โœ… hatchling (modern Python packaging)
  • โœ… pdm-backend (PDM packaging)
  • โœ… poetry-core (Poetry packaging)

Detection Methods

  1. Static pyproject.toml version
  2. Dynamic setuptools attributes
  3. setuptools-scm Git tags
  4. scikit-build-core dynamic versioning
  5. Package attribute inspection

Usage Tips

  1. Ensure your pyproject.toml is properly configured
  2. For dynamic versioning, make sure your version module is importable
  3. For Git-based versioning, ensure you have proper tags
  4. Use enhanced diagnostics: kx-publish-pypi check shows detailed detection attempts

๐Ÿ’ก Examples

Basic Publishing Workflow

# Check your package
kx-publish-pypi check

# Bump version if needed
kx-publish-pypi bump patch

# Set up tokens (first time only)
kx-publish-pypi setup-tokens

# Test publish
kx-publish-pypi publish-test

# Publish to production
kx-publish-pypi publish-prod

Development Workflow

# One-command publishing
kx-publish-pypi run

# Check with verbose output
kx-publish-pypi run --verbose

๐Ÿš€ CI/CD Integration

KX-Publish-PyPI works great with CI/CD pipelines:

GitHub Actions Example

- name: Publish to PyPI
  run: |
    pip install kx-publish-pypi
    kx-publish-pypi setup-tokens --test-token ${{ secrets.TEST_PYPI_TOKEN }} --prod-token ${{ secrets.PYPI_TOKEN }}
    kx-publish-pypi publish-prod

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

Development Setup

git clone https://github.com/Khader-X/kx-publish-pypi.git
cd kx-publish-pypi
pip install -e .

Running Tests

python -m pytest tests/

Code Style

We use black for code formatting and flake8 for linting.

๐Ÿ“š Documentation

๐Ÿ†˜ Support & Community

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

โค๏ธ Acknowledgments


Made with โค๏ธ by KhaderX

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kx_publish_pypi-1.0.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kx_publish_pypi-1.0.0-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file kx_publish_pypi-1.0.0.tar.gz.

File metadata

  • Download URL: kx_publish_pypi-1.0.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for kx_publish_pypi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e03a20adc2c29e1040e53144f578c1fe1d67656205e06d6922da77a0d2826a03
MD5 02c3fa27f748795523af581dd0c8d9f8
BLAKE2b-256 a86609c39d9d8970d67278dfffa0a5e22c7a279bbc69f9b73bb2182dff554aae

See more details on using hashes here.

File details

Details for the file kx_publish_pypi-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kx_publish_pypi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20fef737028cbf03ad74864a3f78780ced9f8fe9dddd3879190f780613a87489
MD5 690407fc0a8a3aff78301b2c9968cacb
BLAKE2b-256 bcc871f0d5c151608ccb596ab5dcb566ce92d7aab837006f1fb7d765db4bfd01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page