Skip to content
/ pypi-skeleton Public template

A template repo for quickly building a Python project and publishing to PyPI

License

Notifications You must be signed in to change notification settings

brianwarner/pypi-skeleton

Repository files navigation

REPLACEME_PROJECT_NAME

This is a starter template to publish to PyPI.

Describe your project here and remove these instructions, this README will appear in your documentation and on your PyPI page.

Using this template

Find and replace any instances of REPLACEME- with your information. Replace the placeholders in src/ with your application. Add appropriate tests to tests/.

Dependencies

Add your development dependencies to requirements.txt and any runtime dependencies to pyproject.toml.

Docs

Add your top-level functions to docsrc/index.rst

Add a new pending publisher

Log into your account on PyPI and configure a pending Trusted Publisher:

  • PyPI Project Name: The name of the project
  • Owner: Your GitHub username
  • Repository name: Your GitHub repo
  • Workflow name: release.yml
  • Environment name: Leave this blank

The project will be created the first time the publication action runs successfully.

Create a Python environment

In VSCode, press Ctrl+Shift+p (Windows) or Cmd+Shift+p (Mac) and search for "Python: Create Environment...". Take the defaults and install requirements from requirements.txt.

Publishing

Test locally

Always write your test cases and make sure they run correctly locally before pushing your code.

pytest

Run a test build

Run a test build to ensure everything works correctly.

python -m build

Open a PR

Commit your changes, push your branch, and open a PR. The pre-release.yml workflow will run, and make sure the project builds against Python 3.10, 3.11, and 3.12. It will also generate a fresh copy of your docs into the docs directory.

Merge

When everything looks fine (hint: pull the latest changes on the branch and open docs/index.html), you can merge the PR.

Set up GitHub Pages for docs

You only have to do this once. In your repo, go to "settings/pages". Choose "Deploy from a branch", set your branch to main and deploy from /docs. Further down the page, select "Enforce HTTPS".

Your site will now build.

Push an annotated tag

When you're ready to publish to PyPI, create and push an annotated tag on the main branch:

git checkout main
git pull
git tag -a v1.0.0 -m "v1.0.0"
git push origin tag v1.0.0

The release.yml workflow will run and publish to PyPI.

About

A template repo for quickly building a Python project and publishing to PyPI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published