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

EAPI=8
CRATES="
	addr2line@0.27.1
	adler2@2.0.1
	adler32@1.2.0
	aho-corasick@1.1.5
	android_system_properties@0.1.6
	anes@0.1.6
	anstream@1.0.0
	anstyle-parse@1.0.0
	anstyle-query@1.1.5
	anstyle-wincon@3.0.11
	anstyle@1.0.14
	anyhow@1.0.104
	ar@0.9.0
	arc-swap@1.9.3
	async-trait@0.1.92
	autocfg@1.5.1
	backtrace@0.3.77
	better-panic@0.3.0
	bindgen@0.71.1
	bitflags@1.3.2
	bitflags@2.13.2
	bitvec@1.1.1
	block-buffer@0.10.4
	bumpalo@3.20.3
	byteorder@1.5.0
	bytes@1.12.1
	cast@0.3.0
	cc@1.11.0
	cexpr@0.6.0
	cfg-if@1.0.5
	chrono@0.4.45
	ciborium-io@0.2.2
	ciborium-ll@0.2.2
	ciborium@0.2.2
	clang-sys@1.9.1
	clap@4.6.7
	clap_builder@4.6.7
	clap_lex@1.1.1
	cmake@0.1.58
	colorchoice@1.0.5
	console@0.15.11
	console_error_panic_hook@0.1.7
	core-foundation-sys@0.8.7
	cpufeatures@0.2.17
	crc32fast@1.5.4
	criterion-plot@0.5.0
	criterion@0.5.1
	crossbeam-deque@0.8.8
	crossbeam-epoch@0.9.21
	crossbeam-utils@0.8.23
	crunchy@0.2.4
	crypto-common@0.1.7
	digest@0.10.7
	dynasm@1.2.3
	dynasmrt@1.2.3
	either@1.19.0
	encode_unicode@1.0.0
	fern@0.7.1
	find-msvc-tools@0.1.15
	flate2@1.1.10
	funty@2.0.0
	generic-array@0.14.7
	gimli@0.34.0
	glob@0.3.4
	goblin@0.10.7
	half@2.7.1
	heck@0.5.0
	hermit-abi@0.5.3
	hex@0.4.3
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.65
	indoc@2.0.8
	inflate@0.4.5
	is-terminal@0.4.17
	is_terminal_polyfill@1.70.2
	itertools@0.10.5
	itertools@0.13.0
	itertools@0.14.0
	itoa@1.0.18
	js-sys@0.3.77
	lazy_static@1.5.1
	libc@0.2.191
	libloading@0.8.9
	log@0.4.35
	memchr@2.8.3
	memmap2@0.5.10
	memoffset@0.9.1
	minimal-lexical@0.2.1
	miniz_oxide@0.9.1
	nom@7.1.3
	nu-ansi-term@0.50.3
	num-traits@0.2.19
	object@0.36.7
	object@0.40.0
	once_cell@1.21.4
	once_cell_polyfill@1.70.2
	oorandom@11.1.5
	pin-project-lite@0.2.17
	pkg-config@0.3.34
	plain@0.2.3
	plotters-backend@0.3.7
	plotters-svg@0.3.7
	plotters@0.3.7
	portable-atomic@1.15.0
	prettyplease@0.2.37
	proc-macro-error-attr@1.0.4
	proc-macro-error@1.0.4
	proc-macro2@1.0.107
	prost-derive@0.13.5
	prost@0.13.5
	pyo3-build-config@0.27.2
	pyo3-ffi@0.27.2
	pyo3-log@0.13.5
	pyo3-macros-backend@0.27.2
	pyo3-macros@0.27.2
	pyo3@0.27.2
	python3-dll-a@0.2.15
	quote@1.0.47
	radium@0.7.0
	rayon-core@1.13.0
	rayon@1.12.0
	regex-automata@0.4.18
	regex-syntax@0.8.11
	regex@1.13.1
	rustc-demangle@0.1.28
	rustc-hash@2.1.3
	rustversion@1.0.23
	ruzstd@0.7.3
	same-file@1.0.6
	scroll@0.13.0
	scroll_derive@0.13.2
	serde@1.0.229
	serde_core@1.0.229
	serde_derive@1.0.229
	serde_json@1.0.154
	sha256@1.6.0
	sha2@0.10.9
	shlex@1.3.0
	shlex@2.0.1
	simd-adler32@0.3.10
	smallvec@1.16.4
	static_assertions@1.1.0
	strsim@0.11.1
	syn@1.0.109
	syn@2.0.119
	syn@3.0.9
	tap@1.0.1
	target-lexicon@0.13.5
	thiserror-impl@2.0.21
	thiserror@2.0.21
	tinytemplate@1.2.1
	tokio@1.54.1
	twox-hash@1.6.3
	typenum@1.20.1
	unicode-ident@1.0.27
	unicorn-engine-sys@2.1.5
	unicorn-engine@2.1.5
	unindent@0.2.4
	utf8parse@0.2.2
	version_check@0.9.5
	walkdir@2.5.0
	wasm-bindgen-backend@0.2.100
	wasm-bindgen-macro-support@0.2.100
	wasm-bindgen-macro@0.2.100
	wasm-bindgen-shared@0.2.100
	wasm-bindgen@0.2.100
	web-sys@0.3.77
	widestring@1.2.1
	winapi-util@0.1.11
	windows-core@0.62.2
	windows-implement@0.60.2
	windows-interface@0.59.3
	windows-link@0.2.1
	windows-result@0.4.1
	windows-strings@0.5.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
	wyz@0.5.1
	zerocopy-derive@0.8.63
	zerocopy@0.8.63
	zlib-rs@0.6.8
	zmij@1.0.23
	zydis@4.1.1
"
DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=maturin
PYTHON_COMPAT=( python3_{10..15} )

inherit cargo distutils-r1

DESCRIPTION="Python library for parsing, compiling, and matching FLIRT signatures"
HOMEPAGE="https://pypi.org/project/python-flirt/"
SRC_URI="https://github.com/williballenthin/lancelot/archive/refs/tags/v${PV}.tar.gz -> lancelot-${PV}.gh.tar.gz
	${CARGO_CRATE_URIS}"
S="${WORKDIR}/lancelot-${PV}/pyflirt"

LICENSE="Apache-2.0"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD GPL-2 ISC MIT MPL-2.0
	Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

BDEPEND="test? (
	dev-python/pytest-sugar[${PYTHON_USEDEP}]
	dev-python/pytest-instafail[${PYTHON_USEDEP}]
)"

python_prepare_all() {
	sed -re 's/^ar =.*/ar = "0.9"/' -i ../bin/Cargo.toml || die
	cp "${FILESDIR}/Cargo.lock" ../Cargo.lock || die
	distutils-r1_python_prepare_all
}

EPYTEST_PLUGINS=( pytest-instafail pytest-sugar )
distutils_enable_tests pytest