# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=twine
pkgver=6.0.1
pkgrel=0
pkgdesc="Collection of utilities for publishing packages on PyPI"
url="https://twine.readthedocs.io/en/latest/"
# loongarch64: blocked by py3-readme_renderer
arch="noarch !loongarch64"
license="Apache-2.0"
depends="
	py3-keyring
	py3-pkginfo
	py3-readme_renderer
	py3-requests-toolbelt
	py3-requests>=2.20.0
	py3-rfc3986
	py3-rich
	py3-urllib3
	python3
	"
makedepends="
	py3-gpep517
	py3-setuptools_scm
	py3-wheel
	"
checkdepends="
	py3-build
	py3-flaky
	py3-jaraco.envs
	py3-munch
	py3-portend
	py3-pretend
	py3-pytest
	py3-pytest-cov
	py3-pytest-socket
	"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/t/twine/twine-$pkgver.tar.gz"

# Backwards compatibility
provides="py3-$pkgname=$pkgver-r$pkgrel"
replaces="py3-$pkgname"

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION="$pkgver"
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	# deselect'ed tests require a network connection
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	gpep517 install-wheel --destdir .testenv --prefix '' .dist/*.whl
	.testenv/bin/python3 -m pytest \
		--deselect tests/test_integration.py \
		--deselect tests/test_upload.py::test_check_status_code_for_wrong_repo_url \
		-k "not test_metadata_dictionary_keys and not test_fips_metadata_excludes_md5_and_blake2 and not test_pkginfo_returns_no_metadata and not test_pkginfo_returns_no_metadata and not test_fails_rst_no_content"
}

package() {
	python3 -m installer -d "$pkgdir" .dist/twine-$pkgver-py3-none-any.whl
}

sha512sums="
8131917fa2e19b4bc0fc17f3204682662ce78a4e023fbfb596e77163237adb12a9680d7dda85d78bdcbf9280aa2e53141e2b1e6ce998cb0ae2bfce72f9ec76a0  twine-6.0.1.tar.gz
"
