Skip to content

Commit

Permalink
community/z3: ensure that the python bindings do not depend on importlib
Browse files Browse the repository at this point in the history
See Z3Prover/z3#7042

Fixes #15727
  • Loading branch information
nmeum committed Jan 29, 2024
1 parent 8500597 commit 774d857
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 9ad4d50b5d859443e3ba004bd36c560af3673a55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Tue, 5 Dec 2023 16:49:32 +0100
Subject: [PATCH] Use built-in `importlib.resources` on Python 3.9+ (#7042)

Use built-in `importlib.resources` module rather than the external
`importlib_resources` package on Python 3.9 and newer. The latter
is only intended as a backport for old Python versions, and since modern
Linux distributions may no longer support such old Python versions,
they also no longer provide importlib_resources (this is the case
on Gentoo).
---
scripts/update_api.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/update_api.py b/scripts/update_api.py
index d426da34a..7d3d8899f 100755
--- a/scripts/update_api.py
+++ b/scripts/update_api.py
@@ -1831,7 +1831,10 @@ import atexit
import sys, os
import contextlib
import ctypes
-import importlib_resources
+if sys.version_info >= (3, 9):
+ import importlib.resources as importlib_resources
+else:
+ import importlib_resources
from .z3types import *
from .z3consts import *

4 changes: 3 additions & 1 deletion community/z3/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=z3
pkgver=4.12.3
pkgrel=0
pkgrel=1
pkgdesc="Theorem prover from Microsoft Research"
url="https://github.com/Z3Prover/z3"
arch="all"
license="MIT"
makedepends="cmake python3 samurai"
subpackages="$pkgname-dev py3-$pkgname:py3:noarch"
source="https://github.com/Z3Prover/z3/archive/z3-$pkgver.tar.gz
0001-Use-built-in-importlib.resources-on-Python-3.9-7042.patch
"
builddir="$srcdir/z3-z3-$pkgver"

Expand Down Expand Up @@ -45,4 +46,5 @@ py3() {

sha512sums="
06d667b86e2d941e8cbcafe508392f5ef9307354a97428107e26ac7ef86246a86a0096fbf92034f2a3e47efe41f95ddc74460c2c4797aadec79e14020737afcb z3-4.12.3.tar.gz
70c64ea3da608753bb8ba02d5d1217775184c7d45a4f7f6cb25a1dd9c6c9badc3357b5e59ee73c9820b80170d527c7d7e91678e7759bdfcb8f90db5f8561720c 0001-Use-built-in-importlib.resources-on-Python-3.9-7042.patch
"

0 comments on commit 774d857

Please sign in to comment.