# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=maturin
PYPI_VERIFY_REPO=https://github.com/pydantic/jiter
PYTHON_COMPAT=( python3_{12..14} )

CRATES="
	ahash@0.8.12
	aho-corasick@1.1.4
	anes@0.1.6
	anstyle@1.0.14
	autocfg@1.5.1
	bit-set@0.8.0
	bit-vec@0.8.0
	bitflags@2.13.0
	bitvec@1.1.1
	bumpalo@3.20.3
	cast@0.3.0
	cfg-if@1.0.4
	ciborium-io@0.2.2
	ciborium-ll@0.2.2
	ciborium@0.2.2
	clap@4.6.1
	clap_builder@4.6.0
	clap_lex@1.1.0
	codspeed-criterion-compat-walltime@2.10.1
	codspeed-criterion-compat@2.10.1
	codspeed@2.10.1
	colored@2.2.0
	criterion-plot@0.5.0
	crossbeam-deque@0.8.6
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.21
	crunchy@0.2.4
	either@1.16.0
	equivalent@1.0.2
	errno@0.3.14
	fastrand@2.4.1
	fnv@1.0.7
	funty@2.0.0
	futures-core@0.3.32
	futures-task@0.3.32
	futures-util@0.3.32
	getrandom@0.3.4
	getrandom@0.4.3
	half@2.7.1
	hashbrown@0.17.1
	heck@0.5.0
	hermit-abi@0.5.2
	indexmap@2.14.0
	is-terminal@0.4.17
	itertools@0.10.5
	itoa@1.0.18
	js-sys@0.3.103
	lazy_static@1.5.0
	lexical-parse-float@1.0.6
	lexical-parse-integer@1.0.6
	lexical-util@1.0.7
	libc@0.2.186
	linux-raw-sys@0.12.1
	memchr@2.8.2
	num-bigint@0.4.6
	num-integer@0.1.46
	num-traits@0.2.19
	once_cell@1.21.4
	oorandom@11.1.5
	paste@1.0.15
	pin-project-lite@0.2.17
	plotters-backend@0.3.7
	plotters-svg@0.3.7
	plotters@0.3.7
	portable-atomic@1.13.1
	ppv-lite86@0.2.21
	proc-macro2@1.0.106
	proptest@1.11.0
	pyo3-build-config@0.29.0
	pyo3-ffi@0.29.0
	pyo3-macros-backend@0.29.0
	pyo3-macros@0.29.0
	pyo3@0.29.0
	quick-error@1.2.3
	quote@1.0.46
	r-efi@5.3.0
	r-efi@6.0.0
	radium@0.7.0
	rand@0.9.4
	rand_chacha@0.9.0
	rand_core@0.9.5
	rand_xorshift@0.4.0
	rayon-core@1.13.0
	rayon@1.12.0
	regex-automata@0.4.14
	regex-syntax@0.8.11
	regex@1.12.4
	rustix@1.1.4
	rustversion@1.0.22
	rusty-fork@0.3.1
	same-file@1.0.6
	serde@1.0.228
	serde_core@1.0.228
	serde_derive@1.0.228
	serde_json@1.0.150
	slab@0.4.12
	smallvec@1.15.2
	syn@2.0.118
	tap@1.0.1
	target-lexicon@0.13.5
	tempfile@3.27.0
	tinytemplate@1.2.1
	unarray@0.1.4
	unicode-ident@1.0.24
	uuid@1.23.4
	version_check@0.9.5
	wait-timeout@0.2.1
	walkdir@2.5.0
	wasip2@1.0.4+wasi-0.2.12
	wasm-bindgen-macro-support@0.2.126
	wasm-bindgen-macro@0.2.126
	wasm-bindgen-shared@0.2.126
	wasm-bindgen@0.2.126
	web-sys@0.3.103
	winapi-util@0.1.11
	windows-link@0.2.1
	windows-sys@0.59.0
	windows-sys@0.61.2
	windows-targets@0.52.6
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.52.6
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.52.6
	wit-bindgen@0.57.1
	wyz@0.5.1
	zerocopy-derive@0.8.52
	zerocopy@0.8.52
	zmij@1.0.21
"
# jiter is a Rust workspace; MSRV comes from [workspace.package] rust-version
# in the sdist's Cargo.toml (edition 2024 needs >=1.85 anyway).
RUST_MIN_VER="1.88.0"

# The pypi eclass derives SRC_URI from ${PN}/${PV}; cargo.eclass only *computes*
# CARGO_CRATE_URIS, so the crate tarballs have to be appended explicitly.
inherit cargo distutils-r1 pypi

DESCRIPTION="Fast iterable JSON parser"
HOMEPAGE="
	https://github.com/pydantic/jiter/
	https://pypi.org/project/jiter/
"
SRC_URI+="
	${CARGO_CRATE_URIS}
"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+=" Apache-2.0 Apache-2.0-with-LLVM-exceptions MIT MPL-2.0 Unicode-3.0"
SLOT="0"
KEYWORDS="~amd64 ~arm64"

# Upstream declares no runtime dependencies (requires_dist is empty).

QA_FLAGS_IGNORED="usr/lib.*/py.*/site-packages/jiter.*\\.so"

# The test suite uses dirty-equals for NaN comparisons; no pytest plugins.
EPYTEST_PLUGINS=()
distutils_enable_tests pytest
# NOTE: must be +=, distutils_enable_tests already appended pytest to BDEPEND.
BDEPEND+="
	test? (
		dev-python/dirty-equals[${PYTHON_USEDEP}]
	)
"

src_unpack() {
	pypi_src_unpack
	cargo_src_unpack
}

python_test() {
	# The Python test suite lives in the Rust workspace member, not at ${S}.
	epytest crates/jiter-python/tests
}