1# 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}" 18PYPI_ARCHIVE_NAME_PREFIX ?= "" 19 20def pypi_src_uri(d): 21 package = d.getVar('PYPI_PACKAGE') 22 archive_name = d.getVar('PYPI_ARCHIVE_NAME') 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) 25 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 33# 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+[\.\-_]*)+)/" 37 38CVE_PRODUCT ?= "python:${PYPI_PACKAGE}" 39