From 1f30684b62e54b92dc9311d02c66511f989b3cd6 Mon Sep 17 00:00:00 2001 From: AstroAir Date: Tue, 14 Oct 2025 15:59:08 +0800 Subject: [PATCH 1/3] Enhance Makefile for Windows compatibility and improve environment setup for Python versions 3.10 to 3.13 --- Makefile | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c3e7a8484d..6c50216667 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,12 @@ .DEFAULT_GOAL := all +# Detect OS +ifeq ($(OS),Windows_NT) + DETECTED_OS := Windows +else + DETECTED_OS := $(shell uname -s) +endif + .PHONY: .uv .uv: ## Check that uv is installed @uv --version || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/' @@ -15,10 +22,17 @@ install: .uv .pre-commit ## Install the package, dependencies, and pre-commit fo .PHONY: install-all-python install-all-python: ## Install and synchronize an interpreter for every python version +ifeq ($(DETECTED_OS),Windows) + @set UV_PROJECT_ENVIRONMENT=.venv310 & uv sync --python 3.10 --frozen --all-extras --all-packages --group lint --group docs + @set UV_PROJECT_ENVIRONMENT=.venv311 & uv sync --python 3.11 --frozen --all-extras --all-packages --group lint --group docs + @set UV_PROJECT_ENVIRONMENT=.venv312 & uv sync --python 3.12 --frozen --all-extras --all-packages --group lint --group docs + @set UV_PROJECT_ENVIRONMENT=.venv313 & uv sync --python 3.13 --frozen --all-extras --all-packages --group lint --group docs +else UV_PROJECT_ENVIRONMENT=.venv310 uv sync --python 3.10 --frozen --all-extras --all-packages --group lint --group docs UV_PROJECT_ENVIRONMENT=.venv311 uv sync --python 3.11 --frozen --all-extras --all-packages --group lint --group docs UV_PROJECT_ENVIRONMENT=.venv312 uv sync --python 3.12 --frozen --all-extras --all-packages --group lint --group docs UV_PROJECT_ENVIRONMENT=.venv313 uv sync --python 3.13 --frozen --all-extras --all-packages --group lint --group docs +endif .PHONY: sync sync: .uv ## Update local packages and uv.lock @@ -36,8 +50,12 @@ lint: ## Lint the code .PHONY: typecheck-pyright typecheck-pyright: +ifeq ($(DETECTED_OS),Windows) + @set PYRIGHT_PYTHON_IGNORE_WARNINGS=1 & uv run pyright +else @# PYRIGHT_PYTHON_IGNORE_WARNINGS avoids the overhead of making a request to github on every invocation PYRIGHT_PYTHON_IGNORE_WARNINGS=1 uv run pyright +endif .PHONY: typecheck-mypy typecheck-mypy: @@ -57,10 +75,17 @@ test: ## Run tests and collect coverage data .PHONY: test-all-python test-all-python: ## Run tests on Python 3.10 to 3.13 +ifeq ($(DETECTED_OS),Windows) + @set UV_PROJECT_ENVIRONMENT=.venv310 & uv run --python 3.10 --all-extras --all-packages coverage run -p -m pytest + @set UV_PROJECT_ENVIRONMENT=.venv311 & uv run --python 3.11 --all-extras --all-packages coverage run -p -m pytest + @set UV_PROJECT_ENVIRONMENT=.venv312 & uv run --python 3.12 --all-extras --all-packages coverage run -p -m pytest + @set UV_PROJECT_ENVIRONMENT=.venv313 & uv run --python 3.13 --all-extras --all-packages coverage run -p -m pytest +else UV_PROJECT_ENVIRONMENT=.venv310 uv run --python 3.10 --all-extras --all-packages coverage run -p -m pytest UV_PROJECT_ENVIRONMENT=.venv311 uv run --python 3.11 --all-extras --all-packages coverage run -p -m pytest UV_PROJECT_ENVIRONMENT=.venv312 uv run --python 3.12 --all-extras --all-packages coverage run -p -m pytest UV_PROJECT_ENVIRONMENT=.venv313 uv run --python 3.13 --all-extras --all-packages coverage run -p -m pytest +endif @uv run coverage combine @uv run coverage report @@ -89,13 +114,11 @@ docs-serve: ## Build and serve the documentation .PHONY: .docs-insiders-install .docs-insiders-install: ## Install insiders packages for docs if necessary -ifeq ($(shell uv pip show mkdocs-material | grep -q insiders && echo 'installed'), installed) - @echo 'insiders packages already installed' -else ifeq ($(PPPR_TOKEN),) - @echo "Error: PPPR_TOKEN is not set, can't install insiders packages" +ifeq ($(PPPR_TOKEN),) + @echo Error: PPPR_TOKEN is not set, cannot install insiders packages @exit 1 else - @echo 'installing insiders packages...' + @echo installing insiders packages... @uv pip install --reinstall --no-deps \ --extra-index-url https://pydantic:${PPPR_TOKEN}@pppr.pydantic.dev/simple/ \ mkdocs-material mkdocstrings-python @@ -125,6 +148,11 @@ all: format lint typecheck testcov ## Run code formatting, linting, static type .PHONY: help help: ## Show this help (usage: make help) +ifeq ($(DETECTED_OS),Windows) + @echo Usage: make [recipe] + @echo Recipes: + @uv run python -c "import re; [print(f' {m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z0-9_-]+):.*?## (.*)$$', open('$(MAKEFILE_LIST)').read(), re.MULTILINE)]" +else @echo "Usage: make [recipe]" @echo "Recipes:" @awk '/^[a-zA-Z0-9_-]+:.*?##/ { \ @@ -135,3 +163,4 @@ help: ## Show this help (usage: make help) printf " \033[36m%-20s\033[0m %s\n", recipe, substr($$0, RSTART + 3, RLENGTH); \ } \ }' $(MAKEFILE_LIST) +endif From 942154294c6f84d53461a5a60c6ad82f8e12c5a4 Mon Sep 17 00:00:00 2001 From: AstroAir Date: Thu, 16 Oct 2025 16:44:28 +0800 Subject: [PATCH 2/3] Enhance Makefile for installing insiders packages with improved error handling and OS-specific commands --- Makefile | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 6c50216667..1e4a06d108 100644 --- a/Makefile +++ b/Makefile @@ -114,14 +114,31 @@ docs-serve: ## Build and serve the documentation .PHONY: .docs-insiders-install .docs-insiders-install: ## Install insiders packages for docs if necessary -ifeq ($(PPPR_TOKEN),) - @echo Error: PPPR_TOKEN is not set, cannot install insiders packages - @exit 1 +ifeq ($(DETECTED_OS),Windows) + @powershell -NoProfile -Command " \ + $$material = uv pip show mkdocs-material 2>$$null; \ + if ($$material -match 'insiders') { \ + Write-Host 'insiders packages already installed'; \ + } elseif ('$(PPPR_TOKEN)' -eq '') { \ + Write-Host 'Error: PPPR_TOKEN is not set, cannot install insiders packages'; \ + exit 1; \ + } else { \ + Write-Host 'installing insiders packages...'; \ + uv pip install --reinstall --no-deps --extra-index-url https://pydantic:$(PPPR_TOKEN)@pppr.pydantic.dev/simple/ mkdocs-material mkdocstrings-python; \ + } \ + " else - @echo installing insiders packages... - @uv pip install --reinstall --no-deps \ - --extra-index-url https://pydantic:${PPPR_TOKEN}@pppr.pydantic.dev/simple/ \ - mkdocs-material mkdocstrings-python + ifeq ($(shell uv pip show mkdocs-material | grep -q insiders && echo 'installed'), installed) + @echo 'insiders packages already installed' + else ifeq ($(PPPR_TOKEN),) + @echo "Error: PPPR_TOKEN is not set, can't install insiders packages" + @exit 1 + else + @echo 'installing insiders packages...' + @uv pip install --reinstall --no-deps \ + --extra-index-url https://pydantic:${PPPR_TOKEN}@pppr.pydantic.dev/simple/ \ + mkdocs-material mkdocstrings-python + endif endif .PHONY: docs-insiders @@ -151,7 +168,7 @@ help: ## Show this help (usage: make help) ifeq ($(DETECTED_OS),Windows) @echo Usage: make [recipe] @echo Recipes: - @uv run python -c "import re; [print(f' {m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z0-9_-]+):.*?## (.*)$$', open('$(MAKEFILE_LIST)').read(), re.MULTILINE)]" + @uv run python -c "import re; [print(f' {m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z0-9_-]+):.*?## (.*)$$', open('$(MAKEFILE_LIST)').read(), re.MULTILINE)]" || powershell -NoProfile -Command "Get-Content '$(MAKEFILE_LIST)' | Select-String -Pattern '^([a-zA-Z0-9_-]+):.*?## (.*)$$' | ForEach-Object { Write-Host (' {0,-20} {1}' -f $$_.Matches[0].Groups[1].Value, $$_.Matches[0].Groups[2].Value) }" else @echo "Usage: make [recipe]" @echo "Recipes:" From 9a30d4bb02e745f3442216c1cae52a282c86e1db Mon Sep 17 00:00:00 2001 From: Max Qian <64824374+AstroAir@users.noreply.github.com> Date: Sat, 1 Nov 2025 22:04:55 +0800 Subject: [PATCH 3/3] Fix Makefile help command for Windows --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b37eb03fcd..585e9731c4 100644 --- a/Makefile +++ b/Makefile @@ -166,7 +166,7 @@ help: ## Show this help (usage: make help) ifeq ($(DETECTED_OS),Windows) @echo Usage: make [recipe] @echo Recipes: - @uv run python -c "import re; [print(f' {m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z0-9_-]+):.*?## (.*)$$', open('$(MAKEFILE_LIST)').read(), re.MULTILINE)]" || powershell -NoProfile -Command "Get-Content '$(MAKEFILE_LIST)' | Select-String -Pattern '^([a-zA-Z0-9_-]+):.*?## (.*)$$' | ForEach-Object { Write-Host (' {0,-20} {1}' -f $$_.Matches[0].Groups[1].Value, $$_.Matches[0].Groups[2].Value) }" + @powershell -NoProfile -Command "Get-Content '$(MAKEFILE_LIST)' | Select-String -Pattern '^([a-zA-Z0-9_-]+):.*?## (.*)$$' | ForEach-Object { Write-Host (' {0,-20} {1}' -f $$_.Matches[0].Groups[1].Value, $$_.Matches[0].Groups[2].Value) }" else @echo "Usage: make [recipe]" @echo "Recipes:"