summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/pypi.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes-recipe/pypi.bbclass')
-rw-r--r--meta/classes-recipe/pypi.bbclass57
1 files changed, 0 insertions, 57 deletions
diff --git a/meta/classes-recipe/pypi.bbclass b/meta/classes-recipe/pypi.bbclass
deleted file mode 100644
index 1372d85e8d..0000000000
--- a/meta/classes-recipe/pypi.bbclass
+++ /dev/null
@@ -1,57 +0,0 @@
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
15# The PyPi package name (defaults to PN without the python3- prefix)
16PYPI_PACKAGE ?= "${@pypi_package(d)}"
17# The file extension of the source archive
18PYPI_PACKAGE_EXT ?= "tar.gz"
19# An optional prefix for the download file in the case of name collisions
20PYPI_ARCHIVE_NAME_PREFIX ?= ""
21
22def pypi_src_uri(d):
23 """
24 Construct a source URL as per https://warehouse.pypa.io/api-reference/integration-guide.html#predictable-urls.
25 """
26 package = d.getVar('PYPI_PACKAGE')
27 archive_name = d.expand('${PYPI_PACKAGE}-${PV}.${PYPI_PACKAGE_EXT}')
28 archive_downloadname = d.getVar('PYPI_ARCHIVE_NAME_PREFIX') + archive_name
29 return 'https://files.pythonhosted.org/packages/source/%s/%s/%s;downloadfilename=%s' % (package[0], package, archive_name, archive_downloadname)
30
31def pypi_normalize(d):
32 """"
33 Normalize the package names to match PEP625 (https://peps.python.org/pep-0625/).
34 For non-compliant packages, maintainers can set UPSTREAM_CHECK_PYPI_PACKAGE to override the normalization
35 """
36 import re
37 return re.sub(r"[-_.]+", "-", d.getVar('PYPI_PACKAGE')).lower()
38
39PYPI_SRC_URI ?= "${@pypi_src_uri(d)}"
40
41HOMEPAGE ?= "https://pypi.python.org/pypi/${PYPI_PACKAGE}/"
42SECTION = "devel/python"
43SRC_URI:prepend = "${PYPI_SRC_URI} "
44S = "${UNPACKDIR}/${PYPI_PACKAGE}-${PV}"
45
46# Replace any '_' characters in the pypi URI with '-'s to follow the PyPi website naming conventions
47UPSTREAM_CHECK_PYPI_PACKAGE ?= "${@pypi_normalize(d)}"
48
49# Use the simple repository API rather than the potentially unstable project URL
50# More information on the pypi API specification is avaialble here:
51# https://packaging.python.org/en/latest/specifications/simple-repository-api/
52#
53# NOTE: All URLs for the simple API MUST request canonical normalized URLs per the spec
54UPSTREAM_CHECK_URI ?= "https://pypi.org/simple/${@pypi_normalize(d)}/"
55UPSTREAM_CHECK_REGEX ?= "${UPSTREAM_CHECK_PYPI_PACKAGE}-(?P<pver>(\d+[\.\-_]*)+).(tar\.gz|tgz|zip|tar\.bz2)"
56
57CVE_PRODUCT ?= "python:${PYPI_PACKAGE}"