Skip to main content

Cookiecutter template for a Python package in the GitLab ecosystem

Project description

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 package repository 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.

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

cookiecutter_pypackage_gitlab-0.4.0.tar.gz (56.6 kB view details)

Uploaded Source

Built Distribution

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

cookiecutter_pypackage_gitlab-0.4.0-py3-none-any.whl (59.5 kB view details)

Uploaded Python 3

File details

Details for the file cookiecutter_pypackage_gitlab-0.4.0.tar.gz.

File metadata

  • Download URL: cookiecutter_pypackage_gitlab-0.4.0.tar.gz
  • Upload date:
  • Size: 56.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for cookiecutter_pypackage_gitlab-0.4.0.tar.gz
Algorithm Hash digest
SHA256 fb71d884bbd291a91c15fa7b85704855c84d8b691335d57dd70a69b4c80efd42
MD5 c22a0c21eeb80da020e8edebba17cbfc
BLAKE2b-256 9e1e1be10c5c3c99576e0cdcac3a22a5823e6eb34914f09a32689e3d57264274

See more details on using hashes here.

File details

Details for the file cookiecutter_pypackage_gitlab-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: cookiecutter_pypackage_gitlab-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 59.5 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for cookiecutter_pypackage_gitlab-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b88f8061912172ab116fe3bce4c73d16c4e9d79b549e5ac71585dce62b1b9127
MD5 f1ac89ab3af2dd1806a0da2d6f01a1ee
BLAKE2b-256 76dc2a33326822cbfb510023d2efb7b6fc9aa8dcd40e2b1314efd895da5eada6

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