Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

andreaslongo/cc-python

Repository files navigation

Python Project Template

Use this template to bootstrap new Python projects fast and unified.

Usage

$ cookiecutter https://github.com/andreaslongo/cc-python.git

Features

Requirements

This tools are language agnostic and don’t belong to a single project. Install them locally for your user or globally for your system.

Note
I recommend pipx for Python application management, but it is not required for this template.

Creating a project

To create a new project, install and run Cookiecutter

$ cookiecutter https://github.com/andreaslongo/cc-python.git

Or install and use pipx (recommended)

$ pipx run cookiecutter https://github.com/andreaslongo/cc-python.git
Note
Make sure you are working in a Python virtual environment for the following steps.

Compile the project dependencies

cd python-project
make compile-dependencies

Initialize the project for development

make init
Note
You may have to refresh your shell environment before the next step.

Run the test suite

make test

Python Dependency Management

python-project/
| requirements-dev.in
| requirements-dev.txt
| requirements.in
| requirements.txt
  • .in files contain the actual dependencies. Add your dependencies to this files manually.

  • .txt files are pinned and hashed results of pip-compile. Use this files to install your dependencies.

Environments

Depending on the environment, the dependencies of Python packages may vary.

An environment is (simplified): Operating system + Python version (3.8, 3.9, …​) + Python interpreter (CPython, PyPy, …​)

If your project supports multiple environments, run pip-compile on each environment to generate different .txt files, valid for each environment. You can use the same .in files for all environments.

Do not use the same .txt files for different environments, even if the generated output is the same. Any change or update to dependencies or their sub-dependencies might introduce new environment dependent dependencies.

An example {environment}-requirements.txt format:

python-project/
| requirements-dev.in
| requirements-dev.txt
| requirements.in
| linux-py3.6-requirements.txt
| macos-py3.7-requirements.txt
| win32-py3.8-requirements.txt