@@ -20,6 +20,12 @@ LYCHEE_VERSION := $(shell bash scripts/cargo-tool-version.sh lychee)
2020# Tool versions from tools.toml
2121PREK_VERSION := $(shell bash scripts/tool-version.sh prek)
2222UV_VERSION := $(shell bash scripts/uv-version.sh)
23+ UV_V2_REQUIRED_SPEC := $(shell awk -F'"' '\
24+ /^\[tool\.uv\]/ { in_section=1; next } \
25+ /^\[/ { in_section=0 } \
26+ in_section && /^[[:space:]]* required-version[[:space:]]* =/ { print $$2; exit } \
27+ ' python/pyproject.toml)
28+ UV_V2_REQUIRED_VERSION := $(patsubst ==% ,% ,$(UV_V2_REQUIRED_SPEC ) )
2329
2430V = 0 # 0 / 1 - verbose mode
2531Q = $(if $(filter 1,$V) ,,@) # Quiet mode, suppress command output
@@ -32,6 +38,8 @@ VERBOSE ?= true
3238# Set UV_SYNC_FLAGS= to make uv prune packages not in uv.lock
3339UV_SYNC_FLAGS ?= --inexact
3440
41+ V2_CARGO_TARGET_DIR ?= $(CURDIR ) /target-v2
42+
3543PIP_AUDIT_IGNORE_FLAGS :=
3644
3745# TARGET_DIR controls where cargo places build artifacts.
@@ -1037,19 +1045,40 @@ test-performance: #-- Run performance tests with codspeed benchmarking
10371045
10381046.PHONY : sync-v2
10391047sync-v2 : # -- Sync v2 Python dependencies (without building the package)
1040- $(info $(M ) Syncing v2 Python dependencies...)
1048+ @if [ -z " $( UV_V2_REQUIRED_SPEC) " ]; then \
1049+ printf " $( RED) ERROR: Could not find required-version in python/pyproject.toml$( RESET) \n" ; \
1050+ exit 1; \
1051+ fi
1052+ @if [ " $( UV_V2_REQUIRED_SPEC) " = " $( UV_V2_REQUIRED_VERSION) " ]; then \
1053+ printf " $( RED) ERROR: python/pyproject.toml required-version must use ==A.B.C, found $( UV_V2_REQUIRED_SPEC) $( RESET) \n" ; \
1054+ exit 1; \
1055+ fi
1056+ @found=" $$ (uv --version 2>/dev/null | awk '{print $$ 2}' || true)" ; \
1057+ if [ -z " $$ found" ]; then \
1058+ printf " $( RED) ERROR: uv not found, ==$( UV_V2_REQUIRED_VERSION) required; run \` uv self update --version $( UV_V2_REQUIRED_VERSION) \` or prepend a matching binary to PATH.$( RESET) \n" ; \
1059+ exit 1; \
1060+ fi ; \
1061+ if [ " $$ found" != " $( UV_V2_REQUIRED_VERSION) " ]; then \
1062+ printf " $( RED) ERROR: uv $$ found found, ==$( UV_V2_REQUIRED_VERSION) required; run \` uv self update --version $( UV_V2_REQUIRED_VERSION) \` or prepend a matching binary to PATH.$( RESET) \n" ; \
1063+ exit 1; \
1064+ fi
1065+ @printf " $( M) Syncing v2 Python dependencies...\n"
10411066 $Q cd python && VIRTUAL_ENV= uv sync --all-groups --all-extras --no-install-package nautilus-trader $(UV_SYNC_FLAGS )
10421067
10431068.PHONY : build-debug-v2
10441069build-debug-v2 : sync-v2 # -- Build the v2 Python package in debug mode (also regenerates type stubs)
10451070 @$(MAKE ) --no-print-directory py-stubs-v2
10461071 $(info $(M ) Building v2 extension in debug mode...)
1047- $Q cd python && VIRTUAL_ENV= CARGO_TARGET_DIR=../target-v2 uv run --no-sync maturin develop
1072+ $Q cd python && VIRTUAL_ENV= CARGO_TARGET_DIR=$( V2_CARGO_TARGET_DIR ) uv run --no-sync maturin develop
10481073
10491074.PHONY : py-stubs-v2
10501075py-stubs-v2 : sync-v2 # -- Regenerate v2 Python type stubs from Rust bindings
10511076 $(info $(M ) Generating v2 Python type stubs...)
1052- $Q cd python && VIRTUAL_ENV= CARGO_TARGET_DIR=$(CURDIR ) /target-v2 uv run --no-sync python generate_stubs.py
1077+ $Q cd python && VIRTUAL_ENV= CARGO_TARGET_DIR=$(V2_CARGO_TARGET_DIR ) uv run --no-sync python generate_stubs.py
1078+
1079+ .PHONY : check-v2-generated-drift
1080+ check-v2-generated-drift : # -- Check v2 generated stubs and docstrings are committed
1081+ $Q bash scripts/ci/check-v2-generated-drift.bash
10531082
10541083.PHONY : update-v2
10551084update-v2 : cargo-update # -- Update v2 dependencies (cargo and uv)
@@ -1064,7 +1093,7 @@ pytest-v2: build-debug-v2 #-- Run v2 Python tests
10641093
10651094.PHONY : pre-flight-v2
10661095pre-flight-v2 : export CARGO_TARGET_DIR=target-v2
1067- pre-flight-v2 : # -- Run comprehensive v2 pre-flight checks (format, check-code, cargo-test, build, pytest )
1096+ pre-flight-v2 : # -- Run v2 pre-flight checks (format, tests, build, generated drift, audit )
10681097 $(info $(M ) Running v2 pre-flight checks...)
10691098 @if ! git diff --quiet; then \
10701099 printf " $( RED) ERROR: You have unstaged changes$( RESET) \n" ; \
@@ -1077,6 +1106,7 @@ pre-flight-v2: #-- Run comprehensive v2 pre-flight checks (format, check-code,
10771106 && $(MAKE ) --no-print-directory check-code EXTRA_FEATURES=" capnp,hypersync" \
10781107 && $(MAKE ) --no-print-directory cargo-test-extras \
10791108 && $(MAKE ) --no-print-directory build-debug-v2 \
1109+ && $(MAKE ) --no-print-directory check-v2-generated-drift \
10801110 && $(MAKE ) --no-print-directory pytest-v2 \
10811111 && $(MAKE ) --no-print-directory security-audit \
10821112 $(call timer_end,Pre-flight)
0 commit comments