Skip to content

Commit

Permalink
Drop pybins and allow to install them all
Browse files Browse the repository at this point in the history
Requires chainguard-dev/melange#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
```
  • Loading branch information
xnox committed Apr 26, 2024
1 parent 1df349d commit 27b22d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
7 changes: 0 additions & 7 deletions pipelines/py/install-compile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 0 additions & 11 deletions pipelines/py/pip-build-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 21 additions & 3 deletions py3-pip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand All @@ -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:
Expand Down Expand Up @@ -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

This comment has been minimized.

Copy link
@smoser

smoser Apr 27, 2024

this isn't implmented anywhere, right? the 'no-commands'? is it still needed

This comment has been minimized.

Copy link
@xnox

xnox Apr 28, 2024

Author Owner

I am confused by this question. This is an existing option supported by melange, to prevent generating "cmd:pip=${{package.full-version}}" because they conflict with each other upon install.

Ideally i'd want to generate that provides either only on the current default python (i.e. py3.12), or with versions that specify priority somehow.

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
Expand Down

0 comments on commit 27b22d6

Please sign in to comment.