Skip to main content

Cookiecutter PyPackage GitLab

PyPI version

Cookiecutter template for a Python package in the GitLab CI/CD ecosystem.

Project links

Features

  • Dependency management with uv
  • Task running with make
  • Testing with pytest under GitLab CI
  • Auto-publish to a package registry when you push a v* tag. (For PyPI no API tokens are needed by using Trusted Publishers.)
  • Hardened GitLab CI workflows: version-pinned Docker images
  • Documentation site built with Zensical and auto-deployed to GitLab Pages.
  • Linting with ruff, type checking with mypy and ty
  • Command line interface using argparse

Quickstart

Generate a new Python package by creating a temporary venv, installing the package, and running the command.

python -m venv venv
source venv/bin/activate
pip install cookiecutter-pypackage-gitlab
cookiecutter-pypackage-gitlab

If you have uvx installed, you can also use it to run cookiecutter-pypackage-gitlab without explicitly creating a temporary venv, installing the package, running the package, and then removing the temporary venv:

uvx cookiecutter-pypackage-gitlab

You'll be prompted for your project's values (name, description, author details, GitLab repository URL, publish registry, and so on). See docs/prompts.md for the full list and what each value controls.

Then:

  • Review src/ and tests/; see tutorial Step 7 for what to adapt or delete.
  • Create a GitLab repo and push your code
  • Enable GitLab Pages: Settings > Pages > Source: GitLab CI
  • Set up your selected package registry (see Registry setup -- covers GitLab Package Registry, PyPI Trusted Publishing, and TestPyPI for dry runs).
  • Release your package: see Release checklist for the workflow.

See the full documentation for the tutorial, CI/CD reference, design notes, and more.

Development

To set up for local development:

git clone git@gitlab.com:sck/cookiecutter-pypackage-gitlab.git
cd cookiecutter-pypackage-gitlab
make venv
source venv/bin/activate
make init
make sync-devci

Run quality checks (format, lint, type check, test):

make qa

Watch the template for changes and auto-regenerate python-boilerplate/ in the repo root (useful when iterating on template files):

make template-watch

Release cycle

  1. Edit code and add change notes to the Next release (TBD) entry in HISTORY.md as you go.

  2. When ready to release, upgrade all dependencies and refresh the environment:

    make update
    make sync-devci
    
  3. Run the full quality check suite:

    make qa
    
  4. In HISTORY.md, replace the Next release (TBD) heading with the release version and today's date, and verify the change notes are complete.

  5. Sync the version to pyproject.toml and uv.lock:

    make set-version
    
  6. Commit the release:

    git commit -am "Release X.Y.Z"
    
  7. Tag and push. make tag validates version consistency across HISTORY.md, pyproject.toml, and uv.lock; creates an annotated tag; pushes it to origin; and adds a new Next release (TBD) entry to HISTORY.md:

    make tag
    

    Pushing the tag triggers the GitLab CI/CD publish job, which uploads the package to your selected registry.

  8. Commit to open the next development cycle:

    git commit -am "Start next development cycle"
    
  9. Go back to step 1.

See also Release checklist for registry-specific publishing notes and troubleshooting.

Not exactly what you want?

Don't worry, you have options:

Fork this / Create your own

If you have differences in your preferred setup, I encourage you to fork this to create your own version. Or create your own; it doesn't strictly have to be a fork.

Similar Cookiecutter templates

This cookiecutter template was based on the v0.4.0 (2026-02-16) release of Cookiecutter PyPackage (a GitHub-centric template). That package lists other forks you can explore to get ideas at network and family tree.

Or submit a merge request

I also accept merge requests on this, if they're small, atomic, follow my design decisions, and if they make my own packaging experience better.

License

MIT.

Release files for cookiecutter-pypackage-gitlab 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cookiecutter-pypackage-gitlab 0.6.0
File Size Uploaded
cookiecutter_pypackage_gitlab-0.6.0.tar.gz 74.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cookiecutter-pypackage-gitlab 0.6.0
File Interpreter ABI Platform
cookiecutter_pypackage_gitlab-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 143.3 kB

Release files / cookiecutter_pypackage_gitlab-0.6.0.tar.gz

Download URL cookiecutter_pypackage_gitlab-0.6.0.tar.gz
Size 74.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b994cd9fbee1831c9231b9f0a3f678a6e38ea456ddac66b69a309c240e18e896
BLAKE2b-256 checksum
How to use checksums
fc94e0081bb4d096e11172a7289f2b5ad50a9dbcf44c276341c1d5dcb0f343b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cookiecutter_pypackage_gitlab-0.6.0-py3-none-any.whl

Download URL cookiecutter_pypackage_gitlab-0.6.0-py3-none-any.whl
Size 69.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fa80670a97195c6c8c0c7b47fb9381c257286458de2ba05dcce1d49589a6e3e
BLAKE2b-256 checksum
How to use checksums
09c2ddbb472131b933b8635009fcf36168936c268c51ef7532bffa7eaaf0d540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.6.1

2 release files

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page