Skip to content

Commit 1758359

Browse files
committed
Initial commit from 'copier' template
1 parent 70f8093 commit 1758359

File tree

12 files changed

+854
-200
lines changed

12 files changed

+854
-200
lines changed

.copier-answers.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2-
_commit: v1.8.1
2+
_commit: v2.0.0a1
33
_src_path: gh:OverkillGuy/python-template
44
author_email: [email protected]
55
author_name: Jb Doyon
66
description: Multipurpose discord bot for the Zeusops community
7-
dynamic_versioning: false
7+
dynamic_versioning: true
88
package_name: zeusops_bot
99
project_name: Zeusops bot
1010
project_slug: zeusops-bot

.dockerignore

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Poetry.lock is an exact version pinning tool (down to SHA256 of libs)
2-
# If writing a (reusable) library, exact versions don't matter that much so it
3-
# may make sense to gitignore that file, uncommenting the following line:
4-
# poetry.lock
5-
# If writing an App (binary-deployable), then exact library versions
6-
# do matter a lot, and you'll want to keep Poetry.lock tracked = keep
7-
# commented
8-
91
################################################################################
102
# Global ignore list, common in BOTH .dockerignore, and .gitignore
113
# Make sure that whatever is done below is copied to the other file
124
################################################################################
135

6+
# uv.lock is an exact version pinning tool (down to SHA256 of libs)
7+
# If writing a (reusable) library, exact versions don't matter that much so it
8+
# may make sense to ignore that file, uncommenting the following line:
9+
# uv.lock
10+
# If writing an App (binary-deployable), then exact library versions
11+
# do matter a lot, and you'll want to keep Uv.lock tracked = keep
12+
# commented
13+
1414
test_results/
1515

1616
# Do not track the code-extracted docs page from 'make docs'
@@ -120,6 +120,12 @@ ipython_config.py
120120
# install all needed dependencies.
121121
#Pipfile.lock
122122

123+
# UV
124+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
125+
# This is especially recommended for binary packages to ensure reproducibility, and is more
126+
# commonly ignored for libraries.
127+
#uv.lock
128+
123129
# poetry
124130
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
125131
# This is especially recommended for binary packages to ensure reproducibility, and is more
@@ -132,8 +138,10 @@ ipython_config.py
132138
#pdm.lock
133139
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
134140
# in version control.
135-
# https://pdm.fming.dev/#use-with-ide
141+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
136142
.pdm.toml
143+
.pdm-python
144+
.pdm-build/
137145

138146
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
139147
__pypackages__/
@@ -185,6 +193,19 @@ cython_debug/
185193
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
186194
#.idea/
187195

196+
# Ruff stuff:
197+
.ruff_cache/
198+
199+
# PyPI configuration file
200+
.pypirc
201+
202+
# Cursor
203+
# Cursor is an AI-powered code editor.`.cursorignore` specifies files/directories to
204+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
205+
# refer to https://docs.cursor.com/context/ignore-files
206+
.cursorignore
207+
.cursorindexingignore
208+
188209
################ Above is Python gitignore from github/gitignore ###############
189210

190211

.gitignore

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Poetry.lock is an exact version pinning tool (down to SHA256 of libs)
2-
# If writing a (reusable) library, exact versions don't matter that much so it
3-
# may make sense to gitignore that file, uncommenting the following line:
4-
poetry.lock
5-
# If writing an App (binary-deployable), then exact library versions
6-
# do matter a lot, and you'll want to keep Poetry.lock tracked = keep
7-
# commented
8-
91
################################################################################
102
# Global ignore list, common in BOTH .dockerignore, and .gitignore
113
# Make sure that whatever is done below is copied to the other file
124
################################################################################
135

6+
# uv.lock is an exact version pinning tool (down to SHA256 of libs)
7+
# If writing a (reusable) library, exact versions don't matter that much so it
8+
# may make sense to ignore that file, uncommenting the following line:
9+
# uv.lock
10+
# If writing an App (binary-deployable), then exact library versions
11+
# do matter a lot, and you'll want to keep Uv.lock tracked = keep
12+
# commented
13+
1414
test_results/
1515

1616
# Do not track the code-extracted docs page from 'make docs'
@@ -120,6 +120,12 @@ ipython_config.py
120120
# install all needed dependencies.
121121
#Pipfile.lock
122122

123+
# UV
124+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
125+
# This is especially recommended for binary packages to ensure reproducibility, and is more
126+
# commonly ignored for libraries.
127+
#uv.lock
128+
123129
# poetry
124130
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
125131
# This is especially recommended for binary packages to ensure reproducibility, and is more
@@ -132,8 +138,10 @@ ipython_config.py
132138
#pdm.lock
133139
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
134140
# in version control.
135-
# https://pdm.fming.dev/#use-with-ide
141+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
136142
.pdm.toml
143+
.pdm-python
144+
.pdm-build/
137145

