From 1da51d4a0e7f6bfb0c186b5f9b2d275553b2ae0a Mon Sep 17 00:00:00 2001 From: totaam Date: Fri, 25 Aug 2023 15:32:59 +0700 Subject: [PATCH] #3974 Python 3.12 compatibility --- packaging/rpm/patches/pycuda-py3.12.patch | 20 ++++++++++++++++++++ packaging/rpm/python3-pycuda.spec | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 packaging/rpm/patches/pycuda-py3.12.patch diff --git a/packaging/rpm/patches/pycuda-py3.12.patch b/packaging/rpm/patches/pycuda-py3.12.patch new file mode 100644 index 0000000000..fa0a40ef24 --- /dev/null +++ b/packaging/rpm/patches/pycuda-py3.12.patch @@ -0,0 +1,20 @@ +--- a/aksetup_helper.py 2023-08-25 15:28:31.955661823 +0700 ++++ b/aksetup_helper.py 2023-08-25 15:29:03.838431471 +0700 +@@ -35,10 +35,14 @@ + + + def get_numpy_incpath(): +- from imp import find_module ++ from os.path import join, basename + # avoid actually importing numpy, it screws up distutils +- file, pathname, descr = find_module("numpy") +- from os.path import join ++ try: ++ from imp import find_module ++ file, pathname, descr = find_module("numpy") ++ except ImportError: ++ from importlib import util ++ pathname = basename(util.find_spec("numpy").origin) + return join(pathname, "core", "include") + + diff --git a/packaging/rpm/python3-pycuda.spec b/packaging/rpm/python3-pycuda.spec index b7818c19ba..08be02bbbe 100644 --- a/packaging/rpm/python3-pycuda.spec +++ b/packaging/rpm/python3-pycuda.spec @@ -40,6 +40,7 @@ Source0: https://files.pythonhosted.org/packages/78/09/9df5358ffb74d22524 %else Source0: https://files.pythonhosted.org/packages/2d/1f/48a3a5b2c715345e7af1e09361100bd98c3d72b4025371692ab233f523d3/pycuda-%{version}.tar.gz %endif +Patch1: pycuda-py3.12.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build Provides: %{python3}-pycuda @@ -74,6 +75,7 @@ if [ "${sha256}" != "acd9030d93e76e60b122e33ad16bcf01bb1344f4c304dedff1cd2bffb0f exit 1 fi %setup -q -n pycuda-%{version} +%patch -p1 -P 1 %build CUDA=/opt/cuda