Skip to content

Commit

Permalink
always use maturin for the uv commands in Makefile (#1622)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt authored Feb 5, 2025
1 parent ed15f6c commit fdccecd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 62 deletions.
24 changes: 0 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,32 @@ install-rust-coverage:
.PHONY: build-dev
build-dev:
@rm -f python/pydantic_core/*.so
ifneq ($(USE_MATURIN),)
uv run maturin develop --uv
else
uv pip install --force-reinstall -v -e . --config-settings=build-args='--profile dev'
endif

.PHONY: build-prod
build-prod:
@rm -f python/pydantic_core/*.so
ifneq ($(USE_MATURIN),)
uv run maturin develop --uv --release
else
uv pip install -v -e .
endif

.PHONY: build-profiling
build-profiling:
@rm -f python/pydantic_core/*.so
ifneq ($(USE_MATURIN),)
uv run maturin develop --uv --profile profiling
else
uv pip install --force-reinstall -v -e . --config-settings=build-args='--profile profiling'
endif

.PHONY: build-coverage
build-coverage:
@rm -f python/pydantic_core/*.so
ifneq ($(USE_MATURIN),)
RUSTFLAGS='-C instrument-coverage' uv run maturin develop --uv --release
else
RUSTFLAGS='-C instrument-coverage' uv pip install -v -e .
endif

.PHONY: build-pgo
build-pgo:
@rm -f python/pydantic_core/*.so
$(eval PROFDATA := $(shell mktemp -d))
ifneq ($(USE_MATURIN),)
RUSTFLAGS='-Cprofile-generate=$(PROFDATA)' uv run maturin develop --uv --release
else
RUSTFLAGS='-Cprofile-generate=$(PROFDATA)' uv pip install --force-reinstall -v -e .
endif
pytest tests/benchmarks
$(eval LLVM_PROFDATA := $(shell rustup run stable bash -c 'echo $$RUSTUP_HOME/toolchains/$$RUSTUP_TOOLCHAIN/lib/rustlib/$$(rustc -Vv | grep host | cut -d " " -f 2)/bin/llvm-profdata'))
$(LLVM_PROFDATA) merge -o $(PROFDATA)/merged.profdata $(PROFDATA)
ifneq ($(USE_MATURIN),)
RUSTFLAGS='-Cprofile-use=$(PROFDATA)/merged.profdata' uv run maturin develop --uv --release
else
RUSTFLAGS='-Cprofile-use=$(PROFDATA)/merged.profdata' uv pip install --force-reinstall -v -e .
endif
@rm -rf $(PROFDATA)


Expand Down
57 changes: 21 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
[build-system]
requires = [
'maturin>=1,<2',
'typing-extensions >=4.6.0,!=4.7.0'
]
requires = ['maturin>=1,<2', 'typing-extensions >=4.6.0,!=4.7.0']
build-backend = 'maturin'

[project]
name = 'pydantic_core'
description = "Core functionality for Pydantic validation and serialization"
requires-python = '>=3.9'
authors = [
{name = 'Samuel Colvin', email = 's@muelcolvin.com'}
]
authors = [{ name = 'Samuel Colvin', email = 's@muelcolvin.com' }]
classifiers = [
'Development Status :: 3 - Alpha',
'Programming Language :: Python',
Expand All @@ -32,23 +27,18 @@ classifiers = [
'Operating System :: MacOS',
'Typing :: Typed',
]
dependencies = [
'typing-extensions >=4.6.0,!=4.7.0'
]
dynamic = [
'description',
'license',
'readme',
'version'
]
dependencies = ['typing-extensions >=4.6.0,!=4.7.0']
dynamic = ['description', 'license', 'readme', 'version']

[project.urls]
Homepage = 'https://github.com/pydantic/pydantic-core'
Funding = 'https://github.com/sponsors/samuelcolvin'
Source = 'https://github.com/pydantic/pydantic-core'

[dependency-groups]
dev = ["maturin"]
testing = [
{ include-group = "dev" },
'backports.zoneinfo; python_version < "3.9"',
'coverage',
'dirty-equals',
Expand All @@ -70,26 +60,18 @@ testing = [
'tzdata',
'typing_extensions',
]
linting = [
'griffe',
'pyright',
'ruff',
'mypy',
]
wasm = [
'typing_extensions',
'maturin>=1,<2',
'ruff',
]
linting = [{ include-group = "dev" }, 'griffe', 'pyright', 'ruff', 'mypy']
wasm = [{ include-group = "dev" }, 'typing_extensions', 'ruff']
codspeed = [
# codspeed is only run on CI, with latest version of CPython
'pytest-codspeed; python_version == "3.13" and implementation_name == "cpython"',
]

all = [
{ include-group = 'testing' },
{ include-group = 'linting' },
{ include-group = 'wasm' },
{ include-group = "dev" },
{ include-group = 'testing' },
{ include-group = 'linting' },
{ include-group = 'wasm' },
]

[tool.maturin]
Expand All @@ -105,9 +87,9 @@ target-version = 'py39'
[tool.ruff.lint]
extend-select = ['Q', 'RUF100', 'C90', 'I', 'UP']
extend-ignore = [
'E721', # using type() instead of isinstance() - we use this in tests
'E721', # using type() instead of isinstance() - we use this in tests
]
flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'}
flake8-quotes = { inline-quotes = 'single', multiline-quotes = 'double' }
mccabe = { max-complexity = 13 }
isort = { known-first-party = ['pydantic_core', 'tests'] }

Expand All @@ -130,10 +112,13 @@ timeout = 30
xfail_strict = true
# min, max, mean, stddev, median, iqr, outliers, ops, rounds, iterations
addopts = [
'--benchmark-columns', 'min,mean,stddev,outliers,rounds,iterations',
'--benchmark-group-by', 'group',
'--benchmark-warmup', 'on',
'--benchmark-disable', # this is enable by `make benchmark` when you actually want to run benchmarks
'--benchmark-columns',
'min,mean,stddev,outliers,rounds,iterations',
'--benchmark-group-by',
'group',
'--benchmark-warmup',
'on',
'--benchmark-disable', # this is enable by `make benchmark` when you actually want to run benchmarks
]

[tool.coverage.run]
Expand Down
10 changes: 8 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fdccecd

Please sign in to comment.