From 4eed83265395ab52532765c3ae9448283e9ff55b Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 4 Aug 2023 18:49:54 -0500 Subject: py-pyqt6: add new package (#32696) --- .../builtin/packages/py-matplotlib/package.py | 9 ++-- .../builtin/packages/py-pyqt-builder/package.py | 3 +- .../repos/builtin/packages/py-pyqt4/package.py | 43 +++++++++++---- .../repos/builtin/packages/py-pyqt5-sip/package.py | 6 +-- .../repos/builtin/packages/py-pyqt5/package.py | 62 ++++++++++------------ .../repos/builtin/packages/py-pyqt6-sip/package.py | 17 ++++++ .../repos/builtin/packages/py-pyqt6/package.py | 36 +++++++++++++ var/spack/repos/builtin/packages/py-sip/package.py | 50 +++++++++-------- var/spack/repos/builtin/packages/qgis/package.py | 3 -- .../repos/builtin/packages/qscintilla/package.py | 2 +- 10 files changed, 154 insertions(+), 77 deletions(-) create mode 100644 var/spack/repos/builtin/packages/py-pyqt6-sip/package.py create mode 100644 var/spack/repos/builtin/packages/py-pyqt6/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/py-matplotlib/package.py b/var/spack/repos/builtin/packages/py-matplotlib/package.py index 0c6f99dd85..a56508d339 100644 --- a/var/spack/repos/builtin/packages/py-matplotlib/package.py +++ b/var/spack/repos/builtin/packages/py-matplotlib/package.py @@ -177,13 +177,16 @@ class PyMatplotlib(PythonPackage): depends_on("tk@8.4:8.5,8.6.2:", when="backend=" + backend, type="run") depends_on("python+tkinter", when="backend=" + backend, type="run") # Qt + # matplotlib/backends/qt_compat.py for backend in ["qt4agg", "qt4cairo"]: depends_on("py-pyqt4@4.6:", when="backend=" + backend, type="run") + depends_on("qt+gui", when="backend=" + backend, type="run") for backend in ["qt5agg", "qt5cairo"]: depends_on("py-pyqt5", when="backend=" + backend, type="run") - # https://github.com/spack/spack/pull/32696 - # for backend in ["qtagg", "qtcairo"]: - # depends_on("py-pyqt6@6.1:", when="backend=" + backend, type="run") + depends_on("qt+gui", when="backend=" + backend, type="run") + for backend in ["qtagg", "qtcairo"]: + depends_on("py-pyqt6@6.1:", when="backend=" + backend, type="run") + depends_on("qt-base+gui+widgets", when="backend=" + backend, type="run") # GTK for backend in ["gtk", "gtkagg", "gtkcairo", "gtk3agg", "gtk3cairo", "gtk4agg", "gtk4cairo"]: depends_on("py-pygobject", when="backend=" + backend, type="run") diff --git a/var/spack/repos/builtin/packages/py-pyqt-builder/package.py b/var/spack/repos/builtin/packages/py-pyqt-builder/package.py index 25674c3142..74f31161d3 100644 --- a/var/spack/repos/builtin/packages/py-pyqt-builder/package.py +++ b/var/spack/repos/builtin/packages/py-pyqt-builder/package.py @@ -12,9 +12,10 @@ class PyPyqtBuilder(PythonPackage): homepage = "https://www.riverbankcomputing.com/hg/PyQt-builder/" pypi = "PyQt-builder/PyQt-builder-1.12.2.tar.gz" + version("1.15.1", sha256="a2bd3cfbf952e959141dfe55b44b451aa945ca8916d1b773850bb2f9c0fa2985") version("1.12.2", sha256="f62bb688d70e0afd88c413a8d994bda824e6cebd12b612902d1945c5a67edcd7") - depends_on("python@3.5:", type=("build", "run")) depends_on("py-setuptools@30.3:", type="build") depends_on("py-packaging", type=("build", "run")) + depends_on("py-sip@6.7:6", when="@1.15:", type=("build", "run")) depends_on("py-sip@6.3:6", type=("build", "run")) diff --git a/var/spack/repos/builtin/packages/py-pyqt4/package.py b/var/spack/repos/builtin/packages/py-pyqt4/package.py index 6de10982ab..4ce26a7829 100644 --- a/var/spack/repos/builtin/packages/py-pyqt4/package.py +++ b/var/spack/repos/builtin/packages/py-pyqt4/package.py @@ -13,11 +13,7 @@ class PyPyqt4(SIPPackage): against Qt v5.""" homepage = "https://www.riverbankcomputing.com/software/pyqt/intro" - url = ( - "http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.12.3/PyQt4_gpl_x11-4.12.3.tar.gz" - ) - - sip_module = "PyQt4.sip" + url = "https://www.riverbankcomputing.com/static/Downloads/PyQt4/4.12.3/PyQt4_gpl_x11-4.12.3.tar.gz" version("4.12.3", sha256="a00f5abef240a7b5852b7924fa5fdf5174569525dc076cd368a566619e56d472") version( @@ -33,16 +29,28 @@ class PyPyqt4(SIPPackage): # Requires distutils depends_on("python@:3.11", type=("build", "link", "run")) - depends_on("qt@4") - depends_on("qt@4.1:", when="@4.12.3") + depends_on("qt@4.1:4") + + # configure-ng.py depends_on("py-sip@4.19.12:4.19.18 module=PyQt4.sip") - # https://www.riverbankcomputing.com/static/Docs/PyQt4/installation.html - def configure_file(self): - return "configure-ng.py" + build_directory = "." def configure_args(self): + # https://www.riverbankcomputing.com/static/Docs/PyQt4/installation.html args = [ + "--verbose", + "--confirm-license", + "--qmake", + self.spec["qt"].prefix.bin.qmake, + "--sip", + self.spec["py-sip"].prefix.bin.sip, + "--sip-incdir", + join_path(self.spec["py-sip"].prefix, self.spec["python"].package.include), + "--bindir", + self.prefix.bin, + "--destdir", + python_platlib, "--pyuic4-interpreter", self.spec["python"].command.path, "--sipdir", @@ -53,3 +61,18 @@ class PyPyqt4(SIPPackage): if "+qsci_api" in self.spec: args.extend(["--qsci-api", "--qsci-api-destdir", self.prefix.share.qsci]) return args + + def configure(self, spec, prefix): + python("configure-ng.py", *self.configure_args()) + + @run_after("install") + def extend_path_setup(self): + # https://github.com/spack/spack/issues/14121 + # https://github.com/spack/spack/pull/15297 + # Same code comes by default with py-pyqt5 and py-pyqt6 + text = """ +# Support PyQt4 sub-packages that have been created by setuptools. +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +""" + with open(join_path(python_platlib, "PyQt4", "__init__.py"), "a") as f: + f.write(text) diff --git a/var/spack/repos/builtin/packages/py-pyqt5-sip/package.py b/var/spack/repos/builtin/packages/py-pyqt5-sip/package.py index 89bd9833a3..04f46ccd0a 100644 --- a/var/spack/repos/builtin/packages/py-pyqt5-sip/package.py +++ b/var/spack/repos/builtin/packages/py-pyqt5-sip/package.py @@ -10,9 +10,9 @@ class PyPyqt5Sip(PythonPackage): """The sip module support for PyQt5.""" homepage = "https://www.riverbankcomputing.com/software/sip/" - pypi = "PyQt5_sip/PyQt5_sip-12.9.0.tar.gz" + pypi = "PyQt5-sip/PyQt5_sip-12.9.0.tar.gz" + version("12.12.1", sha256="8fdc6e0148abd12d977a1d3828e7b79aae958e83c6cb5adae614916d888a6b10") version("12.9.0", sha256="d3e4489d7c2b0ece9d203ae66e573939f7f60d4d29e089c9f11daa17cfeaae32") - depends_on("python@3.5:", type=("build", "run")) - depends_on("py-setuptools", type="build") + depends_on("py-setuptools@30.3:", type="build") diff --git a/var/spack/repos/builtin/packages/py-pyqt5/package.py b/var/spack/repos/builtin/packages/py-pyqt5/package.py index af8b33af46..55a63dce74 100644 --- a/var/spack/repos/builtin/packages/py-pyqt5/package.py +++ b/var/spack/repos/builtin/packages/py-pyqt5/package.py @@ -12,44 +12,36 @@ class PyPyqt5(SIPPackage): Windows, OS X, Linux, iOS and Android. PyQt5 supports Qt v5.""" homepage = "https://www.riverbankcomputing.com/software/pyqt/intro" - url = ( - "https://www.riverbankcomputing.com/static/Downloads/PyQt5/5.13.0/PyQt5_gpl-5.13.0.tar.gz" + url = "https://files.pythonhosted.org/packages/source/P/PyQt5/PyQt5-5.15.9.tar.gz" + list_url = "https://pypi.org/simple/PyQt5/" + + version("5.15.9", sha256="dc41e8401a90dc3e2b692b411bd5492ab559ae27a27424eed4bd3915564ec4c0") + version( + "5.13.1", + sha256="54b7f456341b89eeb3930e786837762ea67f235e886512496c4152ebe106d4af", + deprecated=True, + ) + version( + "5.13.0", + sha256="0cdbffe5135926527b61cc3692dd301cd0328dd87eeaf1313e610787c46faff9", + deprecated=True, + ) + version( + "5.12.3", + sha256="0db0fa37debab147450f9e052286f7a530404e2aaddc438e97a7dcdf56292110", + deprecated=True, ) - list_url = "https://www.riverbankcomputing.com/software/pyqt/download5" - - sip_module = "PyQt5.sip" - version("5.13.1", sha256="54b7f456341b89eeb3930e786837762ea67f235e886512496c4152ebe106d4af") - version("5.13.0", sha256="0cdbffe5135926527b61cc3692dd301cd0328dd87eeaf1313e610787c46faff9") - version("5.12.3", sha256="0db0fa37debab147450f9e052286f7a530404e2aaddc438e97a7dcdf56292110") + # pyproject.toml + depends_on("py-sip@6.6.2:6", type="build") + depends_on("py-pyqt-builder@1.14.1:1", type="build") - # API files can be installed regardless if Qscintilla is installed or not - variant("qsci_api", default=False, description="Install PyQt API file for QScintilla") + # PKG-INFO + depends_on("py-pyqt5-sip@12.11:12", type=("build", "run")) - # Without opengl support, I got the following error: - # sip: QOpenGLFramebufferObject is undefined - depends_on("qt@5:+opengl") - depends_on("python@2.6:", type=("build", "run")) - depends_on("py-sip module=PyQt5.sip", type=("build", "run")) - depends_on("py-sip@:4.19.18 module=PyQt5.sip", type=("build", "run"), when="@:5.13.0") + # README + depends_on("qt@5+opengl") - # https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html def configure_args(self): - args = [ - "--pyuic5-interpreter", - self.spec["python"].command.path, - "--sipdir", - self.prefix.share.sip.PyQt5, - "--designer-plugindir", - self.prefix.plugins.designer, - "--qml-plugindir", - self.prefix.plugins.PyQt5, - "--stubsdir", - join_path(python_platlib, "PyQt5"), - ] - if "+qsci_api" in self.spec: - args.extend(["--qsci-api", "--qsci-api-destdir", self.prefix.share.qsci]) - return args - - def setup_run_environment(self, env): - env.prepend_path("QT_PLUGIN_PATH", self.prefix.plugins) + # https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html + return ["--confirm-license", "--no-make", "--qmake", self.spec["qt"].prefix.bin.qmake] diff --git a/var/spack/repos/builtin/packages/py-pyqt6-sip/package.py b/var/spack/repos/builtin/packages/py-pyqt6-sip/package.py new file mode 100644 index 0000000000..63d711eb92 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-pyqt6-sip/package.py @@ -0,0 +1,17 @@ +# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import * + + +class PyPyqt6Sip(PythonPackage): + """The sip module support for PyQt6.""" + + homepage = "https://www.riverbankcomputing.com/software/sip/" + pypi = "PyQt6-sip/PyQt6_sip-13.5.1.tar.gz" + + version("13.5.1", sha256="d1e9141752966669576d04b37ba0b122abbc41cc9c35493751028d7d91c4dd49") + + depends_on("py-setuptools@30.3:", type="build") diff --git a/var/spack/repos/builtin/packages/py-pyqt6/package.py b/var/spack/repos/builtin/packages/py-pyqt6/package.py new file mode 100644 index 0000000000..cdef126332 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-pyqt6/package.py @@ -0,0 +1,36 @@ +# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import * + + +class PyPyqt6(SIPPackage): + """PyQt6 is a comprehensive set of Python bindings for Qt v6.""" + + homepage = "https://www.riverbankcomputing.com/software/pyqt/" + url = "https://files.pythonhosted.org/packages/source/P/PyQt6/PyQt6-6.5.1.tar.gz" + list_url = "https://pypi.org/simple/PyQt6/" + + version("6.5.1", sha256="e166a0568c27bcc8db00271a5043936226690b6a4a74ce0a5caeb408040a97c3") + + # pyproject.toml + depends_on("py-sip@6.5:6", type="build") + depends_on("py-pyqt-builder@1.15:1", type="build") + + # PKG-INFO + depends_on("py-pyqt6-sip@13.4:13", type=("build", "run")) + + # README + depends_on("qt-base@6") + + def setup_build_environment(self, env): + # Detected system locale encoding (US-ASCII, locale "C") is not UTF-8. + # Qt shall use a UTF-8 locale ("UTF-8") instead. If this causes problems, + # reconfigure your locale. See the locale(1) manual for more information. + env.set("LC_ALL", "en_US.UTF-8") + + def configure_args(self): + # https://www.riverbankcomputing.com/static/Docs/PyQt6/installation.html + return ["--confirm-license", "--no-make", "--qmake", self.spec["qt-base"].prefix.bin.qmake] diff --git a/var/spack/repos/builtin/packages/py-sip/package.py b/var/spack/repos/builtin/packages/py-sip/package.py index 031c04ca8b..e85f442127 100644 --- a/var/spack/repos/builtin/packages/py-sip/package.py +++ b/var/spack/repos/builtin/packages/py-sip/package.py @@ -14,9 +14,11 @@ class PySip(PythonPackage): homepage = "https://www.riverbankcomputing.com/software/sip" pypi = "sip/sip-6.4.0.tar.gz" + version("6.7.9", sha256="35d51fc10f599d3696abb50f29d068ad04763df7b77808c76b74597660f99b17") version("6.6.2", sha256="0e3efac1c5dfd8e525ae57140927df26993e13f58b89d1577c314f4105bfd90d") version("6.4.0", sha256="42ec368520b8da4a0987218510b1b520b4981e4405086c1be384733affc2bcb0") version("5.5.0", sha256="5d024c419b30fea8a6de8c71a560c7ab0bc3c221fbfb14d55a5b865bd58eaac5") + version("4.19.25", sha256="3d36986f7327b7b966bb6eacf22bcf6e4d0a3d24e392276ef92af89988818062") version("4.19.21", sha256="3bfd58e875a87471c00e008f25a01d8312885aa01efc4f688e5cac861c8676e4") version("4.19.20", sha256="475f85277a6601c406ade508b6c935b9f2a170c16fd3ae9dd4cdee7a4f7f340d") version("4.19.19", sha256="348cd6229b095a3090e851555814f5147bffcb601cec891f1038eb6b38c9d856") @@ -33,27 +35,25 @@ class PySip(PythonPackage): multi=False, ) - depends_on("python@3.7:", when="@6.6:", type=("build", "link", "run")) - depends_on("python@3.6:", when="@6:", type=("build", "link", "run")) - depends_on("py-ply", when="@6.6:", type=("build", "run")) with when("@5:"): - depends_on("python@3.5.1:", type=("build", "link", "run")) - depends_on("py-packaging", type="build") - depends_on("py-setuptools@30.3:", type="build") - depends_on("py-toml", type="build") + depends_on("python", type=("build", "link", "run")) + depends_on("py-packaging", type=("build", "run")) + depends_on("py-setuptools@30.3:", type=("build", "run")) + depends_on("py-tomli", when="@6.7: ^python@:3.10", type=("build", "run")) + depends_on("py-toml", when="@:6.6", type=("build", "run")) with when("@:4"): - depends_on("python", type=("build", "link", "run")) + # Requires distutils + depends_on("python@:3.11", type=("build", "link", "run")) depends_on("flex", type="build") depends_on("bison", type="build") def url_for_version(self, version): - if version < Version("5.0.0"): - return "https://www.riverbankcomputing.com/hg/sip/archive/{0}.tar.gz".format( - version.dotted - ) + if version < Version("5"): + url = "https://www.riverbankcomputing.com/hg/sip/archive/{0}.tar.gz" + return url.format(version.dotted) return super().url_for_version(version) @when("@:4") @@ -75,12 +75,20 @@ class PySip(PythonPackage): @run_after("install") def extend_path_setup(self): - if self.spec.satisfies("@:4"): - # See github issue #14121 and PR #15297 - module = self.spec.variants["module"].value - if module != "sip": - module = module.split(".")[0] - with working_dir(python_platlib): - with open(os.path.join(module, "__init__.py"), "w") as f: - f.write("from pkgutil import extend_path\n") - f.write("__path__ = extend_path(__path__, __name__)\n") + # https://github.com/spack/spack/issues/14121 + # https://github.com/spack/spack/pull/15297 + # Same code comes by default with py-pyqt5 and py-pyqt6 + if self.spec.satisfies("@5:"): + return + + module = self.spec.variants["module"].value + if module == "sip": + return + + module = module.split(".")[0] + text = f""" +# Support {module} sub-packages that have been created by setuptools. +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +""" + with open(join_path(python_platlib, module, "__init__.py"), "w") as f: + f.write(text) diff --git a/var/spack/repos/builtin/packages/qgis/package.py b/var/spack/repos/builtin/packages/qgis/package.py index fb9d22a244..a269ba95a1 100644 --- a/var/spack/repos/builtin/packages/qgis/package.py +++ b/var/spack/repos/builtin/packages/qgis/package.py @@ -161,9 +161,6 @@ class Qgis(CMakePackage): depends_on("qt@5.9.0:", when="@3.10.0:") depends_on("qtkeychain@:1.5", when="^qt@4") depends_on("qt@:4", when="@2") - # Help concretizer - # +qsci_api is implied by qscintilla+python dependency - depends_on("py-pyqt5@5.3: +qsci_api", when="@3") patch("pyqt5.patch", when="@:3.14 ^qt@5") patch("pyqt5_3165x.patch", when="@3.16.5:3.21 ^qt@5") diff --git a/var/spack/repos/builtin/packages/qscintilla/package.py b/var/spack/repos/builtin/packages/qscintilla/package.py index dea8ae886c..90a17030c7 100644 --- a/var/spack/repos/builtin/packages/qscintilla/package.py +++ b/var/spack/repos/builtin/packages/qscintilla/package.py @@ -46,7 +46,7 @@ class Qscintilla(QMakePackage): depends_on("qt+opengl", when="+python") depends_on("qt") - depends_on("py-pyqt5 +qsci_api", type=("build", "run"), when="+python ^qt@5") + depends_on("py-pyqt5", type=("build", "run"), when="+python ^qt@5") depends_on("py-pyqt4 +qsci_api", type=("build", "run"), when="+python ^qt@4") depends_on("python", type=("build", "run"), when="+python") # adter install inquires py-sip variant : so we need to have it -- cgit v1.2.3-70-g09d2