sgpp: fix build issues (#39086)

* fix(sgpp): Fix installation phase scons args

* fix(sgpp): Workaround for distutils deprecation

The distutils deprecation warning in Python 3.10 - 3.11 caused
problems within the SGpp SConfigure checks by causing failures
when looking for Python.h. This commit works around this by adding a
patch that simply disables the warning. It also puts limits on the
python dependency version until distutils is removed from SGpp.

* fix(sgpp): cleanup and simplify

* fix(sgpp): Fix style
This commit is contained in:
Gregor Daiß 2023-08-11 07:55:44 +02:00 committed by GitHub
parent 633723236e
commit 24256be6d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 19 deletions

View file

@ -0,0 +1,23 @@
diff --git a/site_scons/SGppConfigure.py b/site_scons/SGppConfigure.py
index e5f54931f..2b0adc82a 100644
--- a/site_scons/SGppConfigure.py
+++ b/site_scons/SGppConfigure.py
@@ -3,7 +3,8 @@
# use, please see the copyright notice provided with SG++ or at
# sgpp.sparsegrids.org
-
+import warnings
+warnings.filterwarnings("ignore", category=DeprecationWarning)
import distutils.sysconfig
import errno
import os
@@ -311,6 +312,8 @@ def checkPython(config):
raise Exception("Python 3 is required for SGpp python support!")
pythonpath = getOutput(["python3", "-c",
+ "import warnings; "
+ "warnings.filterwarnings(\"ignore\", category=DeprecationWarning); "
"import distutils.sysconfig; "
"print(distutils.sysconfig.get_python_inc())"])
package = "python3-dev"

View file

@ -22,6 +22,10 @@ class Sgpp(SConsPackage):
version("3.4.0", sha256="450d4002850b0a48c561abe221b634261ca44eee111ca605c3e80797182f40b3") version("3.4.0", sha256="450d4002850b0a48c561abe221b634261ca44eee111ca605c3e80797182f40b3")
version("3.3.0", sha256="ca4d5b79f315b425ce69b04940c141451a76848bf1bd7b96067217304c68e2d4") version("3.3.0", sha256="ca4d5b79f315b425ce69b04940c141451a76848bf1bd7b96067217304c68e2d4")
version("3.2.0", sha256="dab83587fd447f92ed8546eacaac6b8cbe65b8db5e860218c0fa2e42f776962d") version("3.2.0", sha256="dab83587fd447f92ed8546eacaac6b8cbe65b8db5e860218c0fa2e42f776962d")
# Note: Older versions of SGpp required Python 2 (and offered Python 2 bindings) and have
# thus been removed from this list as Spack now requires Python 3.
# The last spack release with support for Python 2 is v0.19 - there, the spack package
# still supports SGpp versions 3.1.0 and 3.0.0 if required.
# Patches with bugfixes that are necessary to build old SGpp versions # Patches with bugfixes that are necessary to build old SGpp versions
# with spack. Patches are submitted upstream, but need to applied # with spack. Patches are submitted upstream, but need to applied
@ -42,8 +46,13 @@ class Sgpp(SConsPackage):
# Fixes compilation with AVX512 and datadriven # Fixes compilation with AVX512 and datadriven
# Fixed in SGpp in PR https://github.com/SGpp/SGpp/pull/229 # Fixed in SGpp in PR https://github.com/SGpp/SGpp/pull/229
patch("avx512_datadriven_compilation.patch", when="@:3.3.0+datadriven") patch("avx512_datadriven_compilation.patch", when="@:3.3.0+datadriven")
# Continue despite distutils deprecation warning!
# distutils will be removed in future SGpp versions. See
# https://github.com/SGpp/SGpp/issues/263 for associated issue!
# TODO Once distutils is removed from SGpp, limit patch to @:3.4.0
patch("disable_disutils_deprecation_warning.patch", when="^python@3.10:3.11")
variant("python", default=True, description="Provide Python bindings for SGpp", when="@3.2:") variant("python", default=True, description="Provide Python bindings for SGpp")
variant("optimization", default=True, description="Builds the optimization module of SGpp") variant("optimization", default=True, description="Builds the optimization module of SGpp")
variant("pde", default=True, description="Builds the datadriven module of SGpp") variant("pde", default=True, description="Builds the datadriven module of SGpp")
variant("quadrature", default=True, description="Builds the datadriven module of SGpp") variant("quadrature", default=True, description="Builds the datadriven module of SGpp")
@ -56,22 +65,17 @@ class Sgpp(SConsPackage):
) )
variant("mpi", default=False, description="Enables support for MPI-distributed operations") variant("mpi", default=False, description="Enables support for MPI-distributed operations")
# Java variant deactivated due to spack issue #987
# variant('java', default=False,
# description='Provide Java bindings for SGpp')
# depends_on('swig@3:', when='+java', type=('build'))
# extends('openjdk', when='+java')
# Mandatory dependencies # Mandatory dependencies
depends_on("scons", type=("build")) depends_on("scons@3:", type=("build"))
depends_on("scons@3:", when="@3.2.0:", type=("build"))
depends_on("zlib-api", type=("link")) depends_on("zlib-api", type=("link"))
# Python dependencies # Python dependencies
extends("python", when="+python") extends("python", when="+python")
depends_on("py-pip", when="+python", type="build") depends_on("py-pip", when="+python", type="build")
depends_on("py-wheel", when="+python", type="build") depends_on("py-wheel", when="+python", type="build")
depends_on("py-setuptools", when="+python", type=("build")) # TODO allow newer versions once distutils is removed from SGpp
depends_on("python@3.7:", when="+python", type=("build", "run")) depends_on("py-setuptools@:59", type=("build"))
# TODO allow newer versions once distutils is removed from SGpp
depends_on("python@3.7:3.11", type=("build", "run"))
depends_on("swig@3:", when="+python", type=("build")) depends_on("swig@3:", when="+python", type=("build"))
depends_on("py-numpy@1.17:", when="+python", type=("build", "run")) depends_on("py-numpy@1.17:", when="+python", type=("build", "run"))
depends_on("py-scipy@1.3:", when="+python", type=("build", "run")) depends_on("py-scipy@1.3:", when="+python", type=("build", "run"))
@ -105,7 +109,6 @@ class Sgpp(SConsPackage):
conflicts("+misc", when="-solver") conflicts("+misc", when="-solver")
conflicts("+misc", when="-optimization") conflicts("+misc", when="-optimization")
conflicts("+misc", when="-pde") conflicts("+misc", when="-pde")
conflicts("+misc", when="@1.0.0:3.1.0", msg="The misc module was introduced in version 3.2.0")
# Combigrid module requirements (for 3.2.0 or older) # Combigrid module requirements (for 3.2.0 or older)
# newer combigrids have no dependencies # newer combigrids have no dependencies
conflicts("+combigrid", when="@1.0.0:3.2.0~optimization") conflicts("+combigrid", when="@1.0.0:3.2.0~optimization")
@ -138,9 +141,7 @@ def build_args(self, spec, prefix):
# Generate swig bindings? # Generate swig bindings?
self.args.append("SG_PYTHON={0}".format("1" if "+python" in spec else "0")) self.args.append("SG_PYTHON={0}".format("1" if "+python" in spec else "0"))
# Java variant deactivated due to spack issue #987 # Java bindings are now deprecated within SGpp
# self.args.append('SG_JAVA={0}'.format(
# '1' if '+java' in spec else '0'))
self.args.append("SG_JAVA=0") self.args.append("SG_JAVA=0")
# Which modules to build? # Which modules to build?
@ -150,10 +151,7 @@ def build_args(self, spec, prefix):
self.args.append("SG_DATADRIVEN={0}".format("1" if "+datadriven" in spec else "0")) self.args.append("SG_DATADRIVEN={0}".format("1" if "+datadriven" in spec else "0"))
self.args.append("SG_COMBIGRID={0}".format("1" if "+combigrid" in spec else "0")) self.args.append("SG_COMBIGRID={0}".format("1" if "+combigrid" in spec else "0"))
self.args.append("SG_SOLVER={0}".format("1" if "+solver" in spec else "0")) self.args.append("SG_SOLVER={0}".format("1" if "+solver" in spec else "0"))
self.args.append("SG_MISC={0}".format("1" if "+misc" in spec else "0"))
# Misc flag did not exist in older versions
if not spec.satisfies("@1.0.0:3.2.0"):
self.args.append("SG_MISC={0}".format("1" if "+misc" in spec else "0"))
# SIMD scons parameter (pick according to simd spec) # SIMD scons parameter (pick according to simd spec)
if "avx512" in self.spec.target: if "avx512" in self.spec.target:
@ -181,6 +179,10 @@ def build_args(self, spec, prefix):
return self.args return self.args
def install_args(self, spec, prefix):
# SGpp expects the same args for the install and build commands
return self.args
@run_after("install") @run_after("install")
def python_install(self): def python_install(self):
if "+python" in self.spec: if "+python" in self.spec: