Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ jobs:
name: pypi_files
path: dist

list-pypi-files:
inspect-pypi-assets:
needs: [build]
runs-on: ubuntu-latest

Expand All @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
4 changes: 1 addition & 3 deletions generate_self_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pydantic_core/_pydantic_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ else:

__all__ = '__version__', 'SchemaValidator', 'SchemaError', 'ValidationError', 'PydanticValueError'
__version__: str
build_profile: str

class SchemaValidator:
title: str
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<SchemaValidator>()?;
m.add_class::<ValidationError>()?;
m.add_class::<SchemaError>()?;
Expand Down
6 changes: 5 additions & 1 deletion tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)
Expand Down