Skip to content
Open
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
24 changes: 9 additions & 15 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,21 @@
"version": "0.1",
"copyright_year": "{% now 'utc', '%Y' %}",
"license": [
"MIT",
// "Apache-2.0",
// "BSD-3-Clause",
// "GPL-3.0-or-later",
// "LGPL-3.0-or-later",
"MIT"
],
"development_status": [
// "Development Status :: 1 - Planning",
// "Development Status :: 2 - Pre-Alpha",
// "Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
// "Development Status :: 5 - Production/Stable",
// "Development Status :: 6 - Mature",
// "Development Status :: 7 - Inactive"
"Development Status :: 4 - Beta"
],
"minimum_python": "3.13.0",
"minimum_python": "3.13",
"with_django": "0",
"with_flask": "0",
"with_fastapi": "0",
"with_cyclopts": "1",
"with_postgres": "0",
"support_rtd": "0",
"__package_name_snake_case": "{{ cookiecutter.package_name|slugify(separator='_') }}"
}
"__package_name_snake_case": "{{ cookiecutter.package_name|slugify(separator='_') }}",
"_copy_without_render": [
"*.justfile",
".just/*.justfile"
]
}
35 changes: 35 additions & 0 deletions {{cookiecutter.project_name}}/.claude/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# Python Package Management with uv

Use uv exclusively for Python package management in this project.

## Package Management Commands

- All Python dependencies **must be installed, synchronized, and locked** using uv
- Never use pip, pip-tools, poetry, or conda directly for dependency management

Use these commands:

- Install dependencies: `uv add <package>`
- Remove dependencies: `uv remove <package>`
- Sync dependencies: `uv sync`

## Running Python Code

- Run a Python script with `uv run <script-name>.py`
- Run Python tools like Pytest with `uv run pytest` or `uv run ruff`
- Launch a Python repl with `uv run python`

## Managing Scripts with PEP 723 Inline Metadata

- Run a Python script with inline metadata (dependencies defined at the top of the file) with: `uv run script.py`
- You can add or remove dependencies manually from the `dependencies =` section at the top of the script, or
- Or using uv CLI:
- `uv add package-name --script script.py`
- `uv remove package-name --script script.py`



# References
- https://pydevtools.com/handbook/how-to/how-to-configure-claude-code-to-use-uv/

31 changes: 16 additions & 15 deletions {{cookiecutter.project_name}}/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@
# >> alias source-env='set -a && source .env && set +a'

PROJECT_NAME='{{cookiecutter.package_name}}'
BASE_DIR="__CWD__"
IPYTHONDIR="__CWD__/etc/ipython"
PYTHONSTARTUP="__CWD__/etc/pythonstartup.py"
BASE_DIR='__CWD__'
IPYTHONDIR='__CWD__/etc/ipython'
PYTHONSTARTUP='__CWD__/etc/pythonstartup.py'

# caching
CACHE_DIR="__CWD__/var/cache/"
BLACK_CACHE_DIR="__CWD__/var/cache/black"
IPYTHON_CACHE_DIR="__CWD__/var/cache/ipython"
MYPY_CACHE_DIR="__CWD__/var/cache/mypy"
PRE_COMMIT_HOME="__CWD__/var/cache/pre-commit"
PYLINTHOME="__CWD__/var/cache/pylint"
CACHE_DIR='__CWD__/var/cache/'
IPYTHON_CACHE_DIR='__CWD__/var/cache/ipython'
PRE_COMMIT_HOME='__CWD__/var/cache/pre-commit'
PYLINTHOME='__CWD__/var/cache/pylint'

# debugging
# used by python-interpreter, cfr. https://docs.python.org/3/using/cmdline.html#environment-variables
Expand All @@ -51,16 +49,19 @@ PYTHONBREAKPOINT='ipdb.set_trace'
# show headers in urllib3-http-connections
DEBUGLEVEL_HTTPCONNECTION='1'

# generated sercrets key
APP_SECRET_KEY='__APP_SECRET_KEY__'

# tmp
TMP="__CWD__/var/tmp"
TMPDIR="__CWD__/var/tmp"
TEMP="__CWD__/var/tmp"
TMP='__CWD__/var/tmp'
TMPDIR='__CWD__/var/tmp'
TEMP='__CWD__/var/tmp'

