22#
33# SPDX-License-Identifier: (Apache-2.0 OR MIT)
44
5+ from pathlib import Path
6+
57from spack_repo .builtin .build_systems .cmake import CMakePackage
68
79from spack .package import *
@@ -14,18 +16,23 @@ class Qgis(CMakePackage):
1416 """
1517
1618 homepage = "https://qgis.org"
17- url = "https://qgis.org/downloads/qgis-3.8.1.tar.bz2"
19+
20+ # the downloads are listed via json, so the spack checksum crawler won't find them
21+ # spack checksum qgis x.y.z will provide the new checksum
22+ url = "https://qgis.org/downloads/qgis-3.44.7.tar.bz2"
1823
1924 maintainers ("adamjstewart" , "Sinan81" , "Chrismarsh" )
2025
2126 license ("GPL-2.0-or-later" )
2227
2328 # Prefer latest LTR
2429 version (
25- "3.40.6 " ,
26- sha256 = "dd68d39a2a29326031195bed2125e8b0fa7112fe9ee74d5f9850d06b02cef6a8 " ,
30+ "3.44.8 " ,
31+ sha256 = "146e197f34f1f9ede8cfdf5b9cc4d76667771720a302172c32d4117367356e96 " ,
2732 preferred = True ,
2833 )
34+ version ("3.44.7" , sha256 = "1ab06f40600c84e928b4fe22a66997d80973201b10769e7a636e5be83459b814" )
35+ version ("3.40.6" , sha256 = "dd68d39a2a29326031195bed2125e8b0fa7112fe9ee74d5f9850d06b02cef6a8" )
2936 version ("3.40.1" , sha256 = "53110464c9f5ba5562c437e1563ab36dad2f218e6e7d1c0cfbe5b6effe241c8e" )
3037 version ("3.34.15" , sha256 = "afb0bed05ffbc7bcb6d27dd1a8644b1e63ac2cb322baa058ff65b848c760efc2" )
3138 version ("3.34.13" , sha256 = "a8873ca9bae346bae48ef3fe3eed702ef1f06d951201464464a64019302ba50b" )
@@ -122,17 +129,22 @@ class Qgis(CMakePackage):
122129 depends_on ("gdal@2.1.0: +python" , type = ("build" , "link" , "run" ))
123130 depends_on ("gdal@3.2.0: +python" , type = ("build" , "link" , "run" ), when = "@3.28:" )
124131 depends_on ("geos@3.4.0:" )
125- depends_on ("libspatialindex" )
132+
133+ # https://github.com/libspatialindex/libspatialindex/issues/276
134+ depends_on ("libspatialindex@:2.0.0" )
126135 depends_on ("libspatialite@4.2.0:" )
127136 depends_on ("libzip" )
128137 depends_on ("libtasn1" )
138+
129139 depends_on ("proj@4.4.0:" )
130140 depends_on ("proj@4.9.3:" , when = "@3.8.2:" )
131141 depends_on ("proj@7.2:" , when = "@3.28:" )
132142 depends_on ("proj@:8" , when = "@3.28" ) # build fails with proj@9
133143 # fails to build with proj 9.4+ until the backported patch in 3.34.5
134144 # https://github.com/qgis/QGIS/pull/56761
135145 depends_on ("proj@:9.3" , when = "@:3.34.4" )
146+ depends_on ("proj@:9.5" , when = "@3.34.5:3.34.15" )
147+
136148 depends_on ("py-psycopg2" , type = ("build" , "run" )) # TODO: is build dependency necessary?
137149 depends_on ("py-pyqt4" , when = "@2" )
138150 depends_on ("py-pyqt5@5.3:" , when = "@3" )
@@ -163,6 +175,7 @@ class Qgis(CMakePackage):
163175 depends_on ("py-owslib" , type = "run" )
164176 depends_on ("py-jinja2" , type = "run" )
165177 depends_on ("py-pygments" , type = "run" )
178+ depends_on ("py-packaging" , type = "run" , when = "@3.44:" )
166179
167180 # optionals
168181 depends_on ("postgresql@8:" , when = "+postgresql" ) # for PostGIS support
@@ -223,9 +236,35 @@ def fix_qsci_sip(self):
223236 elif "^py-pyqt6" in self .spec :
224237 pyqtx = "PyQt6"
225238
239+ pp = Path ("python/gui/pyproject.toml.in" )
240+ txt = pp .read_text (encoding = "utf-8" )
241+
226242 sip_inc_dir = join_path (self ["qscintilla" ].module .python_platlib , pyqtx , "bindings" )
227- with open (join_path ("python" , "gui" , "pyproject.toml.in" ), "a" ) as tomlfile :
228- tomlfile .write (f'\n [tool.sip.project]\n sip-include-dirs = ["{ sip_inc_dir } "]\n ' )
243+ sip_line = f'sip-include-dirs = ["{ sip_inc_dir } "]'
244+
245+ # QGis 3.42.0 added a @sipabi@ that expands to the [tool.sip.project] header.
246+ # The simple patch append approach results in a duplicate header which causes a
247+ # build failure. The middle case is probably overkill but it is kept as a just
248+ # in (edge) case
249+
250+ # if it's already there, do nothing
251+ if sip_line not in txt :
252+ if "@sipabi@" in txt :
253+ # @sipabi@ expands to the [tool.sip.project] table + abi-version,
254+ # add just the key immediately after it
255+ txt = txt .replace ("@sipabi@" , "@sipabi@\n " + sip_line , 1 )
256+
257+ elif "[tool.sip.project]" in txt :
258+ # insert right after the first header occurrence
259+ txt = txt .replace ("[tool.sip.project]" , "[tool.sip.project]\n " + sip_line , 1 )
260+
261+ else :
262+ # no macro + no table, append a new table
263+ if not txt .endswith ("\n " ):
264+ txt += "\n "
265+ txt += "\n [tool.sip.project]\n " + sip_line + "\n "
266+
267+ pp .write_text (txt , encoding = "utf-8" )
229268
230269 def cmake_args (self ):
231270 spec = self .spec
0 commit comments