app-metrics/prometheus: add 3.1.0
[gentoo/gentoo.git] / sci-geosciences / qgis / qgis-9999.ebuild
blobe3db08636738e93d67c816413194ce3fa2674fc1
1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
6 PYTHON_COMPAT=( python3_{10..12} )
7 PYTHON_REQ_USE="sqlite"
9 # We only package the LTS releases right now
10 # We could package more but would ideally only stabilise the LTS ones
11 # at least.
13 if [[ ${PV} == *9999* ]]; then
14         EGIT_REPO_URI="https://github.com/${PN}/${PN^^}.git"
15         inherit git-r3
16 else
17         SRC_URI="https://qgis.org/downloads/${P}.tar.bz2
18                 examples? ( https://qgis.org/downloads/data/qgis_sample_data.tar.gz -> qgis_sample_data-2.8.14.tar.gz )"
19         KEYWORDS="~amd64"
21 inherit cmake flag-o-matic python-single-r1 virtualx xdg
23 DESCRIPTION="User friendly Geographic Information System"
24 HOMEPAGE="https://www.qgis.org/"
26 LICENSE="GPL-2+ GPL-3+"
27 SLOT="0"
28 IUSE="3d doc examples +georeferencer grass hdf5 mapserver netcdf opencl oracle pdal postgres python qml test webengine"
30 REQUIRED_USE="${PYTHON_REQUIRED_USE}
31         mapserver? ( python )
33 #       test? ( postgres )
35 # Disabling test suite because upstream disallow running from install path
36 RESTRICT="!test? ( test )"
38 COMMON_DEPEND="
39         app-crypt/qca:2[qt6,ssl]
40         >=dev-db/spatialite-4.2.0
41         dev-db/sqlite:3
42         dev-libs/expat
43         dev-libs/libzip:=
44         dev-libs/protobuf:=
45         dev-libs/qtkeychain[qt6]
46         dev-qt/qttools:6[designer]
47         dev-qt/qtbase:6[concurrent,gui,network,sql,ssl,widgets,xml]
48         dev-qt/qtmultimedia:6
49         dev-qt/qtpositioning:6
50         dev-qt/qtserialport:6
51         dev-qt/qtsvg:6
52         dev-vcs/git
53         media-gfx/exiv2:=
54         >=sci-libs/gdal-3.0.4:=[geos,spatialite,sqlite]
55         sci-libs/geos
56         sci-libs/libspatialindex:=
57         >=sci-libs/proj-4.9.3:=
58         sys-libs/zlib
59         >=x11-libs/qscintilla-2.10.1:=[qt6]
60         >=x11-libs/qwt-6.2.0-r3:=[polar(+),qt6,svg(+)]
61         3d? ( dev-qt/qt3d:6 )
62         georeferencer? ( sci-libs/gsl:= )
63         grass? ( sci-geosciences/grass:= )
64         hdf5? ( sci-libs/hdf5:= )
65         mapserver? ( dev-libs/fcgi )
66         netcdf? ( sci-libs/netcdf:= )
67         opencl? ( virtual/opencl )
68         oracle? (
69                 dev-db/oracle-instantclient:=
70                 sci-libs/gdal:=[oracle]
71         )
72         pdal? ( sci-libs/pdal:= )
73         postgres? ( dev-db/postgresql:= )
74         python? (
75                 ${PYTHON_DEPS}
76                 >=sci-libs/gdal-2.2.3[python,${PYTHON_SINGLE_USEDEP}]
77                 $(python_gen_cond_dep '
78                         dev-python/httplib2[${PYTHON_USEDEP}]
79                         dev-python/jinja2[${PYTHON_USEDEP}]
80                         dev-python/markupsafe[${PYTHON_USEDEP}]
81                         dev-python/numpy[${PYTHON_USEDEP}]
82                         dev-python/owslib[${PYTHON_USEDEP}]
83                         dev-python/pygments[${PYTHON_USEDEP}]
84                         dev-python/python-dateutil[${PYTHON_USEDEP}]
85                         dev-python/pytz[${PYTHON_USEDEP}]
86                         dev-python/pyyaml[${PYTHON_USEDEP}]
87                         >=dev-python/qscintilla-2.10.1[${PYTHON_USEDEP}]
88                         dev-python/requests[${PYTHON_USEDEP}]
89                         dev-python/sip:=[${PYTHON_USEDEP}]
90                         postgres? ( dev-python/psycopg:2[${PYTHON_USEDEP}] )
91                         dev-python/pyqt6[designer,gui,multimedia,network,positioning,printsupport,serialport,sql,svg,widgets,${PYTHON_USEDEP}]
92                         >=dev-python/qscintilla-2.10.1[qt6]
93                 ')
94         )
95         qml? ( dev-qt/qtdeclarative:6 )
96         webengine? ( dev-qt/qtwebengine:6 )
98 DEPEND="${COMMON_DEPEND}
99         test? (
100                 python? (
101                         app-text/qpdf
102                         app-text/poppler[cairo,utils]
103                 )
104         )
106 RDEPEND="${COMMON_DEPEND}
107         sci-geosciences/gpsbabel
109 BDEPEND="${PYTHON_DEPS}
110         dev-qt/qttools:6[linguist]
111         app-alternatives/yacc
112         app-alternatives/lex
113         doc? ( app-text/doxygen )
114         test? (
115                 python? (
116                         $(python_gen_cond_dep '
117                                 dev-python/pyqt6[${PYTHON_USEDEP},testlib]
118                                 dev-python/nose2[${PYTHON_USEDEP}]
119                                 dev-python/mock[${PYTHON_USEDEP}]
120                         ')
121                 )
122         )
125 PATCHES=(
126         # "${FILESDIR}/${PN}-3.36.3-qt6-Fix-broken-test.patch"
127         "${FILESDIR}/${PN}-3.36.3-qt6.patch"
128         "${FILESDIR}/${PN}-3.36.3-testReportDir.patch"
131 src_prepare() {
132         cmake_src_prepare
133         # Tests want to be run inside a git repo
134         if [[ ${PV} != *9999* ]]; then
135                 if use test; then
136                         git config --global --add safe.directory "${S}" || die
137                         git init -q || die
138                         git config --local gc.auto 0 || die
139                         git config --local user.email "larry@gentoo.org" || die
140                         git config --local user.name "Larry the Cow" || die
141                         git add . || die
143                         git commit -m "init" || die
144                 fi
145         fi
148 src_configure() {
149         # -Werror=strict-aliasing
150         # https://bugs.gentoo.org/862660
151         # https://github.com/qgis/QGIS/issues/56859
152         #
153         # Do not trust with LTO either
154         append-flags -fno-strict-aliasing
155         filter-lto
157         local mycmakeargs=(
158                 -DQGIS_MANUAL_SUBDIR=share/man/
159                 -DQGIS_LIB_SUBDIR=$(get_libdir)
160                 -DQGIS_PLUGIN_SUBDIR=$(get_libdir)/qgis
162                 # -DQWT_INCLUDE_DIR=/usr/include/qwt6
163                 # -DQWT_LIBRARY=/usr/$(get_libdir)/libqwt6-qt5.so
164                 # -DQGIS_QML_SUBDIR=/usr/$(get_libdir)/qt5/qml
166                 -DPEDANTIC=OFF
167                 -DUSE_CCACHE=OFF
168                 -DBUILD_WITH_QT6=ON
169                 -DWITH_ANALYSIS=ON
170                 -DWITH_APIDOC=$(usex doc)
171                 -DWITH_GUI=ON
172                 -DWITH_INTERNAL_MDAL=ON # not packaged, bug 684538
173                 -DWITH_QSPATIALITE=ON
174                 -DENABLE_TESTS=$(usex test)
175                 -DWITH_3D=$(usex 3d)
176                 -DWITH_GSL=$(usex georeferencer)
177                 $(cmake_use_find_package hdf5 HDF5)
178                 -DWITH_SERVER=$(usex mapserver)
179                 $(cmake_use_find_package netcdf NetCDF)
180                 -DUSE_OPENCL=$(usex opencl)
181                 -DWITH_ORACLE=$(usex oracle)
182                 -DWITH_QWTPOLAR=ON
183                 -DWITH_QTWEBENGINE=$(usex webengine)
184                 -DWITH_PDAL=$(usex pdal)
185                 -DWITH_POSTGRESQL=$(usex postgres)
186                 -DWITH_BINDINGS=$(usex python)
187                 -DWITH_CUSTOM_WIDGETS=$(usex python)
188                 -DWITH_QUICK=$(usex qml)
189                 -DWITH_QTWEBKIT=OFF
190                 -DWITH_DRACO=OFF
191         )
193         # We list all supported versions *by upstream for this version*
194         # here, even if we're not allowing it (e.g. bugs for now), so
195         # we enable/disable all the right versions. This is so qgis doesn't
196         # try to automatically use a version the build system knows about.
197         local supported_grass_versions=( 7 8 )
198         if use grass; then
199                 # We can do this because we have a := dep on grass &
200                 # it changes subslot (ABI) when major versions change, so
201                 # the logic here doesn't end up becoming stale.
202                 readarray -d'-' -t f <<<"$(best_version sci-geosciences/grass)"
203                 readarray -d'.' -t v <<<"${f[2]}"
204                 grassdir="grass${v[0]}${v[1]}"
206                 GRASSDIR=/usr/$(get_libdir)/${grassdir}
208                 einfo "Supported versions: ${supported_grass_versions[*]}"
209                 einfo "Found GRASS version: ${v[0]}*"
211                 local known_grass_version
212                 # GRASS isn't slotted (in Gentoo, anyway) so we pick
213                 # the best version we can to build against, and disable the others.
214                 for known_grass_version in "${supported_grass_versions[@]}" ; do
215                         case "${known_grass_version}" in
216                                 "${v[0]}")
217                                         einfo "GRASS version ${known_grass_version} is supported. Enabling."
218                                         mycmakeargs+=(
219                                                 "-DGRASS_PREFIX${known_grass_version}=${GRASSDIR}"
220                                                 "-DWITH_GRASS${known_grass_version}=ON"
221                                         )
222                                         ;;
223                                 *)
224                                         einfo "GRASS version ${known_grass_version} is not supported or not latest found. Disabling."
225                                         mycmakeargs+=(
226                                                 "-DWITH_GRASS${known_grass_version}=OFF"
227                                         )
228                                         ;;
229                         esac
230                 done
231         else
232                 local known_grass_version
233                 for known_grass_version in "${supported_grass_versions[@]}" ; do
234                         mycmakeargs+=(
235                                 "-DWITH_GRASS${known_grass_version}=OFF"
236                         )
237                 done
238         fi
240         use python && mycmakeargs+=( -DBINDINGS_GLOBAL_INSTALL=ON )
242         CMAKE_BUILD_TYPE=Release  # RelWithDebInfo enables debug logging
244         cmake_src_configure
247 src_test() {
248         addwrite "/proc/self/mem"
249         addwrite "/proc/self/task/"
250         addwrite "/dev/fuse"
252         local -x CMAKE_SKIP_TESTS=(
253                 PyQgsAFSProvider$
254                 PyQgsAnnotation$
255                 PyQgsAuthenticationSystem$
256                 PyQgsAuxiliaryStorage$
257                 PyQgsBlockingNetworkRequest$
258                 PyQgsBlockingProcess$
259                 PyQgsCodeEditor$
260                 PyQgsDataItemProviderRegistry$
261                 PyQgsDelimitedTextProvider$
262                 PyQgsEditWidgets$
263                 PyQgsElevationProfileCanvas$
264                 PyQgsEmbeddedSymbolRenderer$
265                 PyQgsExternalStorageAwsS3$
266                 PyQgsExternalStorageWebDav$
267                 PyQgsFileDownloader$
268                 PyQgsFloatingWidget$
269                 PyQgsGeometryTest$
270                 PyQgsGoogleMapsGeocoder$
271                 PyQgsGroupLayer$
272                 PyQgsLayerDefinition$
273                 PyQgsLayoutHtml$
274                 PyQgsLayoutLegend$
275                 PyQgsLayoutMap$
276                 PyQgsLineSymbolLayers$
277                 PyQgsMapBoxGlStyleConverter$
278                 PyQgsMapLayerComboBox$
279                 PyQgsMapLayerProxyModel$
280                 PyQgsMemoryProvider$
281                 PyQgsNetworkAccessManager$
282                 PyQgsOGRProvider$
283                 PyQgsOGRProviderGpkg$
284                 PyQgsPainting$
285                 PyQgsPalLabelingCanvas$
286                 PyQgsPalLabelingLayout$
287                 PyQgsPalLabelingPlacement$
288                 PyQgsPlot$
289                 PyQgsPointCloudAttributeByRampRenderer$
290                 PyQgsPointCloudClassifiedRenderer$
291                 PyQgsPointCloudRgbRenderer$
292                 PyQgsProcessExecutablePt1$
293                 PyQgsProcessExecutablePt2$
294                 PyQgsProcessingAlgRunner$
295                 PyQgsProcessingInPlace$
296                 PyQgsProcessingPackageLayersAlgorithm$
297                 PyQgsProcessingParameters$
298                 PyQgsProject$
299                 PyQgsPythonProvider$
300                 PyQgsRasterFileWriter$
301                 PyQgsRasterLayer$
302                 PyQgsRasterLayerRenderer$
303                 PyQgsSelectiveMasking$
304                 PyQgsSettings$
305                 PyQgsSettingsEntry$
306                 PyQgsShapefileProvider$
307                 PyQgsSpatialiteProvider$
308                 PyQgsStyleModel$
309                 PyQgsSvgCache$
310                 PyQgsSymbolLayerReadSld$
311                 PyQgsTextRenderer$
312                 PyQgsVectorFileWriter$
313                 PyQgsVectorLayerCache$
314                 PyQgsVectorLayerEditBuffer$
315                 PyQgsVectorLayerEditUtils$
316                 PyQgsVectorLayerProfileGenerator$
317                 PyQgsWFSProvider$
318                 TestQgsRandomMarkerSymbolLayer$
319                 qgis_sip_uptodate$
320                 test_3d_3drendering$
321                 test_3d_layout3dmap$
322                 test_3d_mesh3drendering$
323                 test_3d_pointcloud3drendering$
324                 test_3d_tessellator$
325                 test_analysis_gcptransformer$
326                 test_app_advanceddigitizing$
327                 test_authmethod_authoauth2method$
328                 test_core_mapdevicepixelratio$
329                 test_core_ogcutils$
330                 test_core_openclutils$
331                 test_core_vectortilelayer$
332                 test_gui_dockwidget$
333                 test_gui_ogrprovidergui$
335                 PyQgsDocCoverage$
336                 PyQgsSipCoverage$
337         )
339         CMAKE_SKIP_TESTS+=(
340                 test_core_blendmodes$
341                 test_core_callout$
342                 test_core_compositionconverter$
343                 test_core_dataitem$
344                 test_core_expression$
345                 test_core_gdalutils$
346                 test_core_labelingengine$
347                 test_core_layoutmap$
348                 test_core_layoutmapoverview$
349                 test_core_layoutpicture$
350                 test_core_linefillsymbol$
351                 test_core_maprendererjob$
352                 test_core_maprotation$
353                 test_core_meshlayer$
354                 test_core_meshlayerrenderer$
355                 test_core_networkaccessmanager$
356                 test_core_pointcloudlayerexporter$
357                 test_core_project$
358                 test_core_rastercontourrenderer$
359                 test_core_rasterlayer$
360                 test_core_simplemarker$
361                 test_core_tiledownloadmanager$
362                 test_gui_processinggui$
363                 test_gui_filedownloader$
364                 test_gui_newdatabasetablewidget$
365                 test_gui_queryresultwidget$
366                 test_analysis_processingalgspt2$
367                 test_analysis_meshcontours$
368                 test_analysis_triangulation$
369                 test_analysis_processing$
370                 test_provider_wcsprovider$
371                 test_app_maptoolcircularstring$
372                 test_app_vertextool$
373         )
375         if ! use netcdf; then
376                 CMAKE_SKIP_TESTS+=(
377                         test_core_gdalprovider$
378                 )
379         fi
381         if ! use hdf5; then
382                 CMAKE_SKIP_TESTS+=(
383                         test_gui_meshlayerpropertiesdialog$
384                         test_app_maptooleditmesh$
385                 )
386         fi
388         if ! use python || ! use postgres; then
389                 CMAKE_SKIP_TESTS+=(
390                         ProcessingGrassAlgorithmsRasterTestPt2$
391                         ProcessingCheckValidityAlgorithmTest$
392                         ProcessingGdalAlgorithmsGeneralTest$
393                         ProcessingGdalAlgorithmsRasterTest$
394                         ProcessingGdalAlgorithmsVectorTest$
395                         ProcessingGeneralTest$
396                         ProcessingGenericAlgorithmsTest$
397                         ProcessingGrassAlgorithmsImageryTest$
398                         ProcessingGrassAlgorithmsRasterTestPt1$
399                         ProcessingGrassAlgorithmsVectorTest$
400                         ProcessingGuiTest$
401                         ProcessingModelerTest$
402                         ProcessingParametersTest$
403                         ProcessingProjectProviderTest$
404                         ProcessingQgisAlgorithmsTestPt1$
405                         ProcessingQgisAlgorithmsTestPt2$
406                         ProcessingQgisAlgorithmsTestPt3$
407                         ProcessingQgisAlgorithmsTestPt4$
408                         ProcessingQgisAlgorithmsTestPt5$
409                         ProcessingQgisAlgorithmsTestPt5$
410                         ProcessingScriptUtilsTest$
411                         ProcessingToolsTest$
412                 )
413         fi
415         local myctestargs=(
416                 --output-on-failure
417                 -j1
418         )
420         xdg_environment_reset
422         local -x QGIS_CONTINUOUS_INTEGRATION_RUN="true"
423         virtx cmake_src_test
426 src_install() {
427         if use test; then
428                 git config --global --add safe.directory "${S}" || die
429         fi
430         cmake_src_install
432         insinto /usr/share/mime/packages
433         doins debian/qgis.xml
435         if use examples; then
436                 docinto examples
437                 dodoc -r "${WORKDIR}"/qgis_sample_data/.
438                 docompress -x "/usr/share/doc/${PF}/examples"
439         fi
441         if use python; then
442                 python_optimize
443                 python_optimize "${ED}"/usr/share/qgis/python
444         fi
446         if use grass; then
447                 python_fix_shebang "${ED}"/usr/share/qgis/grass/scripts
448         fi
451 pkg_postinst() {
452         if use postgres; then
453                 elog "If you don't intend to use an external PostGIS server"
454                 elog "you should install:"
455                 elog "   dev-db/postgis"
456         elif use python; then
457                 elog "Support of PostgreSQL is disabled."
458                 elog "But some installed python-plugins import the psycopg2 module."
459                 elog "If you do not need these plugins just disable them"
460                 elog "in the Plugins menu, else you need to set USE=\"postgres\""
461         fi
463         xdg_pkg_postinst