A friendly CLI tool to check and publish Python packages to TestPyPI/PyPI
Project description
๐ KX-Publish-PyPI
โจ 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+
twinefor uploadsbuildfor package buildingkeyringfor secure token storage
๐ Quick Start
-
Install the package
pip install kx-publish-pypi
-
Set up your API tokens
kx-publish-pypi setup-tokens -
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
- Static pyproject.toml version
- Dynamic setuptools attributes
- setuptools-scm Git tags
- scikit-build-core dynamic versioning
- Package attribute inspection
Usage Tips
- Ensure your
pyproject.tomlis properly configured - For dynamic versioning, make sure your version module is importable
- For Git-based versioning, ensure you have proper tags
- Use enhanced diagnostics:
kx-publish-pypi checkshows 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
- ๐ Enhanced Version Detection Guide: Complete guide to the new version detection system
- ๐งช Test Examples: Comprehensive test suite demonstrating all capabilities
- ๐ป API Usage Examples: Programmatic usage examples
- ๐ Releasing Guide: How to release new versions of this package
๐ Support & Community
- ๐ Website: KhaderX.com - Explore more tools and resources
- ๐ Issues: GitHub Issues
- ๐ Documentation: GitHub Wiki
- ๐ฌ Discussions: GitHub Discussions
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
โค๏ธ Acknowledgments
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e03a20adc2c29e1040e53144f578c1fe1d67656205e06d6922da77a0d2826a03
|
|
| MD5 |
02c3fa27f748795523af581dd0c8d9f8
|
|
| BLAKE2b-256 |
a86609c39d9d8970d67278dfffa0a5e22c7a279bbc69f9b73bb2182dff554aae
|
File details
Details for the file kx_publish_pypi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: kx_publish_pypi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20fef737028cbf03ad74864a3f78780ced9f8fe9dddd3879190f780613a87489
|
|
| MD5 |
690407fc0a8a3aff78301b2c9968cacb
|
|
| BLAKE2b-256 |
bcc871f0d5c151608ccb596ab5dcb566ce92d7aab837006f1fb7d765db4bfd01
|