Skip to content

Commit

Permalink
drop python req from pip-build-install, move to pip-build-install, ad…
Browse files Browse the repository at this point in the history
…d tests

There are lots of changes here, centered around removing all occurences
of SETUPTOOLS_SCM_PRETEND_VERSION.  That seems to be not necessary now,
at least with the current pip-build-install workflow.

 * do not require 'python' setting in pip-build-install.  Default to
   using the target of the 'python3' link. If not present, user
   has to supply it.

   Also use contextdir rather than subpkgdir so it can be used from "main"
   packages also.

 * replace any packages that had SETUPTOOLS_SCM_PRETEND_VERSION with
   py/pip-build-install.

 * py3-cppy has a runtime dep on setuptools

 * Add tests to touched packages

 * Drop 'python3' runtime dep from touched packages.

 * Fix uninstallable py3-gcloud-aio-storage which conflicted with
   its dependency py3-gcloud-aio-auth as they both provided
   usr/lib/python3.12/site-packages/gcloud/py.typed

 * Fix the provides in py3-maturin-bin packages to provide py3-maturin-bin
   rather than just py3-maturin.  That also fixes py3-pendulum which
   was failing to build because it actually needs 'maturin' executable
   but that was not being provided by the 'py3-maturin' dep.

 * Fix pendulum's dependency that had py3-pytzdata, it's deps list 'tzdata'

 * Drop the now-unused py3-pytzdata

Note the 'python3' shell snippet in py3-rich and others is painful.
See wolfi-dev#26818 for more context.
  • Loading branch information
