From 27b22d6f1c610d70f621c5b5ae2789f5d6cd9c21 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Fri, 26 Apr 2024 23:35:39 +0100 Subject: [PATCH] Drop pybins and allow to install them all Requires https://github.com/chainguard-dev/melange/pull/1166 Drop pybins, instead build all packages with commands in /usr/bin. Set replaces, replaces-priority to ensure they are apk installable. Also set provider-priority such that `apk add py3-pip` transparently installs py3.12-pip alone. This is all great, however not at all supported by apko. But imho should be supported. As one simply has to sort packages in replaces priority order prior to streaming. And allow overriding files between packages that have replaces declared. ```console ... (13/25) Installing python-3.10-base (3.10.14-r1) (14/25) Installing py3.10-flit-core (3.9.0-r2) (15/25) Installing py3.10-setuptools (69.5.1-r1) (16/25) Installing py3.10-pip (24.0-r2) (17/25) Installing python-3.11-base (3.11.9-r1) (18/25) Installing py3.11-flit-core (3.9.0-r2) (19/25) Installing py3.11-setuptools (69.5.1-r1) (20/25) Installing py3.11-pip (24.0-r2) (21/25) Installing python-3.12-base (3.12.3-r1) (22/25) Installing py3.12-flit-core (3.9.0-r2) (23/25) Installing py3.12-setuptools (69.5.1-r1) (24/25) Installing py3.12-pip (24.0-r2) (25/25) Installing py3-supported-pip (24.0-r2) OK: 197 MiB in 40 packages -rwxrwxr-x 1 root root 946 Apr 26 22:22 /usr/bin/pip3.12 -rwxrwxr-x 1 root root 946 Apr 26 22:22 /usr/bin/pip3.11 -rwxrwxr-x 1 root root 946 Apr 26 22:22 /usr/bin/pip3.10 -rwxrwxr-x 1 root root 940 Apr 26 22:22 /usr/bin/pip3 -rwxrwxr-x 1 root root 938 Apr 26 22:22 /usr/bin/pip ``` --- pipelines/py/install-compile.yaml | 7 ------- pipelines/py/pip-build-install.yaml | 11 ----------- py3-pip.yaml | 24 +++++++++++++++++++++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pipelines/py/install-compile.yaml b/pipelines/py/install-compile.yaml index ef6113f9df..fd1dd68161 100644 --- a/pipelines/py/install-compile.yaml +++ b/pipelines/py/install-compile.yaml @@ -16,10 +16,3 @@ pipeline: - name: "compileall ${{inputs.python}}" runs: | ${{inputs.python}} -m compileall --invalidation-mode=unchecked-hash -r100 ${{targets.subpkgdir}}/usr/lib/ - pyver=$(${{inputs.python}} -c 'import sys; print("%s.%s" % (sys.version_info.major, sys.version_info.minor))') - for bin in ${{targets.subpkgdir}}/usr/bin/*; do - [ -f "$bin" ] && [ -x "$bin" ] || continue - d="${{targets.subpkgdir}}/usr/pybin/$pyver" - [ -d "$d" ] || mkdir -p "$d" - mv "$bin" "$d/" - done diff --git a/pipelines/py/pip-build-install.yaml b/pipelines/py/pip-build-install.yaml index a675fb042f..13d38b63b5 100644 --- a/pipelines/py/pip-build-install.yaml +++ b/pipelines/py/pip-build-install.yaml @@ -33,14 +33,3 @@ pipeline: "--find-links=$distwheelsd" --no-index --no-build-isolation --no-deps \ --force-reinstall --no-compile --prefix=/usr "--root=$root" "$wd"/*.whl vr $py -m compileall --invalidation-mode=unchecked-hash -r100 "$root/$sitepkgd" - - - name: "compileall ${{inputs.python}}" - runs: | - pyver=$(${{inputs.python}} -c 'import sys; print("%s.%s" % (sys.version_info.major, sys.version_info.minor))') - for bin in ${{inputs.dest}}/usr/bin/*; do - [ -f "$bin" ] && [ -x "$bin" ] || continue - d="${{inputs.dest}}/usr/pybin/$pyver" - [ -d "$d" ] || mkdir -p "$d" - mv "$bin" "$d/" - echo "moved $bin -> $d/" - done diff --git a/py3-pip.yaml b/py3-pip.yaml index 2e4ee847ce..d5d84a14b4 100644 --- a/py3-pip.yaml +++ b/py3-pip.yaml @@ -5,7 +5,11 @@ package: description: The PyPA recommended tool for installing Python packages. copyright: - license: MIT + checks: + disabled: + - empty dependencies: + provider-priority: 0 runtime: - py3.12-${{vars.pypi-package}} @@ -15,9 +19,9 @@ vars: data: - name: py-versions items: - 3.10: "" - 3.11: "" - 3.12: "" + 3.10: "310" + 3.11: "311" + 3.12: "312" environment: contents: @@ -45,7 +49,21 @@ subpackages: with: python: python${{range.key}} - uses: strip + # ideally want If syntax here + # if: ${{range.key}} != 3.12 + # options: + # no-commands: true + options: + no-commands: true dependencies: + provides: + - py3-pip + replaces: + - py3.10-${{vars.pypi-package}} + - py3.11-${{vars.pypi-package}} + - py3.12-${{vars.pypi-package}} + provider-priority: ${{range.value}} + replaces-priority: ${{range.value}} runtime: - py${{range.key}}-flit-core - py${{range.key}}-setuptools