summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross@burtonini.com>2022-03-14 14:39:22 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-16 08:48:09 +0000
commitc4cfeb96a337cd7790d18cdbb101a130845efc02 (patch)
treeab6e395690c71c9ab9cc608f5b5030f5148c7e97
parent7769b1f3fa218f648e9d753a5cbd7cebb422069e (diff)
downloadpoky-c4cfeb96a337cd7790d18cdbb101a130845efc02.tar.gz
python3-installer: add installer module
Add a recipe for Installer, a minimal library/tool to install Python Wheels. Unlike PIP, it explicitly only installs wheels and does nothing else. (From OE-Core rev: bf09c0bd99e4defbc259775b4a2e3fcce09bde17) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/conf/distro/include/maintainers.inc1
-rw-r--r--meta/recipes-devtools/python/python3-installer/interpreter.patch61
-rw-r--r--meta/recipes-devtools/python/python3-installer_0.5.1.bb22
3 files changed, 84 insertions, 0 deletions
diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
index 0de1642b5c..1a61fefd95 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -612,6 +612,7 @@ RECIPE_MAINTAINER:pn-python3-importlib-metadata = "Tim Orling <tim.orling@konsul
612RECIPE_MAINTAINER:pn-python3-iniconfig = "Tim Orling <tim.orling@konsulko.com>" 612RECIPE_MAINTAINER:pn-python3-iniconfig = "Tim Orling <tim.orling@konsulko.com>"
613RECIPE_MAINTAINER:pn-python3-iniparse = "Oleksandr Kravchuk <open.source@oleksandr-kravchuk.com>" 613RECIPE_MAINTAINER:pn-python3-iniparse = "Oleksandr Kravchuk <open.source@oleksandr-kravchuk.com>"
614RECIPE_MAINTAINER:pn-python3-iso8601 = "Tim Orling <tim.orling@konsulko.com>" 614RECIPE_MAINTAINER:pn-python3-iso8601 = "Tim Orling <tim.orling@konsulko.com>"
615RECIPE_MAINTAINER:pn-python3-installer = "Ross Burton <ross.burton@arm.com>"
615RECIPE_MAINTAINER:pn-python3-jinja2 = "Richard Purdie <richard.purdie@linuxfoundation.org>" 616RECIPE_MAINTAINER:pn-python3-jinja2 = "Richard Purdie <richard.purdie@linuxfoundation.org>"
616RECIPE_MAINTAINER:pn-python3-jsonpointer = "Bruce Ashfield <bruce.ashfield@gmail.com>" 617RECIPE_MAINTAINER:pn-python3-jsonpointer = "Bruce Ashfield <bruce.ashfield@gmail.com>"
617RECIPE_MAINTAINER:pn-python3-jsonschema = "Bruce Ashfield <bruce.ashfield@gmail.com>" 618RECIPE_MAINTAINER:pn-python3-jsonschema = "Bruce Ashfield <bruce.ashfield@gmail.com>"
diff --git a/meta/recipes-devtools/python/python3-installer/interpreter.patch b/meta/recipes-devtools/python/python3-installer/interpreter.patch
new file mode 100644
index 0000000000..ef10ef1b45
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-installer/interpreter.patch
@@ -0,0 +1,61 @@
1Let us override the hashbang directly (possibly upstreamable), and don't
2play games with hashbangs: for now assume that even hashbangs with spaces
3are simple (assume the spaces are only used to separate arguments) and
4we don't have long hashbangs.
5
6Upstream-Status: Inappropriate
7Signed-off-by: Ross Burton <ross.burton@arm.com>
8
9diff --git a/src/installer/__main__.py b/src/installer/__main__.py
10index 3357ec5..d2fd8d2 100644
11--- a/src/installer/__main__.py
12+++ b/src/installer/__main__.py
13@@ -23,6 +23,13 @@ def _get_main_parser() -> argparse.ArgumentParser:
14 type=str,
15 help="destination directory (prefix to prepend to each file)",
16 )
17+ parser.add_argument(
18+ "--interpreter",
19+ "-i",
20+ type=str,
21+ default=sys.executable,
22+ help=f"interpreter (defaults to {sys.executable})",
23+ )
24 parser.add_argument(
25 "--compile-bytecode",
26 action="append",
27@@ -73,7 +80,7 @@ def _main(cli_args: Sequence[str], program: Optional[str] = None) -> None:
28 with WheelFile.open(args.wheel) as source:
29 destination = SchemeDictionaryDestination(
30 scheme_dict=_get_scheme_dict(source.distribution),
31- interpreter=sys.executable,
32+ interpreter=args.interpreter,
33 script_kind=get_launcher_kind(),
34 bytecode_optimization_levels=bytecode_levels,
35 destdir=args.destdir,
36diff --git a/src/installer/scripts.py b/src/installer/scripts.py
37index 7e3c8fc..ba6ed5a 100644
38--- a/src/installer/scripts.py
39+++ b/src/installer/scripts.py
40@@ -59,20 +59,7 @@ def _build_shebang(executable: str, forlauncher: bool) -> bytes:
41 https://bitbucket.org/pypa/distlib/src/58cd5c6/distlib/scripts.py#lines-124
42 """
43 executable_bytes = executable.encode("utf-8")
44- if forlauncher: # The launcher can just use the command as-is.
45- return b"#!" + executable_bytes
46- if _is_executable_simple(executable_bytes):
47- return b"#!" + executable_bytes
48-
49- # Shebang support for an executable with a space in it is under-specified
50- # and platform-dependent, so we use a clever hack to generate a script to
51- # run in ``/bin/sh`` that should work on all reasonably modern platforms.
52- # Read the following message to understand how the hack works:
53- # https://github.com/pradyunsg/installer/pull/4#issuecomment-623668717
54-
55- quoted = shlex.quote(executable).encode("utf-8")
56- # I don't understand a lick what this is trying to do.
57- return b"#!/bin/sh\n'''exec' " + quoted + b' "$0" "$@"\n' + b"' '''"
58+ return b"#!" + executable_bytes
59
60
61 class InvalidScript(ValueError):
diff --git a/meta/recipes-devtools/python/python3-installer_0.5.1.bb b/meta/recipes-devtools/python/python3-installer_0.5.1.bb
new file mode 100644
index 0000000000..12d9fce249
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-installer_0.5.1.bb
@@ -0,0 +1,22 @@
1SUMMARY = "Library and tool for installing Python wheels"
2DESCRIPTION = "A low-level library for installing a Python package from a wheel distribution."
3HOMEPAGE = "https://installer.readthedocs.io/"
4BUGTRACKER = "https://github.com/pypa/installer/issues"
5
6LICENSE = "MIT"
7LIC_FILES_CHKSUM = "file://LICENSE;md5=5038641aec7a77451e31da828ebfae00"
8
9SRC_URI += "file://interpreter.patch"
10
11SRC_URI[sha256sum] = "f970995ec2bb815e2fdaf7977b26b2091e1e386f0f42eafd5ac811953dc5d445"
12
13inherit pypi flit_core
14
15DEPENDS:remove:class-native = "python3-installer-native"
16DEPENDS:append:class-native = " unzip-native"
17
18do_install:class-native () {
19 python_pep517_do_bootstrap_install
20}
21
22BBCLASSEXTEND = "native nativesdk"