-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Enhance Makefile for Windows compatibility and Python version support #3159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AstroAir
wants to merge
10
commits into
pydantic:main
Choose a base branch
from
NJUPT-SAST-CXX:fix-makefile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1f30684
Enhance Makefile for Windows compatibility and improve environment se…
AstroAir a6810ba
Merge branch 'pydantic:main' into fix-makefile
AstroAir 17635ba
Merge branch 'main' into fix-makefile
AstroAir 015c4f2
Merge branch 'main' into fix-makefile
AstroAir 000d2c6
Merge branch 'main' into fix-makefile
AstroAir 9421542
Enhance Makefile for installing insiders packages with improved error…
AstroAir fec290c
Merge branch 'main' into fix-makefile
AstroAir 227cdcd
Merge branch 'main' into fix-makefile
AstroAir 88f2945
Merge branch 'main' into fix-makefile
AstroAir 9a30d4b
Fix Makefile help command for Windows
AstroAir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.