Skip to content

Recipe to build pydantic-core (required for Pydantic 2) - #1413

Open
pax0r wants to merge 2 commits into
chaquo:masterfrom
pax0r:pydantic-core
Open

Recipe to build pydantic-core (required for Pydantic 2)#1413
pax0r wants to merge 2 commits into
chaquo:masterfrom
pax0r:pydantic-core

Conversation

@pax0r

@pax0r pax0r commented Oct 30, 2025

Copy link
Copy Markdown

As for Python 3.13 now includes sysconfig in Chaquopy build it is possible to directly build rust packages like pydantic-core.

This should fix #1017 at least for Python 3.13

In fact we should be able to build any rust-based package for Android this way.

@mhsmith

mhsmith commented Oct 31, 2025

Copy link
Copy Markdown
Member

@freakboy3742: I haven't looked at this yet, but it might be relevant to what you're working on.

@Herklos

Herklos commented Nov 28, 2025

Copy link
Copy Markdown

Great job @pax0r! I can’t wait for it to be merged.

@mhsmith

mhsmith commented Nov 29, 2025

Copy link
Copy Markdown
Member

Thanks for the PR. To add a new package, we need a test script to verify that it works. Please do the following:

  • Follow the instructions in "Testing a package" in the README.
  • Push your test script to this PR.
  • Post a comment saying which Python versions and ABIs you have tested. You don't need to cover every combination, but you should get at least one of them passing.

Comment thread server/pypi/README.md
`fortran` subdirectory in the same directory as this README, and unpack the .bz2 files
into it.
* `rust`: `rustup` must be on the PATH.
* `rust`: `rustup` must be on the PATH. One can set `PYO3_NO_PYTHON=1` in `script_env:` to build without a Python interpreter (https://pyo3.rs/main/building-and-distribution#building-abi3-extensions-without-a-python-interpreter).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap at 88 columns.

Comment on lines +675 to +676
# available in the `target` packages for Python 3.12 and older, but are available on Python 3.13.
# However, since PyO3 0.16.4, it's possible to compile abi3 modules without sysconfig

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap at 88 columns.

Comment on lines +5 to +8
build:
script_env:
- PYO3_NO_PYTHON=1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the cryptography changes from this PR; we can do that in #1375.

Comment on lines +8 to +9
host:
- python

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

host: python is unnecessary, as this is the default for all packages whose source is downloaded from PyPI.

Comment on lines +717 to +719
if "rust" in self.non_python_build_reqs:
self.get_rust_env_vars(env)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining why this needs to be done after script_env.

run(f"{os.environ['AR']} rc {self.host_env}/chaquopy/lib/lib{name}.a")

def extract_stdlib(self):
run(f"unzip -q -d {self.chaquopy_dir}/lib {self.std_lib_zip}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directly under lib is the wrong place for the Python standard library; it should be under lib/python3.13, for example. So are you sure this is actually having any effect? Maybe the build would work fine without it.

If it's really necessary, then please do the following:

  • Change std_lib to stdlib, which is the more conventional spelling.
  • Merge extract_stdlib into extract_target, because making it a separate function is taking up more space for no benefit.

@Jzhenli

Jzhenli commented Apr 23, 2026

Copy link
Copy Markdown

Anything update on the pydantic-core v2?

@mhsmith

mhsmith commented Apr 23, 2026

Copy link
Copy Markdown
Member

Since PyPI and cibuildwheel now support Android, we now prefer everyone to submit PRs to each package's own repository. See the FAQ for instructions.

As long as they're of sufficient quality, I will still accept PRs to update existing packages in the Chaquopy repository which don't have official Android wheels on PyPI yet. I'm unlikely to accept any new packages, unless they're very popular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

pydantic v2

4 participants