Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | def pypi_package(d): |
| 8 | bpn = d.getVar('BPN') |
| 9 | if bpn.startswith('python-'): |
| 10 | return bpn[7:] |
| 11 | elif bpn.startswith('python3-'): |
| 12 | return bpn[8:] |
| 13 | return bpn |
| 14 | |
| 15 | PYPI_PACKAGE ?= "${@pypi_package(d)}" |
| 16 | PYPI_PACKAGE_EXT ?= "tar.gz" |
| 17 | PYPI_ARCHIVE_NAME ?= "${PYPI_PACKAGE}-${PV}.${PYPI_PACKAGE_EXT}" |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 18 | PYPI_ARCHIVE_NAME_PREFIX ?= "" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 19 | |
| 20 | def pypi_src_uri(d): |
| 21 | package = d.getVar('PYPI_PACKAGE') |
| 22 | archive_name = d.getVar('PYPI_ARCHIVE_NAME') |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 23 | archive_downloadname = d.getVar('PYPI_ARCHIVE_NAME_PREFIX') + archive_name |
| 24 | return 'https://files.pythonhosted.org/packages/source/%s/%s/%s;downloadfilename=%s' % (package[0], package, archive_name, archive_downloadname) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 25 | |
| 26 | PYPI_SRC_URI ?= "${@pypi_src_uri(d)}" |
| 27 | |
| 28 | HOMEPAGE ?= "https://pypi.python.org/pypi/${PYPI_PACKAGE}/" |
| 29 | SECTION = "devel/python" |
| 30 | SRC_URI:prepend = "${PYPI_SRC_URI} " |
| 31 | S = "${WORKDIR}/${PYPI_PACKAGE}-${PV}" |
| 32 | |
| 33 | UPSTREAM_CHECK_URI ?= "https://pypi.org/project/${PYPI_PACKAGE}/" |
| 34 | UPSTREAM_CHECK_REGEX ?= "/${PYPI_PACKAGE}/(?P<pver>(\d+[\.\-_]*)+)/" |
| 35 | |
| 36 | CVE_PRODUCT ?= "python:${PYPI_PACKAGE}" |