138146
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
139147
__pypackages__/
@@ -185,6 +193,19 @@ cython_debug/
185193
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
186194
#.idea/
187195

196+
# Ruff stuff:
197+
.ruff_cache/
198+
199+
# PyPI configuration file
200+
.pypirc
201+
202+
# Cursor
203+
# Cursor is an AI-powered code editor.`.cursorignore` specifies files/directories to
204+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
205+
# refer to https://docs.cursor.com/context/ignore-files
206+
.cursorignore
207+
.cursorindexingignore
208+
188209
################ Above is Python gitignore from github/gitignore ###############
189210

190211

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ repos:
3131
name: Hadolint (Dockerfile checker)
3232
# Actual Python Linters
3333
- repo: https://github.com/astral-sh/ruff-pre-commit
34-
rev: v0.11.11
34+
rev: v0.7.0
3535
hooks:
3636
- id: ruff-format
3737
- id: ruff
3838
args: ["--fix"]
3939
- repo: https://github.com/pre-commit/mirrors-mypy
40-
rev: v1.15.0
40+
rev: v1.12.1
4141
hooks:
4242
- id: mypy
4343
name: Mypy (Python type-checker)
4444
exclude: 'docs/source/.*\.py'
4545
# Uncomment below if mypy requires extra type stub packages
4646
# additional_dependencies: [types-PyYAML==6.0.12.2]
4747
- repo: https://github.com/igorshubovych/markdownlint-cli
48-
rev: v0.45.0
48+
rev: v0.42.0
4949
hooks:
5050
- id: markdownlint-fix

Dockerfile

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
FROM python:3.12-bookworm
1+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm
22

3-
# Bring poetry, our package manager, and pre-commit hooks
4-
ARG POETRY_VERSION=1.8.1
5-
ARG PRECOMMIT_VERSION=4.1.0
6-
RUN pip install --no-cache-dir \
7-
poetry==${POETRY_VERSION} \
8-
pre-commit==${PRECOMMIT_VERSION}
3+
# Ensure tools installed by UV are on PATH right away
4+
# Per https://github.com/astral-sh/uv/issues/13057#issuecomment-2832631407
5+
ENV UV_TOOL_BIN_DIR=/usr/local/bin
96

7+
# Disable python version downloading, use what we got!
8+
ENV UV_PYTHON_DOWNLOADS=0
109

11-
# We may be in docker, but the package's dependecies we install may clash with
12-
# the poetry/pre-commit dependencies (mostly requests version).
13-
# Set up a venv anyway here:
14-
ENV POETRY_VIRTUALENVS_CREATE=true
1510

11+
ARG PRECOMMIT_VERSION=4.2.0
12+
ARG UV_DYNAMIC_VERSION=0.8.2
13+
RUN uv pip install --system \
14+
"uv-dynamic-versioning==${UV_DYNAMIC_VERSION}" && \
15+
uv tool install \
16+
"pre-commit==${PRECOMMIT_VERSION}"
1617

