11set dotenv-load
22
3- PYTHONPATH := "./{{ source_catalog_name }}"
43PATHS_TO_LINT := "{{ source_catalog_name }} tests"
54TEST_PATH := "tests"
65ANSWERS_FILE := ".copier/.copier-answers.copier-python-project.yml"
7- {% - if is_docker_project %}
8- CONTAINER_NAME := "{{ project_name_snake_case }}"
9- WORKDIR := "/code"
10- {% - endif %}
116{% - if is_lambda_project %}
12- BUILD_PATH := "build"
7+ BUILD_DIR := "build"
138CURRENT_DATETIME := `date +'%Y%m%d_%H%M%S'`
149PYTHON_VERSION := "3.13"
1510{% - endif %}
11+ {% - if is_docker_project %}
12+ CONTAINER_NAME := "{{ project_name_snake_case }}"
13+ WORKDIR := "/code"
14+ {% - endif %}
1615{% - raw %}
16+
1717[doc("Command run when 'just' is called without any arguments")]
1818default: help
1919
@@ -28,22 +28,6 @@ all: lint_full test
2828[group("development")]
2929[doc("Run all checks and tests, but fail on first that returns error (lints, mypy, tests...)")]
3030all_ff: lint_full_ff test
31- {% - endraw -%}
32- {% - if is_docker_project -%}
33- {% - raw %}
34-
35- [group("development")]
36- [doc("Run any command inside docker (e.g. just dc bash)")]
37- dc command *args:
38- docker compose run --rm -w {{WORKDIR}} {{CONTAINER_NAME}} just {{command}} {{args}}
39-
40- [group("development")]
41- [doc("Open bash console (useful when prefixed with dc, as it opens bash inside docker)")]
42- @bash:
43- bash
44- {% - endraw -%}
45- {% - endif -%}
46- {% - raw %}
4731
4832[group("lint")]
4933[doc("Run ruff lint check (code formatting)")]
@@ -90,37 +74,53 @@ alias full_lint_ff := lint_full_ff
9074
9175[group("lint")]
9276[doc("Run mypy check (type checking)")]
93- mypy: _set_pythonpath
77+ mypy:
9478 uv run mypy {{PATHS_TO_LINT}} --show-error-codes --show-traceback --implicit-reexport
9579
9680[group("development")]
97- [doc("Open python console (useful when prefixed with dc, as it opens python console inside docker) ")]
98- ps:
99- PYTHONPATH ={{PYTHONPATH }} uv run ipython
81+ [doc("Run IPython with custom startup script ")]
82+ ps startup_script="ipython_startup.py" :
83+ PYTHONSTARTUP ={{ startup_script }} uv run ipython
10084alias ipython := ps
10185
102- [doc("Helper command, sets PYTHONPATH")]
103- _set_pythonpath path=PYTHONPATH:
104- PYTHONPATH={{path}}
105-
10686[group("development")]
10787[doc("Run non-integration tests (optionally specify file=path/to/test_file.py)")]
108- test file=TEST_PATH: _set_pythonpath
88+ test file=TEST_PATH:
10989 uv run pytest {{file}} --durations=10
90+ {% - endraw -%}
91+ {% - if is_docker_project -%}
92+ {% - raw %}
93+
94+ [group("development")]
95+ [doc("Run any command inside docker (e.g. just dc bash)")]
96+ dc command *args:
97+ docker compose run --rm -w {{WORKDIR}} {{CONTAINER_NAME}} just {{command}} {{args}}
98+
99+ [group("development")]
100+ [doc("Open bash console (useful when prefixed with dc, as it opens bash inside docker)")]
101+ @bash:
102+ bash
103+ {% - endraw -%}
104+ {% - endif -%}
105+ {% - raw %}
110106{% endraw -%}
111107{% - if is_lambda_project -%}
112108{% - raw %}
113109[group("lambda_build")]
114110build: build_create_env
115- cd {{ BUILD_PATH }}/pkg && \
111+ cd {{ BUILD_DIR }}/pkg && \
116112 zip -r ../{% endraw %} {{ source_catalog_name }}{% raw %} _{{ CURRENT_DATETIME }}.zip .
117113
118114[group("lambda_build")]
119- build_create_env: build_generate_requirements build_install
115+ build_create_env: clear_build_dir build_generate_requirements build_install copy_shim
116+
117+ [group("lambda_build")]
118+ clear_build_dir:
119+ rm -rf {{ BUILD_DIR }}/pkg
120120
121121[group("lambda_build")]
122122build_generate_requirements:
123- uv export --frozen --no-dev --no-editable -o {{ BUILD_PATH }}/requirements.txt
123+ uv export --frozen --no-dev --no-editable -o {{ BUILD_DIR }}/requirements.txt
124124
125125[group("lambda_build")]
126126build_install:
@@ -129,7 +129,11 @@ build_install:
129129 --no-compile-bytecode \
130130 --python-platform x86_64-manylinux2014 \
131131 --python {{ PYTHON_VERSION }} \
132- --target {{ BUILD_PATH }}/pkg \
133- -r {{ BUILD_PATH }}/requirements.txt
132+ --target {{ BUILD_DIR }}/pkg \
133+ -r {{ BUILD_DIR }}/requirements.txt
134+
135+ [group("lambda_build")]
136+ copy_shim:
137+ cp lambda_function.py {{ BUILD_DIR }}/pkg/ || true
134138{% endraw -%}
135139{% - endif -%}
0 commit comments