Skip to content

Commit 6dd88d3

Browse files
committed
move pydantic_core into python/pydantic_core to avoid pytest import crash
1 parent 6a487a1 commit 6dd88d3

13 files changed

+7
-7
lines changed

.github/workflows/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ jobs:
453453
pip install -U pip
454454
pip install -r tests/requirements.txt
455455
pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall
456-
cd tests # change directory to avoid importing local pydantic_core source
457456
pytest
458457
rustup run stable bash -c '$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata'
459458

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ node_modules/
3434
/*.profdata
3535
/*.profraw
3636
/foobar.py
37-
/pydantic_core/*.so
37+
/python/pydantic_core/*.so
3838
/src/self_schema.py

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ make install
106106

107107
That should be it, the example shown above should now run.
108108

109-
You might find it useful to look at [`pydantic_core/_pydantic_core.pyi`](./pydantic_core/_pydantic_core.pyi) and
110-
[`pydantic_core/core_schema.py`](./pydantic_core/core_schema.py) for more information on the python API,
109+
You might find it useful to look at [`pydantic_core/_pydantic_core.pyi`](./python/pydantic_core/_pydantic_core.pyi) and
110+
[`pydantic_core/core_schema.py`](./python/pydantic_core/core_schema.py) for more information on the python API,
111111
beyond that, [`tests/`](./tests) provide a large number of examples of usage.
112112

113113
If you want to contribute to pydantic-core, you'll want to use some other make commands:

build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::process::Command;
44
use std::str::from_utf8;
55

66
fn generate_self_schema() {
7-
println!("cargo:rerun-if-changed=pydantic_core/core_schema.py");
7+
println!("cargo:rerun-if-changed=python/pydantic_core/core_schema.py");
88
println!("cargo:rerun-if-changed=generate_self_schema.py");
99
if Path::new("./src/self_schema.py").exists() && option_env!("CI") == Some("true") {
1010
// self_schema.py already exists and CI indicates we're running on a github actions build,

generate_self_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
else:
3535
# can't import core_schema.py directly as pydantic-core might not be installed
3636
core_schema_spec = importlib.util.spec_from_file_location(
37-
'_typing', str(THIS_DIR / 'pydantic_core' / 'core_schema.py')
37+
'_typing', str(THIS_DIR / 'python' / 'pydantic_core' / 'core_schema.py')
3838
)
3939
core_schema = importlib.util.module_from_spec(core_schema_spec)
4040
core_schema_spec.loader.exec_module(core_schema)

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Funding = 'https://github.com/sponsors/samuelcolvin'
4444
Source = 'https://github.com/pydantic/pydantic-core'
4545

4646
[tool.maturin]
47+
python-source = "python"
4748
module-name = "pydantic_core._pydantic_core"
4849
bindings = 'pyo3'
4950
features = ["pyo3/extension-module", "mimalloc-allocator"]
File renamed without changes.
Binary file not shown.
3.84 MB
Binary file not shown.
File renamed without changes.
File renamed without changes.

tests/test_docstrings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def find_examples(*_directories):
1313

1414

1515
@pytest.mark.skipif(sys.platform not in {'linux', 'darwin'}, reason='Only on linux and macos')
16-
@pytest.mark.parametrize('example', find_examples('pydantic_core/core_schema.py'), ids=str)
16+
@pytest.mark.parametrize('example', find_examples('python/pydantic_core/core_schema.py'), ids=str)
1717
def test_docstrings(example: CodeExample, eval_example: EvalExample):
1818
eval_example.set_config(quotes='single')
1919

0 commit comments

Comments
 (0)