diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e97f93af5..82c349e63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -331,7 +331,7 @@ jobs: name: pypi_files path: dist - list-pypi-files: + inspect-pypi-assets: needs: [build] runs-on: ubuntu-latest @@ -344,8 +344,21 @@ jobs: name: pypi_files path: dist - - run: ls -lh dist/ - - run: echo "`ls dist | wc -l` files" + - name: list dist files + run: | + ls -lh dist/ + echo "`ls dist | wc -l` files" + + - name: extract and list s-dist file + run: | + mkdir sdist-files + tar -xvf dist/*.tar.gz -C sdist-files + tree -a sdist-files + + - name: extract and list wheel file + run: | + ls dist/*cp310-manylinux*x86_64.whl | head -n 1 + python -m zipfile --list `ls dist/*cp310-manylinux*x86_64.whl | head -n 1` release: needs: [build, build-wasm-emscripten] diff --git a/Cargo.toml b/Cargo.toml index 03f328c9d..f6bb1987b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,24 @@ license = "MIT" homepage = "https://github.com/pydantic/pydantic-core" repository = "https://github.com/pydantic/pydantic-core.git" readme = "README.md" +include = [ + "/pyproject.toml", + "/README.md", + "/LICENSE", + "/Makefile", + "/build.rs", + "/generate_self_schema.py", + "/rust-toolchain", + "/src", + "!/src/self_schema.py", + "/pydantic_core", + "/tests", + "/.cargo", + "!__pycache__", + "!tests/.hypothesis", + "!tests/.pytest_cache", + "!*.so", +] [dependencies] pyo3 = "0.17.1" diff --git a/build.rs b/build.rs index 594120e96..ecb7cbeda 100644 --- a/build.rs +++ b/build.rs @@ -28,5 +28,6 @@ fn main() { if let Some(true) = version_check::supports_feature("no_coverage") { println!("cargo:rustc-cfg=has_no_coverage"); } - generate_self_schema() + generate_self_schema(); + println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap()); } diff --git a/generate_self_schema.py b/generate_self_schema.py index 255df73d7..6a7b77b72 100644 --- a/generate_self_schema.py +++ b/generate_self_schema.py @@ -11,7 +11,6 @@ from collections.abc import Callable from datetime import date, datetime, time, timedelta from pathlib import Path -from pprint import pformat from typing import TYPE_CHECKING, Any, Dict, ForwardRef, List, Type, Union from typing_extensions import get_args, is_typeddict @@ -169,8 +168,7 @@ def main() -> None: 'choices': choices, } python_code = ( - f'# this file is auto-generated by generate_self_schema.py, DO NOT edit manually\n' - f'self_schema = {pformat(schema)}\n' + f'# this file is auto-generated by generate_self_schema.py, DO NOT edit manually\nself_schema = {schema}\n' ) try: from black import Mode, TargetVersion, format_file_contents diff --git a/pydantic_core/_pydantic_core.pyi b/pydantic_core/_pydantic_core.pyi index 872c1a967..b7d8ff2dc 100644 --- a/pydantic_core/_pydantic_core.pyi +++ b/pydantic_core/_pydantic_core.pyi @@ -10,6 +10,7 @@ else: __all__ = '__version__', 'SchemaValidator', 'SchemaError', 'ValidationError', 'PydanticValueError' __version__: str +build_profile: str class SchemaValidator: title: str diff --git a/pyproject.toml b/pyproject.toml index baee3c7e4..913f2cce9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,6 @@ Source = 'https://github.com/pydantic/pydantic-core' [tool.maturin] bindings = 'pyo3' -sdist-include = ['src/self_schema.py'] [tool.pytest.ini_options] testpaths = 'tests' diff --git a/src/lib.rs b/src/lib.rs index f5cf3bba4..82a222332 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,7 @@ pub fn get_version() -> String { #[pymodule] fn _pydantic_core(_py: Python, m: &PyModule) -> PyResult<()> { m.add("__version__", get_version())?; + m.add("build_profile", env!("PROFILE"))?; m.add_class::()?; m.add_class::()?; m.add_class::()?; diff --git a/tests/test_misc.py b/tests/test_misc.py index 4f8432899..9599c60ef 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -4,7 +4,7 @@ import pytest -from pydantic_core._pydantic_core import SchemaError, SchemaValidator, ValidationError, __version__ +from pydantic_core._pydantic_core import SchemaError, SchemaValidator, ValidationError, __version__, build_profile @pytest.mark.parametrize('obj', [ValidationError, SchemaValidator, SchemaError]) @@ -17,6 +17,10 @@ def test_version(): assert '.' in __version__ +def test_build_profile(): + assert build_profile in ('debug', 'release') + + def test_schema_error(): err = SchemaError('test') assert isinstance(err, Exception)