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

EAPI=8

DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=maturin
PYTHON_COMPAT=( python3_{12..14} )

CRATES="
	autocfg@1.4.0
	heck@0.5.0
	indoc@2.0.6
	libc@0.2.172
	memoffset@0.9.1
	once_cell@1.21.3
	portable-atomic@1.11.0
	proc-macro2@1.0.95
	pyo3-build-config@0.27.1
	pyo3-ffi@0.27.1
	pyo3-macros-backend@0.27.1
	pyo3-macros@0.27.1
	pyo3@0.27.1
	quote@1.0.40
	syn@2.0.101
	target-lexicon@0.13.2
	unicode-ident@1.0.18
	unindent@0.2.4
"

inherit cargo distutils-r1 #pypi #git-r3

DESCRIPTION="Optional Rust speedups for Textual (dev-python/textual)"
HOMEPAGE="
	https://github.com/willmcgugan/textual-speedups
	https://pypi.org/project/textual-speedups/
"
#EGIT_REPO_URI="https://github.com/willmcgugan/textual-speedups.git"
#mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz
#SRC_URI="
#	$(pypi_sdist_url "${PN^}" "${PV}")
#	${CARGO_CRATE_URIS}
#"
SRC_URI="https://github.com/willmcgugan/textual-speedups/archive/refs/tags/v${PV}.tar.gz -> ${P}.gh.tar.gz"
SRC_URI+=" ${CARGO_CRATE_URIS}"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+=" Apache-2.0-with-LLVM-exceptions MIT Unicode-3.0"

SLOT="0"
KEYWORDS="~amd64"

BDEPEND="
	>=dev-util/maturin-1.8
	<dev-util/maturin-2.0
"
	#dev-python/setuptools-rust[${PYTHON_USEDEP}]

# Rust does not respect CFLAGS/LDFLAGS
QA_FLAGS_IGNORED=".*/_rust.*"

src_unpack() {
	cargo_src_unpack
}