Skip to main content

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

Project description

khx_publish_p### CLI Commands### Quick Start

# 1) Configure tokens (interactive)
khx-publish-pypi setup-tokens

# Or configure non-interactively
khx-publish-pypi setup-tokens --test-token YOUR_TEST_TOKEN --prod-token YOUR_PROD_TOKEN

# 2) Update tokens later (interactive)
khx-publish-pypi update-tokens

# 3) Run the guided flow
khx-publish-pypi init
```h-pypi --version`  show CLI version
- `khx-publish-pypi check`  run interactive pre-publish checks
- `khx-publish-pypi bump [patch|minor|major]`  bump `__version__`
- `khx-publish-pypi setup-tokens`  securely configure API tokens (interactive)
- `khx-publish-pypi update-tokens`  interactively update existing API tokens
- `khx-publish-pypi init`  guided flow: checks  tokens  bump  build  publish
- `khx-publish-pypi publish-test`  publish to Test PyPI
- `khx-publish-pypi publish-prod`  publish to PyPInteractive, friendly CLI to check, build, and publish Python packages to TestPyPI and PyPI  with beautiful output and guardrails. ✨

Why use it?
- Fast pre-publish checks (name/version/structure)
- Guided token setup using your OS keyring
- Smart suggestions when uploads fail (version conflicts, auth, etc.)
- One command to run checks  build  publish

### Installation
- From source (editable):
```bash
pip install -e .

CLI Commands

  • khx-publish-pypi --version — show CLI version
  • khx-publish-pypi check — run interactive pre-publish checks
  • khx-publish-pypi bump [patch|minor|major] — bump __version__
  • khx-publish-pypi setup-tokens — securely configure API tokens (interactive)
  • khx-publish-pypi update-tokens --test-token TOKEN --prod-token TOKEN — update tokens (non-interactive)
  • khx-publish-pypi init — guided flow: checks → tokens → bump → build → publish
  • khx-publish-pypi publish-test — publish to TestPyPI
  • khx-publish-pypi publish-prod — publish to PyPI

Quick Start

# 1) Configure tokens (interactive)
khx-publish-pypi setup-tokens

# Or configure non-interactively
khx-publish-pypi setup-tokens --test-token YOUR_TEST_TOKEN --prod-token YOUR_PROD_TOKEN

# 2) Update tokens later
khx-publish-pypi update-tokens --test-token NEW_TEST_TOKEN

# 3) Run the guided flow
khx-publish-pypi init

The init flow will:

  1. Run checks and show a friendly report
  2. Let you configure tokens (or confirm existing)
  3. Optionally bump the package version
  4. Build distributions in dist/
  5. Publish to TestPyPI, PyPI, or both

Version Management

khx-publish-pypi bump patch  # 0.1.0 -> 0.1.1
khx-publish-pypi bump minor  # 0.1.1 -> 0.2.0
khx-publish-pypi bump major  # 0.2.0 -> 1.0.0

Programmatic Version

from khx_publish_pypi import __version__
print(__version__)

Token Storage

Tokens are stored via your system keyring under:

  • TestPyPI: khx-publish-testpypi
  • PyPI: khx-publish-pypi

Important: PyPI API tokens require the username to be __token__ for authentication.

You can also provide TESTPYPI_TOKEN or PYPI_TOKEN as environment variables.

Token Management

  • Initial setup: khx-publish-pypi setup-tokens (interactive)
  • Update tokens: khx-publish-pypi update-tokens (interactive)
  • Non-interactive setup: khx-publish-pypi setup-tokens --test-token YOUR_TOKEN --prod-token YOUR_TOKEN

Troubleshooting Uploads

If an upload fails, the CLI analyzes the error and suggests fixes. Common issues:

  • Version exists (400): bump version → khx-publish-pypi bump patch
  • Auth issues (403): reconfigure → khx-publish-pypi setup-tokens
  • Invalid dists: rebuild → python -m build, then retry

CI/CD

  • Run khx-publish-pypi check in CI to validate before release
  • Use python -m build to create artifacts, then upload with Twine

Roadmap

  • JSON output option for CI
  • Wizard mode refinements
  • Custom repository support

License

MIT © ABUELTAYEF Khader

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

khx_publish_pypi-0.1.5.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

khx_publish_pypi-0.1.5-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file khx_publish_pypi-0.1.5.tar.gz.

File metadata

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

File hashes

Hashes for khx_publish_pypi-0.1.5.tar.gz
Algorithm Hash digest
SHA256 b0d5f5871d782382a4d664bb6bbc7b0f7d40441cf283d88c0e9ca9fd68d6ef60
MD5 82b45385fa3bff47b538bf13ecfa428a
BLAKE2b-256 e690fb7b6866bbeb3d05f4da979f708b196648429f594b7aafc684360fc1ca82

See more details on using hashes here.

File details

Details for the file khx_publish_pypi-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for khx_publish_pypi-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 45d41861196ff97dd7355db64d947e8cdcfa878c94b0483f284d0c1e1e851a38
MD5 ccdcbd81031fcf17fa0ddeca6e9382e0
BLAKE2b-256 176a1f1806f7c4a9c692f67202d36c9bf15c2abde004c7fa9a574b6cc1c162bf

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