# libranet-logging - etc/logging.yaml
# Supported values for logging, from lowest to highest priority:
# LOGLEVEL_XXX: NOTSET|TRACE|DEBUG|INFO|WARNING|ERROR
LOGGING_YML_FILE="__CWD__/etc/logging.yaml"
LOG_DIR="__CWD__/var/log"
LOGGING_YML_FILE='__CWD__/etc/logging.yaml'
LOG_DIR='__CWD__/var/log'
PYTHON_CONSOLE_FORMATTER='console_color'
LOGLEVEL_ROOT='NOTSET'
LOGLEVEL_ASYNCIO='NOTSET'
Expand All @@ -81,7 +82,7 @@ LOGLEVEL_URLLIB3='NOTSET'
LOGLEVEL_URLLIB3_CONNECTIONPOOL='NOTSET'
LOGLEVEL_URLLIB3_UTIL_RETRY='NOTSET'
PYTHONASYNCIODDEBUG='1'
LOG_HANDLERS="console|debug_file|info_file|warning_file|error_file"
LOG_HANDLERS='console|debug_file|info_file|warning_file|error_file'
PYTHON_ENABLE_LOGGING_TREE=0


Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/.gitlab-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cache:

before_script:
- test -e $CI_PROJECT_DIR/.poetry/bin/poetry || curl -sSL https://install.python-poetry.org | python3 -
- export PATH="$CI_PROJECT_DIR/.poetry/bin/:$CI_PROJECT_DIR/.venv/bin/:$PATH"
- export PATH="$CI_PROJECT_DIR/.poetry/bin/:$CI_PROJECT_DIR/uv run :$PATH"
- echo $PATH
- poetry --version
- poetry install
Expand Down
13 changes: 3 additions & 10 deletions {{cookiecutter.project_name}}/.just/bandit.justfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
# bandit, see ../justfile
{% raw -%}

# show which bandit is used
[group: 'bandit']
bandit-which:
@ which bandit


# run bandit
[group: 'bandit']
bandit:
# bandit --configfile pyproject.toml --recursive src --baseline etc/bandit-baseline.json
.venv/bin/bandit --configfile pyproject.toml --recursive .
uv run bandit --configfile pyproject.toml --recursive .


# run bandit with htm-report
[group: 'bandit']
bandit-html:
@ mkdir -p var/html/bandit
@ echo -e "Bandit-report generated in var/html/bandit/bandit.html"
.venv/bin/bandit --config pyproject.toml --recursive . --format html > var/html/bandit/bandit.html
uv run bandit --config pyproject.toml --recursive . --format html > var/html/bandit/bandit.html


# update bandit baseline
[group: 'bandit']
bandit-update-baseline:
.venv/bin/bandit --configfile pyproject.toml --recursive . --format json --output etc/bandit-baseline.json
uv run bandit --configfile pyproject.toml --recursive . --format json --output etc/bandit-baseline.json

{%- endraw %}
9 changes: 4 additions & 5 deletions {{cookiecutter.project_name}}/.just/dir-structure.justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% raw -%}

# See ../justfile
#
# - justfile_directory() is the directory of the toplevel justfile
Expand All @@ -13,8 +13,8 @@ export PATH := if os_family() == "windows" { venv_bin_dir + x";${PATH}" } else {
[group: 'dir-structure']
create-dirs:
# vscode does not create cache-dirs, so we need to create it
@ echo -e "In current working dir: ${PWD}"
@ echo -e "Creating project directory-structure:"
@ echo "In current working dir: ${PWD}"
@ echo "Creating project directory-structure:"
mkdir -p var
mkdir -p var/cache
mkdir -p var/cache/mypy
Expand All @@ -23,7 +23,7 @@ create-dirs:
mkdir -p var/log
mkdir -p var/run
mkdir -p var/tmp
@ echo -e ""
@ echo ""


# symlinks to venv-dirs to make bin/python work
Expand Down Expand Up @@ -71,4 +71,3 @@ clean: clean-symlinks clean-venv clean-pyhon-cache-files
alias clear := clean


{%- endraw %}
33 changes: 31 additions & 2 deletions {{cookiecutter.project_name}}/.just/dotenv.justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% raw -%}

# dotenv

env_file := justfile_directory() / ".env"
Expand All @@ -20,6 +20,20 @@ dotenv-install-from-template:




[group: 'dotenv']
[windows]
dotenv-install-from-template:
#!pwsh
if (Test-Path .env) {
Write-Host ".env file already exists. Not overwriting it.`n"
} else {
Write-Host "Copying .env.template to .env"
Copy-Item .env.template .env
}



