Skip to main content

One-shot bootstrap & deploy script for Python packages (git+GitHub+PyPI).

Project description

deploy_pkg

Zero-click Python package deployment.
Build → GitHub → PyPI in a single command, without prompts.


✨ What is it?

deploy_pkg is a one-file deployment tool that:

  1. Bootstraps a project (creates pyproject.toml, README.md, LICENSE, etc.).
  2. Cleans build artifacts.
  3. Bumps the patch version (X.Y.Z → X.Y.(Z+1)).
  4. Builds an optional frontend (npm install && npm run build if a package.json is found).
  5. Builds your Python package (python -m build) and installs it locally in editable mode.
  6. Initializes a Git repository, or re-uses the existing one.
  7. Creates a GitHub repo via the API (if none exists), adds it as origin, commits, tags, and pushes.
  8. Uploads the freshly built distribution to PyPI with twine.

All of that without asking a single question.


🚀 Quick Start

pip install deploy_pkg        # install the script
deploy-me                    # run it in any project directory
  • First run in an empty folder?
    → deploy_pkg scaffolds a minimal package and publishes it immediately.

  • Run it again later?
    → deploy_pkg just bumps the version, rebuilds, commits, tags and republishes.


📦 Installation

From PyPI

pip install deploy_pkg

From source

git clone https://github.com/<you>/deploy_pkg.git
cd deploy_pkg
pip install -e .

🔧 Prerequisites

Tool / Env var Purpose
git version control, pushing to GitHub
Python ≥ 3.8 runtime
GITHUB_TOKEN Personal Access Token with repo + user:email scopes
(optional) npm builds /frontend if present

Create a .env file in your project root:

GITHUB_TOKEN=ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXX
# PKG_NAME=my_custom_name   # (optional) overrides the default package name

🖥️ Usage

deploy-me          # or:  python -m deploy_pkg

Works in any directory:

  • Blank directory → bootstraps + publishes a first 0.0.1 release.
  • Existing package → bumps patch version, rebuilds, commits & tags.
  • Dirty git status → aborts with a clear error (keeps you safe).

How it works – Step by Step

# Action Details
1 Requirements Checks for git, installs missing Python libs (build, twine, toml, requests, python-dotenv).
2 Scaffolding Creates pyproject.toml, README.md, LICENSE, MANIFEST.in, .gitignore if absent.
3 Clean Removes build/, dist/, *.egg-info, __pycache__.
4 Version bump Reads project.version from pyproject, increments patch.
5 Frontend If a package.json exists anywhere: bumps its version, runs npm install & npm run build.
6 Build & install python -m build then pip install -U -e .
7 Git / GitHub Init repo, create GitHub repo (via REST API), add remote, commit "patch update #<ver>", tag v<ver>, push.
8 Publish twine upload dist/* – your new package is live on PyPI.

Any failure aborts the pipeline with a clear, human-friendly error.


CLI Flags

No flags yet. deploy_pkg is intentionally minimal – but a --dry-run or --verbose flag is planned (see Roadmap).


Examples

First-time release

mkdir awesome_pkg
cd awesome_pkg
deploy-me
# → 0.0.1 built, repo created on GitHub, uploaded to PyPI, installed locally

Routine patch release

cd awesome_pkg
git status   # should be clean
deploy-me
# → 0.0.2 built, commit, tag v0.0.2, push, PyPI upload

Using a custom package name

echo "PKG_NAME=super_lib" >> .env
deploy-me

🛡️ Security

  • Access tokens are never printed.
  • Git working tree must be clean or the run aborts (prevents accidental commits).
  • Network operations (requests) use a 10-second timeout and explicit error handling.

🛠 Contributing

Pull Requests welcome!
Clone the repo, install dev deps, run tests (to be added):

pip install -e ".[dev]"
pytest

Feel free to open issues for feature requests or bug reports.


🗺️ Roadmap

  • --dry-run flag (show all steps, no side-effects)
  • Colorised logging (rich)
  • Pre-/post-deploy hooks
  • Config file for per-project overrides
  • Verbose mode with full traceback

🙋 Author

Baptiste – math teacher, Python developer, and despiser of tedious release checklists.


📝 License

deploy_pkg is released under the MIT License – do whatever you want, just keep the copyright.


❤️ Acknowledgements

Inspired by the hundreds of times we forgot one of the following:

  • bumping the version number
  • tagging the commit
  • uploading with Twine
  • pushing the tag
  • building the frontend first…

deploy_pkg never forgets.

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

deploy_pkg-0.0.10.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

deploy_pkg-0.0.10-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file deploy_pkg-0.0.10.tar.gz.

File metadata

  • Download URL: deploy_pkg-0.0.10.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for deploy_pkg-0.0.10.tar.gz
Algorithm Hash digest
SHA256 c937c16eaadf6a78a4bcb068994c7fe3ff14e334a0ff4fbb6e90d201e45eefde
MD5 1f127464fe6ab2fa7159ad9cc8ff9a48
BLAKE2b-256 4eac80f6efca3959214cd5ff34d231c2291b9b757ab7f99525a8fd4bb4efa752

See more details on using hashes here.

File details

Details for the file deploy_pkg-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: deploy_pkg-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for deploy_pkg-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 c46622bc471d811c863a1379657a43fc197644295cba9445dbb4ad4403cfdb4a
MD5 7769a1d2d0743c6735897d7238bf219e
BLAKE2b-256 c66d9634f3584e2058a4735622aca962b5c0b7e62f8573e99895a7919b16a907

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