Skip to content

Commit

Permalink
Python bindings: fix compatibility issue with SWIG 4.3.0 and PYTHONWA…
Browse files Browse the repository at this point in the history
…RNINGS=error

Fixes conda-forge#995

Upstream fix in OSGeo/gdal#11154
  • Loading branch information
rouault committed Oct 28, 2024
1 parent 40f784d commit 833bda3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 037ab68854a533cd80d71d1b8dd447ff9ab6575f Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Mon, 28 Oct 2024 19:59:52 +0100
Subject: [PATCH] Python bindings: fix compatibility issue with SWIG 4.3.0 and
PYTHONWARNINGS=error

Fixes https://github.com/conda-forge/gdal-feedstock/issues/995
---
.github/workflows/cmake_builds.yml | 2 ++
swig/python/modify_cpp_files.cmake | 4 ++++
2 files changed, 6 insertions(+)

diff --git a/.github/workflows/cmake_builds.yml b/.github/workflows/cmake_builds.yml
index 77658bf242..d5ee785b23 100644
--- a/.github/workflows/cmake_builds.yml
+++ b/.github/workflows/cmake_builds.yml
@@ -218,6 +218,8 @@ jobs:
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/install-gdal/lib
$GITHUB_WORKSPACE/install-gdal/bin/gdalinfo --version
PYTHONPATH=$GITHUB_WORKSPACE/install-gdal/lib/python3.8/site-packages python3 -c "from osgeo import gdal;print(gdal.VersionInfo(None))"
+ # Test fix for https://github.com/conda-forge/gdal-feedstock/issues/995
+ PYTHONWARNINGS="error" PYTHONPATH=$GITHUB_WORKSPACE/install-gdal/lib/python3.8/site-packages python3 python -c "from osgeo import gdal"
PYTHONPATH=$GITHUB_WORKSPACE/install-gdal/lib/python3.8/site-packages python3 $GITHUB_WORKSPACE/scripts/check_doc.py
- name: CMake with rpath
run: |
diff --git a/swig/python/modify_cpp_files.cmake b/swig/python/modify_cpp_files.cmake
index af6668b018..293d7fddd2 100644
--- a/swig/python/modify_cpp_files.cmake
+++ b/swig/python/modify_cpp_files.cmake
@@ -60,4 +60,8 @@ string(REPLACE "if (--interpreter_counter != 0) // another sub-interpreter may s
"/* Even Rouault / GDAL hack for SWIG >= 4.1 related to objects not being freed. See swig/python/modify_cpp_files.cmake for more details */\nif( 1 )"
_CONTENTS "${_CONTENTS}")

+# Workarounds https://github.com/swig/swig/issues/3061
+string(REPLACE "# define SWIG_HEAPTYPES" "// Below is disabled because of https://github.com/swig/swig/issues/3061\n// # define SWIG_HEAPTYPES"
+ _CONTENTS "${_CONTENTS}")
+
file(WRITE ${FILE} "${_CONTENTS}")
--
2.25.1

3 changes: 2 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ source:
sha256: 34a037852ffe6d2163f1b8948a1aa7019ff767148aea55876c1339b22ad751f1
patches:
- 000_cmake.patch # [osx]
- 0001-Python-bindings-fix-compatibility-issue-with-SWIG-43.patch

build:
number: 0
number: 1
skip_compile_pyc:
- share/bash-completion/completions/*.py
ignore_run_exports_from:
Expand Down

0 comments on commit 833bda3

Please sign in to comment.