askrobots / dbbasic-cli-new
Public
The command-line tool for creating and managing DBBasic apps: thin scripts over git, cp and sed.
PUBLISHING.md · 3.5 KB · 180 lines
Publishing dbbasic-cli to PyPI
Prerequisites
- Install build tools:
pip install build twine
- Create PyPI account at https://pypi.org/account/register/
- Set up API token:
- Go to https://pypi.org/manage/account/token/
- Create new token (scope: Entire account or specific project)
- Save token securely
Build Distribution
# Clean previous builds
rm -rf build/ dist/ *.egg-info/
# Build packages
python -m build
# This creates:
# dist/dbbasic_cli-1.0.0-py3-none-any.whl
# dist/dbbasic_cli-1.0.0.tar.gz
Test on TestPyPI (Recommended First)
# Upload to TestPyPI
python -m twine upload --repository testpypi dist/*
# Test installation from TestPyPI
pip install --index-url https://test.pypi.org/simple/ dbbasic-cli
Publish to PyPI
# Upload to PyPI
python -m twine upload dist/*
# You'll be prompted for credentials:
# Username: __token__
# Password: pypi-... (your API token)
Install from PyPI
Once published, anyone can install with:
pip install dbbasic-cli
This will:
- Install the
dbbasic_cliPython package - Create the
dbbasiccommand globally (available in any directory) - Enable auto-discovery of module commands from other dbbasic-* packages
Testing Global Installation
After publishing, test in a fresh environment:
# Create clean virtual environment
python -m venv test_env
source test_env/bin/activate # On Windows: test_env\Scripts\activate
# Install from PyPI
pip install dbbasic-cli
# Test command
dbbasic help
dbbasic list
# Test from different directory
cd /tmp
dbbasic help
Version Bumping
Before each release:
- Update version in
dbbasic_cli/__init__.py:
__version__ = "1.0.1"
- Update version in
setup.py:
version="1.0.1",
- Create git tag:
git tag -a v1.0.1 -m "Release version 1.0.1"
git push origin v1.0.1
- Build and publish new version
Semantic Versioning
- Major (1.x.x): Breaking changes
- Minor (x.1.x): New features, backward compatible
- Patch (x.x.1): Bug fixes
Package Name Note
The PyPI package name is dbbasic-cli but:
- Import as:
import dbbasic_cli - Command name:
dbbasic(without -cli)
This matches the pattern of other CLIs like:
pip install django→ command:django-adminpip install flask→ command:flaskpip install pytest→ command:pytest
Continuous Integration (Future)
Consider setting up GitHub Actions to:
- Run tests on push
- Build packages on tag
- Auto-publish to PyPI on release
Example .github/workflows/publish.yml:
name: Publish to PyPI
on:
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
Current Status
Package: dbbasic-cli Version: 1.0.0 Status: Ready for PyPI publication Command: dbbasic (globally available after install) Dependencies: None (pure Python stdlib)
Quick Publish Commands
# 1. Clean and build
rm -rf build/ dist/ *.egg-info/
python -m build
# 2. Check packages
twine check dist/*
# 3. Upload to PyPI
twine upload dist/*