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

# Autogenerated by pycargoebuild 0.14.0

EAPI=8

PYTHON_COMPAT=( python3_{13..14} )

RUST_MIN_VER=1.91.0
CRATES=""

inherit cargo python-single-r1

DESCRIPTION="Tracking of upstream project metadata"
HOMEPAGE="https://github.com/jelmer/upstream-ontologist"
SRC_URI="https://github.com/jelmer/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/sysrq-crate-dist/${PN}/releases/download/v${PV}/${P}-crates.tar.xz
"

LICENSE="GPL-2+"
# Dependent crate licenses
LICENSE+="
	0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD CC0-1.0
	GPL-2+ GPL-3 ISC MIT MPL-2.0 MPL-2.0 Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"
IUSE="bzr +python test"
REQUIRED_USE="
	bzr? ( ${PYTHON_REQUIRED_USE} )
	python? ( ${PYTHON_REQUIRED_USE} )
"
RESTRICT="!test? ( test )"

DEPEND="
	bzr? ( ${PYTHON_DEPS} )
	python? ( ${PYTHON_DEPS} )
"
# NOTE: Some Python dependencies are found in obscure Rust crates
# running py.import_bound()
RDEPEND="${DEPEND}
	bzr? (
		>=dev-vcs/breezy-3.3.0[${PYTHON_SINGLE_USEDEP}]
	)
	python? (
		$(python_gen_cond_dep '
			dev-python/python-debian[${PYTHON_USEDEP}]
			dev-python/setuptools[${PYTHON_USEDEP}]
		')
	)
"
BDEPEND="test? ( ${RDEPEND} )"

DOCS=( docs/. AUTHORS {CODE_OF_CONDUCT,README,SECURITY}.md )

QA_FLAGS_IGNORED="usr/bin/.*"

pkg_setup() {
	rust_pkg_setup

	if use bzr || use python; then
		python-single-r1_pkg_setup
	fi
}

src_configure() {
	local myfeatures=(
		cargo
		cli
		debian
		dist-ini
		git-config
		launchpad
		opam
		pyproject-toml
		python-pkginfo
		r-description
		setup-cfg
		$(usev bzr breezy)
		$(usev python pyo3)
	)

	cargo_src_configure --no-default-features
}

src_install() {
	dobin "$(cargo_target_dir)"/autocodemeta
	dobin "$(cargo_target_dir)"/autodoap
	dobin "$(cargo_target_dir)"/guess-upstream-metadata

	doman man/*
}