Skip to content

Commit

Permalink
move pydantic_core into python/pydantic_core to avoid pytest import c…
Browse files Browse the repository at this point in the history
…rash
  • Loading branch information
davidhewitt committed Jun 22, 2023
1 parent 6a487a1 commit 6dd88d3
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ jobs:
pip install -U pip
pip install -r tests/requirements.txt
pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall
cd tests # change directory to avoid importing local pydantic_core source
pytest
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'
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ node_modules/
/*.profdata
/*.profraw
/foobar.py
/pydantic_core/*.so
/python/pydantic_core/*.so
/src/self_schema.py
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ make install

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

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

If you want to contribute to pydantic-core, you'll want to use some other make commands:
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::process::Command;
use std::str::from_utf8;

fn generate_self_schema() {
println!("cargo:rerun-if-changed=pydantic_core/core_schema.py");
println!("cargo:rerun-if-changed=python/pydantic_core/core_schema.py");
println!("cargo:rerun-if-changed=generate_self_schema.py");
if Path::new("./src/self_schema.py").exists() && option_env!("CI") == Some("true") {
// self_schema.py already exists and CI indicates we're running on a github actions build,
Expand Down
2 changes: 1 addition & 1 deletion generate_self_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
else:
# can't import core_schema.py directly as pydantic-core might not be installed
core_schema_spec = importlib.util.spec_from_file_location(
'_typing', str(THIS_DIR / 'pydantic_core' / 'core_schema.py')
'_typing', str(THIS_DIR / 'python' / 'pydantic_core' / 'core_schema.py')
)
core_schema = importlib.util.module_from_spec(core_schema_spec)
core_schema_spec.loader.exec_module(core_schema)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Funding = 'https://github.com/sponsors/samuelcolvin'
Source = 'https://github.com/pydantic/pydantic-core'

[tool.maturin]
python-source = "python"
module-name = "pydantic_core._pydantic_core"
bindings = 'pyo3'
features = ["pyo3/extension-module", "mimalloc-allocator"]
Expand Down
File renamed without changes.
Binary file not shown.
File renamed without changes.
Binary file added python/pydantic_core/_pydantic_core.so
Binary file not shown.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def find_examples(*_directories):


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

Expand Down

0 comments on commit 6dd88d3

Please sign in to comment.