Sven-Hendrik Haase pushed to branch main at Arch Linux / Packaging / Packages / tensorflow
Commits: c8fc7c8f by loqs at 2024-05-24T02:57:13+00:00 Add patch for Python 3.12 distutils removal Fixes https://gitlab.archlinux.org/archlinux/packaging/packages/tensorflow/-/issues/7 - - - - - 2 changed files: - PKGBUILD - + tensorflow-2.16.1-python-distutils-removal.patch Changes: ===================================== PKGBUILD ===================================== @@ -19,8 +19,10 @@ makedepends=('bazel' 'python-numpy' 'cuda' 'nvidia-utils' 'nccl' 'git' 'cudnn' ' 'python-keras-preprocessing' 'cython' 'patchelf' 'python-requests' 'libxcrypt-compat' 'clang') optdepends=('tensorboard: Tensorflow visualization toolkit') source=("$pkgname-$pkgver.tar.gz::https://github.com/tensorflow/tensorflow/archive/v${_pkgver}.tar.gz" + tensorflow-2.16.1-python-distutils-removal.patch https://github.com/bazelbuild/bazel/releases/download/6.1.0/bazel_nojdk-6.1.0-linux-x86_64) sha512sums=('6f02261b3e72b476a3adb8e47efe2bee76b8564315b853e3b16f443193204d363b5fb22ac5c388cebd6a1f326f0daf00586e0ccbf6a305d761a9266534fde13f' + 'e4c44d2f5314b83d8ed404e5ec14960ef8b7df0c1a2a3e826f913a02c901f9fd0326f9014a602121e0fdb2f928d1459f8b8180455491a1f937ce84e12f6a7d3e' 'b71aed83ae1c3f610df77f7c148703fd3e7aa5901794a2b31c6044c71b3f030831d59f7f3641992105117a422655160fc9b509326b31586c6bca378cbff08762') # consolidate common dependencies to prevent mishaps @@ -55,6 +57,10 @@ check_dir() { } prepare() { + # Python 3.12 removed the distutils module + # https://gitlab.archlinux.org/archlinux/packaging/packages/tensorflow/-/issues/7 + patch -Np1 -i ../tensorflow-2.16.1-python-distutils-removal.patch -d tensorflow-${_pkgver} + # Since Tensorflow is currently imcompatible with our version of Bazel, we're going to use # their exact version of Bazel to fix that. Stupid problems call for stupid solutions. install -Dm755 "${srcdir}"/bazel_nojdk-6.1.0-linux-x86_64 bazel/bazel ===================================== tensorflow-2.16.1-python-distutils-removal.patch ===================================== @@ -0,0 +1,84 @@ +diff --git a/tensorflow/api_template.__init__.py b/tensorflow/api_template.__init__.py +index a0f88926..9c0bb098 100644 +--- a/tensorflow/api_template.__init__.py ++++ b/tensorflow/api_template.__init__.py +@@ -27,7 +27,6 @@ this file with a file generated from [`api_template.__init__.py`](https://www.gi + """ + # pylint: disable=g-bad-import-order,protected-access,g-import-not-at-top + +-import distutils as _distutils + import importlib + import inspect as _inspect + import os as _os +@@ -95,10 +94,10 @@ _site_packages_dirs = [] + if _site.ENABLE_USER_SITE and _site.USER_SITE is not None: + _site_packages_dirs += [_site.USER_SITE] + _site_packages_dirs += [p for p in _sys.path if "site-packages" in p] +-if "getsitepackages" in dir(_site): ++try: + _site_packages_dirs += _site.getsitepackages() +- +-if "sysconfig" in dir(_distutils): ++except AttributeError: ++ import distutils as _distutils + _site_packages_dirs += [_distutils.sysconfig.get_python_lib()] + + _site_packages_dirs = list(set(_site_packages_dirs)) +diff --git a/tensorflow/api_template_v1.__init__.py b/tensorflow/api_template_v1.__init__.py +index 6a4ab4e6..d6f8f2e0 100644 +--- a/tensorflow/api_template_v1.__init__.py ++++ b/tensorflow/api_template_v1.__init__.py +@@ -14,7 +14,6 @@ + # ============================================================================== + """Bring in all of the public TensorFlow interface into this module.""" + +-import distutils as _distutils + import importlib + import inspect as _inspect + import os as _os +@@ -144,10 +143,10 @@ from tensorflow.python.lib.io import file_io as _fi + _site_packages_dirs = [] + _site_packages_dirs += [] if _site.USER_SITE is None else [_site.USER_SITE] + _site_packages_dirs += [p for p in _sys.path if "site-packages" in p] +-if "getsitepackages" in dir(_site): ++try: + _site_packages_dirs += _site.getsitepackages() +- +-if "sysconfig" in dir(_distutils): ++except AttributeError: ++ import distutils as _distutils + _site_packages_dirs += [_distutils.sysconfig.get_python_lib()] + + _site_packages_dirs = list(set(_site_packages_dirs)) +diff --git a/tensorflow/lite/python/convert.py b/tensorflow/lite/python/convert.py +index cfaff27a..a4eeb02f 100644 +--- a/tensorflow/lite/python/convert.py ++++ b/tensorflow/lite/python/convert.py +@@ -14,7 +14,6 @@ + # ============================================================================== + """Converts a frozen graph into a TFLite FlatBuffer.""" + +-import distutils.spawn + import enum + import hashlib + import os as _os +@@ -45,6 +44,10 @@ from tensorflow.python.platform import resource_loader as _resource_loader + from tensorflow.python.util import deprecation + from tensorflow.python.util.tf_export import tf_export as _tf_export + ++try: ++ from shutil import which ++except ImportError: ++ from distutils.spawn import find_executable as which + + def _is_quantized_input_stats_required( + conversion_flags: _conversion_flags_pb2.TocoFlags, +@@ -399,7 +402,7 @@ def _run_deprecated_conversion_binary( + RuntimeError: When conversion fails, an exception is raised with the error + message embedded. + """ +- if distutils.spawn.find_executable(_deprecated_conversion_binary) is None: ++ if which(_deprecated_conversion_binary) is None: + raise ConverterError("""Could not find `toco_from_protos` binary, make sure + your virtualenv bin directory or pip local bin directory is in your path. + In particular, if you have installed TensorFlow with --user, make sure you View it on GitLab: https://gitlab.archlinux.org/archlinux/packaging/packages/tensorflow/-/commit/c8fc7c8f045d0843da273ede6925d474b4efa242 -- View it on GitLab: https://gitlab.archlinux.org/archlinux/packaging/packages/tensorflow/-/commit/c8fc7c8f045d0843da273ede6925d474b4efa242 You're receiving this email because of your account on gitlab.archlinux.org.