# # replace placeholder __CWD__ with current working directory
# [group: 'dotenv']
# dotenv-set-basedir:
Expand All @@ -42,6 +56,22 @@ dotenv-set-basedir:
fi


[group: 'dotenv']
[windows]
dotenv-set-basedir:
#!pwsh
if (Test-Path .env) {
$currentDir = (Get-Location).Path
Write-Host "Replacing string __CWD__ with current directory $currentDir in .env file."
Copy-Item .env .env.backup
(Get-Content .env) -replace '__CWD__', $currentDir | Set-Content .env
Write-Host ".env updated successfully. Please review any credentials.`n"
} else {
Write-Error "Error: .env file not found!`n"
exit 1
}


# install .env-file from .env.template
[group: 'dotenv']
dotenv-install: dotenv-install-from-template dotenv-set-basedir
Expand All @@ -55,4 +85,3 @@ show-dotenv:
@ echo -e "Following environment variables are defined in the {{env_file}}:"
@ cat .env

{%- endraw %}
27 changes: 10 additions & 17 deletions {{cookiecutter.project_name}}/.just/ipython.justfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
{% raw -%}
# ipython


# symlink ipython to ip
[group: 'ipython']
symlink-ipython:
@ cd .venv/bin && ln -sf ipython ip
# ipython


# open python-shell
[group: 'ipython']
python-shell args="":
@ .venv/bin/python {{args}}
python-shell *args:
@ uv run python {{args}}

alias python := python-shell


# open ipython-shell
[group: 'ipython']
ipython-shell args="":
@ .venv/bin/ipython {{args}}
ipython-shell *args:
@ uv run ipython {{args}}

alias ipython := ipython-shell
alias ip := ipython-shell

# open ipython-shell

# open ipython-shell in debug-mode
[group: 'ipython']
ipython-shell-debug args="":
@ .venv/bin/ipython --debug {{args}}
ipython-shell-debug *args:
@ uv run ipython --debug {{args}}

alias ipython-debug := ipython-shell-debug


# create an ipython profile
[group: 'ipython']
ipython-create-profile name="":
.venv/bin/ipython profile create {{name}}

{%- endraw %}
uv run ipython profile create {{name}}
19 changes: 9 additions & 10 deletions {{cookiecutter.project_name}}/.just/just.justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% raw -%}

# just


Expand All @@ -22,24 +22,24 @@ alias just-update := just-install
# show help
[group: 'just']
help:
@ just --help
@ {{just_executable()}} --help


# Display all canonical tasks and their aliases
[group: 'just']
list-all:
@ just --list --unsorted
@ {{just_executable()}} --list --unsorted


# select recipe from list
[group: 'just']
choose:
@ just --choose --justfile justfile
@ {{just_executable()}} --choose --justfile justfile


[group: 'just']
evaluate:
@ just evaluate
@ {{just_executable()}} evaluate


# Install or update tab-completion for just-recipes
Expand All @@ -48,7 +48,7 @@ evaluate:
just-install-completions:
#!pwsh.exe
$filePath = Join-Path $HOME 'completions-just.ps1'
just --completions powershell > $filePath
{{just_executable()}} --completions powershell > $filePath
Write-Host "Generated completions-file in $filePath"
Write-Host "Add following line to your Powershell-profile:"
Write-Host ". ~\completions-just.ps1 -Force"%
Expand All @@ -60,7 +60,7 @@ just-install-completions:
just-update-completions:
#!pwsh.exe
$filePath = 'etc/just/completions-just.ps1'
just --completions powershell > $filePath
{{just_executable()}} --completions powershell > $filePath
Write-Host "Generated new completions-file for powershell in $filePath"


Expand All @@ -71,12 +71,12 @@ just-update-completions:


# Command to get the version of just
JUST_VERSION_COMMAND := `just --version || 1`
JUST_VERSION_COMMAND := `{{just_executable()}} --version || 1`

# Show version of just if it's available
[group: 'just']
just-show-version:
@ Write-Host "`t just: {{JUST_VERSION_COMMAND}}"
@ Write-Host "`t {{just_executable()}}: {{JUST_VERSION_COMMAND}}"


# show location of just.exe
Expand Down Expand Up @@ -170,4 +170,3 @@ just-check:
# Invoke-WebRequest -Uri "https://just.systems/install.sh" -UseBasicParsing | Invoke-Expression -ArgumentList "--to $DEST"


{%- endraw %}
Loading