Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,31 @@ and best development practices for Python.
### Development features

- Supports `Python 3.9` and higher.
- [`Poetry`](https://python-poetry.org/) as a dependency manager. See configuration in [`pyproject.toml`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/pyproject.toml).
- [`Poetry`](https://python-poetry.org/) as a dependency manager. See configuration
in [`pyproject.toml`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/pyproject.toml).
- Automatic codestyle with [`Ruff formatter`](https://docs.astral.sh/ruff/formatter/)
- Linting with [`ruff`](https://github.com/astral-sh/ruff)
- Type checks with [`mypy`](https://mypy.readthedocs.io), security checks with [`safety`](https://github.com/pyupio/safety).
- Type checks with [`mypy`](https://mypy.readthedocs.io), security checks
with [`safety`](https://github.com/pyupio/safety).
- Dependencies check with [`deptry`](https://deptry.com/)
- Testing with [`pytest`](https://docs.pytest.org/en/latest/) and [`coverage`](https://github.com/nedbat/coveragepy).
- Ready-to-use [`pre-commit`](https://pre-commit.com/) hooks with code-formatting.
- Ready-to-use [`.editorconfig`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.editorconfig), [`.dockerignore`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.dockerignore), and [`.gitignore`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.gitignore).
-
Ready-to-use [`.editorconfig`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.editorconfig), [`.dockerignore`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.dockerignore),
and [`.gitignore`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.gitignore).

### Deployment features

- `Github Actions` with linters and tests in the [workflow](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.github/workflows/%7B%7B%20cookiecutter.package_name%20%7D%7D.yml).
- `Gitlab CI` with linters and tests in the [pipeline](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.gitlab-ci.yml). Click [here](pages/gitlab.md) for detailed overview.
- Ready-to-use [`Makefile`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/Makefile) with formatting, linting, and testing. More details in [makefile-usage](#makefile-usage).
- `Github Actions` with linters and tests in
the [workflow](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.github/workflows/%7B%7B%20cookiecutter.package_name%20%7D%7D.yml).
- `Gitlab CI` with linters and tests in
the [pipeline](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/.gitlab-ci.yml).
Click [here](pages/gitlab.md) for detailed overview.
- Ready-to-use [`Makefile`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/Makefile) with
formatting, linting, and testing. More details in [makefile-usage](#makefile-usage).
- [Dockerfile](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/Dockerfile) for your package.
- [docker-compose.yml](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/docker-compose.yml) for local development in Docker.
- [docker-compose.yml](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/docker-compose.yml) for
local development in Docker.

## How to use it

Expand Down Expand Up @@ -92,7 +101,8 @@ By running `make pre-commit-install`. Make sure to set up git first via `git ini
### Makefile usage

[`Makefile`](%7B%7B%20cookiecutter.project_name.lower().replace('%20',%20'-')%20%7D%7D/Makefile)
contains a lot of functions for faster development.
contains a lot of functions
for faster development.

<details>
<summary>1. Download and remove Poetry</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
# BUILDER-BASE
# Used to build deps + create our virtual environment
################################
FROM python-base as builder-base
FROM python-base AS builder-base
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
# deps for installing poetry
Expand All @@ -67,7 +67,7 @@ RUN --mount=type=cache,target=/root/.cache \
# DEVELOPMENT
# Image used during development / testing
################################
FROM python-base as development
FROM python-base AS development
WORKDIR $PYSETUP_PATH

# copy in our built poetry + venv
Expand All @@ -88,7 +88,7 @@ CMD ["python", "-m", "{{ cookiecutter.package_name }}.example"]
# PRODUCTION
# Final image used for runtime
################################
FROM python-base as production
FROM python-base AS production
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
COPY ./{{ cookiecutter.package_name }} /app/{{ cookiecutter.package_name }}
WORKDIR /app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
version: "3.9"
services:
app:
build:
context: .
dockerfile: Dockerfile
image: {{ cookiecutter.project_name.lower().replace(' ', '-') }}:latest
volumes:
- ./{{ cookiecutter.package_name }}:/app/{{ cookiecutter.package_name }}
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ split-on-trailing-comma = false

[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
"pydantic.validator",
# Allow SQLAlchemy's dynamic decorators, like `@field.expression`, to trigger class method treatment.
"declared_attr",
"expression",
"comparator",
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
"pydantic.validator",
# Allow SQLAlchemy's dynamic decorators, like `@field.expression`, to trigger class method treatment.
"declared_attr",
"expression",
"comparator",
]

[tool.ruff.lint.pycodestyle] # https://docs.astral.sh/ruff/settings/#pycodestyle
Expand Down