smoser committed Aug 21, 2024
1 parent e03b1cf commit 34cf75c
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 159 deletions.
23 changes: 22 additions & 1 deletion pipelines/py/pip-build-install-bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ needs:
inputs:
python:
description: which python to use
required: true
default: "DEFAULT"
wheel:
description: build a wheel?
required: false
Expand All @@ -24,6 +24,27 @@ pipeline:
pipzip=/usr/share/pip-zipapp/pip-zipapp.pyz
[ -e "$pipzip" ] || { echo "missing pip-zip - $pipzip does not exist"; exit 1; }
[ -f "$pipzip" ] || { echo "missing pip-zip - $pipzip is not a file"; exit 1; }
if [ "$py" = "DEFAULT" ]; then
if p=$(command -v python3); then
py=$p
if [ -L "$p" ]; then
py=$(readlink -f "$p") ||
{ echo "ERROR: failed 'readlink -f $p'" 1>&2; exit 1; }
fi
else
glob="/usr/bin/python3.[0-9][0-9] /usr/bin/python3.[789]"
n=0
for p in $glob; do
[ -x "$p" ] && n=$((n+1)) && py=$p && found="$found $p"
done
if [ "$n" -ne 1 ]; then
echo "ERROR: must set inputs.python: " \
"found $n executables matching $glob" 1>&2
[ "$n" -eq 0 ] || echo " found: $found" 1>&2
exit 1
fi
fi
fi
pyver=$("$py" -c 'import sys; print("%s.%s" % (sys.version_info.major, sys.version_info.minor))')
sitepkgd=$("$py" -c 'import site; print(site.getsitepackages()[0])')
sitepkgd=${sitepkgd#/}
Expand Down
27 changes: 24 additions & 3 deletions pipelines/py/pip-build-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,37 @@ name: Build and install python package with pip
inputs:
python:
description: which python to use
required: true
default: DEFAULT
dest:
description: the destination
default: ${{targets.subpkgdir}}
default: ${{targets.contextdir}}

pipeline:
- name: "pip build ${{inputs.python}}"
- name: "pip build"
runs: |
export SOURCE_DATE_EPOCH=315532800
py=${{inputs.python}}
if [ "$py" = "DEFAULT" ]; then
if p=$(command -v python3); then
py=$p
if [ -L "$p" ]; then
py=$(readlink -f "$p") ||
{ echo "ERROR: failed 'readlink -f $p'" 1>&2; exit 1; }
fi
else
glob="/usr/bin/python3.[0-9][0-9] /usr/bin/python3.[789]"
n=0
for p in $glob; do
[ -x "$p" ] && n=$((n+1)) && py=$p && found="$found $p"
done
if [ "$n" -ne 1 ]; then
echo "ERROR: must set inputs.python: " \
"found $n executables matching $glob" 1>&2
[ "$n" -eq 0 ] || echo " found: $found" 1>&2
exit 1
fi
fi
fi
pyver=$("$py" -c 'import sys; print("%s.%s" % (sys.version_info.major, sys.version_info.minor))')
sitepkgd=$("$py" -c 'import site; print(site.getsitepackages()[0])')
sitepkgd=${sitepkgd#/}
Expand Down
14 changes: 3 additions & 11 deletions py3-antlr4-python3-runtime.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package:
name: py3-antlr4-python3-runtime
version: 4.13.2
epoch: 0
epoch: 1
description: ANTLR runtime for Python 3
copyright:
- license: BSD-3-Clause
Expand All @@ -26,16 +26,8 @@ pipeline:
repository: https://github.com/antlr/antlr4
tag: ${{package.version}}

- runs: |
cd runtime/Python3
export SETUPTOOLS_SCM_PRETEND_VERSION=${{package.version}}
python3=$(readlink -f `which python3`)
$python3 -m pip install -U poetry
$python3 -m gpep517 build-wheel \
--wheel-dir dist \
--output-fd 3 3>&1 >&2
$python3 -m installer -d "${{targets.destdir}}" \
dist/*.whl
- uses: py/pip-build-install
working-directory: runtime/Python3

- uses: strip

Expand Down
25 changes: 10 additions & 15 deletions py3-cppy.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package:
name: py3-cppy
version: 1.2.1
epoch: 1
epoch: 2
copyright:
- license: BSD-3-Clause
dependencies:
runtime:
- python3
- py3-setuptools

environment:
contents:
Expand All @@ -30,22 +30,17 @@ pipeline:
expected-commit: 13a67972ca9063951440c911270f204aa7fe631a
tag: ${{package.version}}

- runs: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Python Build
runs: |
export SETUPTOOLS_SCM_PRETEND_VERSION=${{package.version}}
python3 -m gpep517 build-wheel \
--wheel-dir .dist \
--output-fd 3 3>&1 >&2
- name: Python Install
runs: python3 -m installer -d "${{targets.destdir}}" .dist/cppy*.whl
- uses: py/pip-build-install

- uses: strip

test:
pipeline:
- uses: python/import
with:
imports: |
import cppy
update:
enabled: true
github:
Expand Down
27 changes: 17 additions & 10 deletions py3-gcloud-aio-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package:
name: py3-gcloud-aio-auth
version: 5.3.2
epoch: 0
epoch: 1
description: Python Client for Google Cloud Auth
copyright:
- license: MIT
Expand All @@ -13,7 +13,6 @@ package:
- py3-chardet
- py3-cryptography
- py3-pyjwt
- python3

environment:
contents:
Expand All @@ -23,6 +22,7 @@ environment:
- ca-certificates-bundle
- poetry
- py3-gpep517
- py3-pip
- py3-setuptools
- py3-wheel
- python3
Expand All @@ -35,19 +35,26 @@ pipeline:
repository: https://github.com/talkiq/gcloud-aio
tag: auth-${{package.version}}

- name: Python Build
- name: remove py.typed to avoid conflict with py3-gcloud-aio-*
runs: |
cd auth
export SETUPTOOLS_SCM_PRETEND_VERSION=${{package.version}}
python3 -m gpep517 build-wheel \
--wheel-dir dist \
--output-fd 3 3>&1 >&2
rm auth/gcloud/py.typed auth/gcloud/aio/py.typed
python3 -m installer -d "${{targets.destdir}}" \
dist/*.whl
- uses: py/pip-build-install
working-directory: auth

- uses: strip

test:
environment:
contents:
packages:
- openssl-provider-legacy # needed for 'from gcloud.aio import auth'
pipeline:
- uses: python/import
with:
imports: |
from gcloud.aio import auth
update:
enabled: true
github:
Expand Down
27 changes: 17 additions & 10 deletions py3-gcloud-aio-storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package:
name: py3-gcloud-aio-storage
version: 9.3.0
epoch: 0
epoch: 1
description: Python Client for Google Cloud Storage
copyright:
- license: MIT
Expand All @@ -12,7 +12,6 @@ package:
- py3-gcloud-aio-auth
- py3-asn1-modules
- py3-rsa
- python3

environment:
contents:
Expand All @@ -22,6 +21,7 @@ environment:
- ca-certificates-bundle
- poetry
- py3-gpep517
- py3-pip
- py3-setuptools
- py3-wheel
- python3
Expand All @@ -34,19 +34,26 @@ pipeline:
repository: https://github.com/talkiq/gcloud-aio
tag: storage-${{package.version}}

- name: Python Build
- name: remove py.typed to avoid conflict with py3-gcloud-aio-*
runs: |
cd storage
export SETUPTOOLS_SCM_PRETEND_VERSION=${{package.version}}
python3 -m gpep517 build-wheel \
--wheel-dir dist \
--output-fd 3 3>&1 >&2
rm storage/gcloud/py.typed storage/gcloud/aio/py.typed
python3 -m installer -d "${{targets.destdir}}" \
dist/*.whl
- uses: py/pip-build-install
working-directory: storage

- uses: strip

test:
environment:
contents:
packages:
- openssl-provider-legacy # needed for gcloud.aio.auth imports to work.
pipeline:
- uses: python/import
with:
imports: |
from gcloud.aio import storage
update:
enabled: true
github:
Expand Down
16 changes: 10 additions & 6 deletions py3-maturin.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package:
name: py3-maturin
version: 1.7.0
epoch: 2
epoch: 3
description: Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages
copyright:
- license: MIT OR Apache-2.0
Expand Down Expand Up @@ -55,6 +55,12 @@ subpackages:
with:
python: python${{range.key}}
- uses: strip
test:
pipeline:
- uses: python/import
with:
python: python${{range.key}}
import: ${{vars.pypi-package}}

- range: py-versions
name: py${{range.key}}-${{vars.pypi-package}}-bin
Expand All @@ -63,18 +69,16 @@ subpackages:
runtime:
- py${{range.key}}-${{vars.pypi-package}}
provides:
- py3-${{vars.pypi-package}}
- py3-${{vars.pypi-package}}-bin
provider-priority: ${{range.value}}
pipeline:
- runs: |
mkdir -p ${{targets.contextdir}}/usr
mv ${{targets.contextdir}}/../py${{range.key}}-${{vars.pypi-package}}/usr/bin ${{targets.contextdir}}/usr
test:
pipeline:
- uses: python/import
with:
python: python${{range.key}}
import: ${{vars.pypi-package}}
- runs: |
maturin --help
- name: py3-supported-${{vars.pypi-package}}
description: meta package providing ${{vars.pypi-package}} for supported python versions.
Expand Down
35 changes: 23 additions & 12 deletions py3-pendulum.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package:
name: py3-pendulum
version: 3.0.0
epoch: 0
epoch: 1
description: Python datetimes made easy
copyright:
- license: MIT
dependencies:
runtime:
- py3-dateutil
- py3-pytzdata
- py3-typing
- python3
- py3-tzdata

environment:
contents:
Expand All @@ -22,7 +21,7 @@ environment:
- poetry
- py3-gpep517
- py3-installer
- py3-maturin
- py3-maturin-bin
- py3-pip
- py3-setuptools
- py3-wheel
Expand All @@ -38,17 +37,29 @@ pipeline:
tag: ${{package.version}}
expected-commit: 0fcd10217af0469b3edda072f2b152d5273f3d58

- runs: |
export SETUPTOOLS_SCM_PRETEND_VERSION=${{package.version}}
python3 -m gpep517 build-wheel \
--wheel-dir dist \
--output-fd 3 3>&1 >&2
python3 -m installer -d "${{targets.destdir}}" \
dist/*.whl
- uses: py/pip-build-install

- uses: strip

test:
pipeline:
- uses: python/import
with:
imports: |
import pendulum
- runs: |
python=$(set +x; m=/usr/bin/python3.*; set -- $m
[ $# -eq 1 -a -x "$1" ] && echo "$1" && exit 0
echo "found $# matches to $m"; exit 1;)
# test verifies that timezone data is present.
$python -c '
from pendulum import datetime
tor = datetime(2012, 1, 1, tz="America/Toronto")
van = datetime(2012, 1, 1, tz="America/Vancouver")
assert 3 == van.diff(tor).in_hours()
print("PASS: time zones check out")
'
update:
enabled: true
github:
Expand Down
Loading

0 comments on commit 34cf75c

Please sign in to comment.