Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
113 lines (92 loc) · 3.57 KB
/
Copy pathjustfile
File metadata and controls
113 lines (92 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Genkit Python SDK — run `just py` to see all available commands.
#
# Usage: just py <command>
#
# Examples:
# just py lint # Lint and type-check all Python code
# just py test # Run all Python tests
# just py fmt # Format Python code
set dotenv-load := true
set shell := ["bash", "-euo", "pipefail", "-c"]
# source_directory() returns the directory of *this* justfile, even when
# invoked as a submodule via `mod py` from the root justfile.
py_dir := source_directory()
top_dir := py_dir
# Default: show available commands.
default:
@just --list --unsorted
# --- Development -------------------------------------------------------
# Lint and type-check all Python code (ruff, ty, pyrefly, pyright).
lint:
uv run --directory "{{ py_dir }}" ruff check --fix --preview --unsafe-fixes .
uv run --directory "{{ py_dir }}" ruff format --preview .
uv run --directory "{{ py_dir }}" ty check .
uv run --directory "{{ py_dir }}" pyrefly check .
uv run --directory "{{ py_dir }}" pyright packages/
# Format Python code with ruff.
fmt:
uv run --directory "{{ py_dir }}" ruff format --preview .
uv run --directory "{{ py_dir }}" ruff check --fix --preview --unsafe-fixes .
# Run all Python tests in the default environment.
test:
uv run --directory "{{ py_dir }}" pytest .
# Run tests at oldest declared pyproject.toml floors (restores uv.lock on exit).
test-min-deps *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cd "{{ py_dir }}"
lock_backup="$(mktemp)"
cp uv.lock "$lock_backup"
restore() { mv "$lock_backup" uv.lock && uv sync --frozen --quiet; }
trap restore EXIT
uv lock --resolution lowest-direct
uv sync --frozen
uv run --no-sync pytest {{ ARGS }}
# Run tests across multiple Python versions (3.10–3.14) with nox.
test-nox:
uv run --directory "{{ py_dir }}" nox
# Run security checks (bandit, pip-audit).
security:
"{{ py_dir }}/bin/run_python_security_checks"
# Sync workspace and verify all packages install.
sync:
uv sync --directory "{{ py_dir }}"
uv pip check --directory "{{ py_dir }}"
# Check workspace consistency (versions, naming, deps).
check:
python3 "{{ py_dir }}/scripts/check_consistency.py"
# Check lockfile is up to date.
check-lock:
uv lock --check --directory "{{ py_dir }}"
# --- Code Generation ---------------------------------------------------
# Regenerate typing.py from JSON schema.
generate-schema:
"{{ py_dir }}/bin/generate_schema_typing"
# --- Release -----------------------------------------------------------
# Bump version in all packages.
bump-version VERSION:
"{{ py_dir }}/bin/bump_version" {{ VERSION }}
# Build wheel/sdist packages.
build:
"{{ py_dir }}/bin/build_dists"
# Tag and publish a release from its merged release PR.
create-release VERSION PR *FLAGS:
"{{ py_dir }}/bin/create_release" {{ VERSION }} {{ PR }} {{ FLAGS }}
# Check version consistency across packages.
check-versions:
"{{ py_dir }}/bin/check_versions"