blob: b8c18ccf395af2d9aababb75bc6d3e515e1230db [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7def 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
15PYPI_PACKAGE ?= "${@pypi_package(d)}"
16PYPI_PACKAGE_EXT ?= "tar.gz"
17PYPI_ARCHIVE_NAME ?= "${PYPI_PACKAGE}-${PV}.${PYPI_PACKAGE_EXT}"
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050018PYPI_ARCHIVE_NAME_PREFIX ?= ""
Patrick Williams92b42cb2022-09-03 06:53:57 -050019
20def pypi_src_uri(d):
21 package = d.getVar('PYPI_PACKAGE')
22 archive_name = d.getVar('PYPI_ARCHIVE_NAME')
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050023 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 Williams92b42cb2022-09-03 06:53:57 -050025
26PYPI_SRC_URI ?= "${@pypi_src_uri(d)}"
27
28HOMEPAGE ?= "https://pypi.python.org/pypi/${PYPI_PACKAGE}/"
29SECTION = "devel/python"
30SRC_URI:prepend = "${PYPI_SRC_URI} "
31S = "${WORKDIR}/${PYPI_PACKAGE}-${PV}"
32
Andrew Geissler220dafd2023-10-04 10:18:08 -050033# Replace any '_' characters in the pypi URI with '-'s to follow the PyPi website naming conventions
34UPSTREAM_CHECK_PYPI_PACKAGE ?= "${@d.getVar('PYPI_PACKAGE').replace('_', '-')}"
35UPSTREAM_CHECK_URI ?= "https://pypi.org/project/${UPSTREAM_CHECK_PYPI_PACKAGE}/"
36UPSTREAM_CHECK_REGEX ?= "/${UPSTREAM_CHECK_PYPI_PACKAGE}/(?P<pver>(\d+[\.\-_]*)+)/"
Patrick Williams92b42cb2022-09-03 06:53:57 -050037
38CVE_PRODUCT ?= "python:${PYPI_PACKAGE}"