1718
# Workaround critical-level CVEs in Python image
1819
# By forcing just security update (no featureful updates, as part of apt conf)
@@ -23,8 +24,22 @@ RUN apt-get update \
2324
&& apt-get upgrade -y \
2425
&& rm -rf /var/lib/apt/lists/*
2526

26-
COPY . /workdir
27+
2728
WORKDIR /workdir
2829

29-
# Install the local package dependencies (dev-mode)
30-
RUN poetry install
30+
# Changing the default UV_LINK_MODE silences warnings about not being able to
31+
# use hard links since the cache and sync target are on separate file systems.
32+
ENV UV_LINK_MODE=copy
33+
34+
# Install dependencies only, as they don't change often (note bindmount deplist)
35+
RUN --mount=type=cache,target=/root/.cache/uv \
36+
--mount=type=bind,source=uv.lock,target=uv.lock \
37+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
38+
uv sync --locked --no-install-project
39+
40+
# Copy the actual project contents into the image
41+
COPY . /workdir
42+
43+
# Sync the project now the code is present
44+
RUN --mount=type=cache,target=/root/.cache/uv \
45+
uv sync --locked

Makefile

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ endif
1212
# - Fallback values using ?=, see below:
1313
DOCKER_IMAGE_NAME?=zeusops-bot
1414
DOCKER_REGISTRY?=
15-
APP_VERSION?=$(shell poetry version --short)
15+
APP_VERSION?=$(shell uvx dunamai from git | sed 's/+/-/g')
16+
1617

1718
## Default command, run via 'make' or 'make all'
1819
.PHONY: all
@@ -31,7 +32,7 @@ help:
3132
## Set up the virtualenv and install the package + dependencies
3233
.PHONY: install
3334
install:
34-
poetry install
35+
uv sync --all-extras
3536

3637
## Run the linters and formatters on all files (not just staged for commit)
3738
.PHONY: lint
@@ -41,17 +42,18 @@ lint:
4142
## Run the tests
4243
.PHONY: test
4344
test:
44-
poetry run pytest
45+
uv run --all-extras pytest
4546

4647
## Generate the docs, both HTML and docsets
4748
.PHONY: docs
4849
docs:
4950
cd docs && make html
50-
poetry run doc2dash \
51-
--force \
52-
--name zeusops-bot \
53-
docs/build/html \
54-
--destination docs/build/docset
51+
uv run --all-extras \
52+
doc2dash \
53+
--force \
54+
--name zeusops-bot \
55+
docs/build/html \
56+
--destination docs/build/docset
5557

5658
## Serve the generated docs on a port of localhost
5759
.PHONY: docs-serve
@@ -61,7 +63,7 @@ docs-serve:
6163
## Build the wheel/tarball package
6264
.PHONY: build
6365
build:
64-
poetry build
66+
uv build
6567

6668
## Set up the pre-commit hooks to execute on next git commit
6769
.PHONY: install-hooks
@@ -82,55 +84,48 @@ docker-build-dev:
8284
docker build -t ${DOCKER_IMAGE_NAME}-dev .
8385

8486
## Make a release commit + tag, creating Changelog entry
85-
## Set BUMP variable to any of poetry-supported (major, minor, patch)
86-
## or number (1.2.3 etc), see 'poetry version' docs for details
87+
## Set BUMP variable to any of uv-supported (major, minor, patch)
8788
## Default the bump to a patch (v1.2.3 -> v1.2.4)
8889
BUMP=patch
8990
.PHONY: release
9091
release:
9192
# Set the new version Makefile variable after the version bump
92-
$(eval NEW_VERSION := $(shell poetry version --short ${BUMP}))
93+
$(eval NEW_VERSION := $(shell uv version --short --dry-run --bump ${BUMP}))
9394
$(eval TMP_CHANGELOG := $(shell mktemp))
94-
sed \
95-
"s/\(## \[Unreleased\]\)/\1\n\n## v${NEW_VERSION} - $(shell date +%Y-%m-%d)/" \
95+
@sed \
96+
"s;\(## \[Unreleased\]\);\1\n\n## v${NEW_VERSION} - $(shell date +%Y-%m-%d);" \
9697
CHANGELOG.md > ${TMP_CHANGELOG}
97-
mv --force ${TMP_CHANGELOG} CHANGELOG.md
98-
git add CHANGELOG.md pyproject.toml
98+
@mv --force ${TMP_CHANGELOG} CHANGELOG.md
99+
git add CHANGELOG.md
99100
git commit -m "Bump to version v${NEW_VERSION}"
100101
git tag --annotate "v${NEW_VERSION}" \
101102
--message "Release v${NEW_VERSION}"
102103

103104
## Less commonly used commands
104105

105-
## Generate/update the poetry.lock file
106+
## Generate/update the uv.lock file
106107
.PHONY: lock
107108
lock:
108-
poetry lock --no-update
109+
uv lock
109110

110111
## Update dependencies (within pyproject.toml specs)
111112
## Update the lock-file at the same time
112113
.PHONY: update
113114
update:
114-
poetry update --lock
115+
uv lock --upgrade
116+
115117

116-
## Install tools (poetry, pre-commit) via pipx
118+
## Install tools (uv, pre-commit) via pipx
117119
## Assumes you have pipx installed
118120
# See https://jiby.tech/post/my-python-toolbox/#pipx-for-cli-installs-not-pip
119121
.PHONY: install-tools
120122
install-tools:
121-
pipx install poetry
122-
pipx install pre-commit
123-
124-
## Ensure Poetry will generate virtualenv inside the git repo /.venv/
125-
## rather than in a centralized location. This makes it possible to
126-
## manipulate venv more simply
127-
.PHONY: poetry-venv-local
128-
poetry-venv-local:
129-
poetry config virtualenvs.in-project true
123+
uv self version
124+
uv tool install uv-dynamic-versioning
125+
uv tool install pre-commit
130126

131127
## Delete the virtualenv to clean dependencies
132128
## Useful when switching to a branch with less dependencies
133-
## Requires the virtualenv to be local (see "poetry-venv-local")
134-
.PHONY: poetry-venv-nuke
135-
poetry-venv-nuke:
129+
.PHONY: venv-nuke
130+
venv-nuke:
136131
find .venv -delete

0 commit comments

Comments
 (0)