diff options
author | Michał Górny <mgorny@gentoo.org> | 2023-02-10 14:51:26 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-02-12 20:00:46 +0100 |
commit | 1b21375a8ce05dad4d9e977f2098f0e70cfec4fa (patch) | |
tree | 9bd9e792351218dee2f0618b6afd5488bc000cc7 | |
parent | pypi.eclass: Add a version translation function (diff) | |
download | gentoo-1b21375a8ce05dad4d9e977f2098f0e70cfec4fa.tar.gz gentoo-1b21375a8ce05dad4d9e977f2098f0e70cfec4fa.tar.bz2 gentoo-1b21375a8ce05dad4d9e977f2098f0e70cfec4fa.zip |
pypi.eclass: Translate ${PV} by default
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | eclass/pypi.eclass | 21 | ||||
-rwxr-xr-x | eclass/tests/pypi.sh | 24 |
2 files changed, 27 insertions, 18 deletions
diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass index 27bd17403100..be0e498fcbf3 100644 --- a/eclass/pypi.eclass +++ b/eclass/pypi.eclass @@ -87,7 +87,10 @@ pypi_translate_version() { # is normalized according to the specification unless `--no-normalize` # is passed. # -# If <version> is unspecified, it defaults to ${PV}. +# If <version> is unspecified, it defaults to ${PV} translated +# via pypi_translate_version. If it is specified, then it is used +# verbatim (the function can be called explicitly to translate custom +# version number). # # If <format> is unspecified, it defaults to ".tar.gz". Another valid # value is ".zip" (please remember to add a BDEPEND on app-arch/unzip). @@ -103,7 +106,7 @@ pypi_sdist_url() { fi local project=${1-"${PN}"} - local version=${2-"${PV}"} + local version=${2-"$(pypi_translate_version "${PV}")"} local suffix=${3-.tar.gz} local fn_project=${project} [[ ${normalize} ]] && fn_project=$(pypi_normalize_name "${project}") @@ -119,7 +122,10 @@ pypi_sdist_url() { # If <package> is unspecified, it defaults to ${PN}. The package name # is normalized according to the wheel specification. # -# If <version> is unspecified, it defaults to ${PV}. +# If <version> is unspecified, it defaults to ${PV} translated +# via pypi_translate_version. If it is specified, then it is used +# verbatim (the function can be called explicitly to translate custom +# version number). # # If <python-tag> is unspecified, it defaults to "py3". It can also be # "py2.py3", or a specific version in case of non-pure wheels. @@ -133,7 +139,7 @@ pypi_wheel_name() { fi local project=$(pypi_normalize_name "${1-"${PN}"}") - local version=${2-"${PV}"} + local version=${2-"$(pypi_translate_version "${PV}")"} local pytag=${3-py3} local abitag=${4-none-any} echo "${project}-${version}-${pytag}-${abitag}.whl" @@ -152,7 +158,10 @@ pypi_wheel_name() { # # If <package> is unspecified, it defaults to ${PN}. # -# If <version> is unspecified, it defaults to ${PV}. +# If <version> is unspecified, it defaults to ${PV} translated +# via pypi_translate_version. If it is specified, then it is used +# verbatim (the function can be called explicitly to translate custom +# version number). # # If <python-tag> is unspecified, it defaults to "py3". It can also be # "py2.py3", or a specific version in case of non-pure wheels. @@ -173,7 +182,7 @@ pypi_wheel_url() { local filename=$(pypi_wheel_name "${@}") local project=${1-"${PN}"} - local version=${2-"${PV}"} + local version=${2-"$(pypi_translate_version "${PV}")"} local pytag=${3-py3} printf "https://files.pythonhosted.org/packages/%s" \ "${pytag}/${project::1}/${project}/${filename}" diff --git a/eclass/tests/pypi.sh b/eclass/tests/pypi.sh index af5d714af748..e114549633a0 100755 --- a/eclass/tests/pypi.sh +++ b/eclass/tests/pypi.sh @@ -6,7 +6,7 @@ EAPI=8 source tests-common.sh || exit PN=Foo.Bar -PV=1.2.3 +PV=1.2.3_beta2 inherit pypi @@ -39,8 +39,8 @@ test-eq "pypi_translate_version 1.2.3_beta1" 1.2.3b1 test-eq "pypi_translate_version 1.2.3_rc2" 1.2.3rc2 test-eq "pypi_translate_version 1.2.3_rc2_p1" 1.2.3rc2.post1 -test-eq "pypi_wheel_name" foo_bar-1.2.3-py3-none-any.whl -test-eq "pypi_wheel_name Flask-BabelEx" flask_babelex-1.2.3-py3-none-any.whl +test-eq "pypi_wheel_name" foo_bar-1.2.3b2-py3-none-any.whl +test-eq "pypi_wheel_name Flask-BabelEx" flask_babelex-1.2.3b2-py3-none-any.whl test-eq "pypi_wheel_name Flask-BabelEx 4" flask_babelex-4-py3-none-any.whl test-eq "pypi_wheel_name Flask-BabelEx 4 py2.py3" \ flask_babelex-4-py2.py3-none-any.whl @@ -48,9 +48,9 @@ test-eq "pypi_wheel_name cryptography 39.0.1 cp36 abi3-manylinux_2_28_x86_64" \ cryptography-39.0.1-cp36-abi3-manylinux_2_28_x86_64.whl test-eq "pypi_wheel_url" \ - https://files.pythonhosted.org/packages/py3/F/Foo.Bar/foo_bar-1.2.3-py3-none-any.whl + https://files.pythonhosted.org/packages/py3/F/Foo.Bar/foo_bar-1.2.3b2-py3-none-any.whl test-eq "pypi_wheel_url Flask-BabelEx" \ - https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-1.2.3-py3-none-any.whl + https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-1.2.3b2-py3-none-any.whl test-eq "pypi_wheel_url Flask-BabelEx 4" \ https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-4-py3-none-any.whl test-eq "pypi_wheel_url Flask-BabelEx 4 py2.py3" \ @@ -59,9 +59,9 @@ test-eq "pypi_wheel_url cryptography 39.0.1 cp36 abi3-manylinux_2_28_x86_64" \ https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-39.0.1-cp36-abi3-manylinux_2_28_x86_64.whl test-eq "pypi_wheel_url --unpack" \ - "https://files.pythonhosted.org/packages/py3/F/Foo.Bar/foo_bar-1.2.3-py3-none-any.whl -> foo_bar-1.2.3-py3-none-any.whl.zip" + "https://files.pythonhosted.org/packages/py3/F/Foo.Bar/foo_bar-1.2.3b2-py3-none-any.whl -> foo_bar-1.2.3b2-py3-none-any.whl.zip" test-eq "pypi_wheel_url --unpack Flask-BabelEx" \ - "https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-1.2.3-py3-none-any.whl -> flask_babelex-1.2.3-py3-none-any.whl.zip" + "https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-1.2.3b2-py3-none-any.whl -> flask_babelex-1.2.3b2-py3-none-any.whl.zip" test-eq "pypi_wheel_url --unpack Flask-BabelEx 4" \ "https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-4-py3-none-any.whl -> flask_babelex-4-py3-none-any.whl.zip" test-eq "pypi_wheel_url --unpack Flask-BabelEx 4 py2.py3" \ @@ -70,24 +70,24 @@ test-eq "pypi_wheel_url --unpack cryptography 39.0.1 cp36 abi3-manylinux_2_28_x8 "https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-39.0.1-cp36-abi3-manylinux_2_28_x86_64.whl -> cryptography-39.0.1-cp36-abi3-manylinux_2_28_x86_64.whl.zip" test-eq "pypi_sdist_url" \ - https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3.tar.gz + https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3b2.tar.gz test-eq "pypi_sdist_url Flask-BabelEx" \ - https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/flask_babelex-1.2.3.tar.gz + https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/flask_babelex-1.2.3b2.tar.gz test-eq "pypi_sdist_url Flask-BabelEx 4" \ https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/flask_babelex-4.tar.gz test-eq "pypi_sdist_url Flask-BabelEx 4 .zip" \ https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/flask_babelex-4.zip test-eq "pypi_sdist_url --no-normalize" \ - https://files.pythonhosted.org/packages/source/F/Foo.Bar/Foo.Bar-1.2.3.tar.gz + https://files.pythonhosted.org/packages/source/F/Foo.Bar/Foo.Bar-1.2.3b2.tar.gz test-eq "pypi_sdist_url --no-normalize Flask-BabelEx" \ - https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/Flask-BabelEx-1.2.3.tar.gz + https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/Flask-BabelEx-1.2.3b2.tar.gz test-eq "pypi_sdist_url --no-normalize Flask-BabelEx 4" \ https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/Flask-BabelEx-4.tar.gz test-eq "pypi_sdist_url --no-normalize Flask-BabelEx 4 .zip" \ https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/Flask-BabelEx-4.zip test-eq 'declare -p SRC_URI' \ - 'declare -- SRC_URI="https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3.tar.gz"' + 'declare -- SRC_URI="https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3b2.tar.gz"' texit |