+
+-if __package__ or '.' in __name__:
++if getattr(__spec__, "parent", None) or '.' in __name__:
+ from ._foo import *
+ else:
+ from _foo import *
+diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
+index 86daf131c8b..a71fc3cdb25 100644
+--- a/Source/Modules/python.cxx
++++ b/Source/Modules/python.cxx
+@@ -703,20 +703,22 @@ class PYTHON:public Language {
+ * onwards (implicit relative imports raised a DeprecationWarning in 2.6,
+ * and fail in 2.7 onwards).
+ *
+- * First check for __package__ which is available from 2.6 onwards, see PEP366.
++ * First check for __spec__.parent which is available from 3.4 onwards,
++ * see https://docs.python.org/3/reference/import.html#spec. If not,
++ * check for __package__, which was set before 3.14.
+ * Next try determine the shadow wrapper's package based on the __name__ it
+ * was given by the importer that loaded it.
+ * If the module is in a package, load the low-level C/C++ module from the
+ * same package, otherwise load it as a global module.
+ */
+ Printv(default_import_code, "# Import the low-level C/C++ module\n", NULL);
+- Printv(default_import_code, "if __package__ or \".\" in __name__:\n", NULL);
++ Printv(default_import_code, "if getattr(globals().get(\"__spec__\"), \"parent\", None) or globals().get(\"__package__\") or \".\" in __name__:\n", NULL);
+ Printv(default_import_code, tab4, "from . import ", module, "\n", NULL);
+ Printv(default_import_code, "else:\n", NULL);
+ Printv(default_import_code, tab4, "import ", module, "\n", NULL);
+ } else {
+ Printv(default_import_code, "# Pull in all the attributes from the low-level C/C++ module\n", NULL);
+- Printv(default_import_code, "if __package__ or \".\" in __name__:\n", NULL);
++ Printv(default_import_code, "if getattr(globals().get(\"__spec__\"), \"parent\", None) or globals().get(\"__package__\") or \".\" in __name__:\n", NULL);
+ Printv(default_import_code, tab4, "from .", module, " import *\n", NULL);
+ Printv(default_import_code, "else:\n", NULL);
+ Printv(default_import_code, tab4, "from ", module, " import *\n", NULL);
+
+From 3bfdf13c602f877860a9949ba751a5b5a9ba70aa Mon Sep 17 00:00:00 2001
+From: Julien Schueller
+Date: Thu, 10 Apr 2025 18:35:25 +0200
+Subject: [PATCH 2/3] Python: Add ht_token
+
+---
+ Source/Modules/python.cxx | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
+index a71fc3cdb25..3070a94face 100644
+--- a/Source/Modules/python.cxx
++++ b/Source/Modules/python.cxx
+@@ -4374,6 +4374,11 @@ class PYTHON:public Language {
+ Printv(f, "#if PY_VERSION_HEX >= 0x030b0000\n", NIL);
+ printSlot(f, getSlot(n, "feature:python:_ht_tpname"), "_ht_tpname", "char *");
+
++ // void *ht_token;
++ Printv(f, "#if PY_VERSION_HEX >= 0x030e0000\n", NIL);
++ printSlot(f, getSlot(n, "feature:python:ht_token"), "ht_token", "void *");
++ Printv(f, "#endif\n", NIL);
++
+ // struct _specialization_cache _spec_cache;
+ Printf(f, " {\n");
+ printSlot(f, getSlot(n, "feature:python:getitem"), "getitem", "PyObject *");
+
+From 55237efa7219f65a04e0ffc69a81c574b5f5e162 Mon Sep 17 00:00:00 2001
+From: Julien Schueller
+Date: Thu, 10 Apr 2025 17:47:59 +0200
+Subject: [PATCH 3/3] Python: Amend annotations test
+
+---
+ .../python_annotations_variable_c_runme.py | 24 +++++++++++++------
+ 1 file changed, 17 insertions(+), 7 deletions(-)
+
+diff --git a/Examples/test-suite/python/python_annotations_variable_c_runme.py b/Examples/test-suite/python/python_annotations_variable_c_runme.py
+index 153852d05e6..d1f359bbbd0 100644
+--- a/Examples/test-suite/python/python_annotations_variable_c_runme.py
++++ b/Examples/test-suite/python/python_annotations_variable_c_runme.py
+@@ -1,4 +1,17 @@
+ import sys
++import inspect
++
++
++def get_annotations(cls):
++ # Python >=3.14 removed the __annotations__ attribute
++ # retrieve it via inspect (see also annotationlib)
++ if hasattr(inspect, "get_annotations"):
++ # Python >=3.10
++ return inspect.get_annotations(cls)
++ else:
++ # Python <3.10
++ return getattr(cls, "__annotations__", {})
++
+
+ # Variable annotations for properties is only supported in python-3.6 and later (PEP 526)
+ if sys.version_info[0:2] >= (3, 6):
+@@ -8,17 +21,14 @@
+ annotations_supported = not(is_python_builtin() or is_python_fastproxy())
+
+ if annotations_supported:
+- ts = TemplateShort()
+- anno = ts.__annotations__
++ anno = get_annotations(TemplateShort)
+ if anno != {'member_variable': 'int'}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
+- ts = StructWithVar()
+- anno = ts.__annotations__
++ anno = get_annotations(StructWithVar)
+ if anno != {'member_variable': 'int'}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
+- ts = StructWithVarNotAnnotated()
+- if getattr(ts, "__annotations__", None) != None:
+- anno = ts.__annotations__
++ anno = get_annotations(StructWithVarNotAnnotated)
++ if anno != {}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
diff --git a/swig.spec b/swig.spec
index 996ead8..0b7b0f9 100644
--- a/swig.spec
+++ b/swig.spec
@@ -3,48 +3,64 @@
%if %{without testsuite}
%global tcl 0
+%global guile 0
%global lualang 0
+%global perllang 0
%global phplang 0
%global rubylang 0
-%global python2lang 0
%global python3lang 0
%global golang 0
%global octave 0
%global Rlang 0
%global javalang 0
+%global ocamllang 0
%endif
%{!?tcl:%global tcl 1}
-%{!?guile:%global guile 0}
%{!?lualang:%global lualang 1}
-%{!?phplang:%global phplang 1}
-# Disable Ruby test failed with swig 4.0.0 on s390
-%ifarch s390x
-%{!?rubylang:%global rubylang 0}
-%else
+%{!?perllang:%global perllang 1}
%{!?rubylang:%global rubylang 1}
-%endif
-%{!?python2lang:%global python2lang 1}
%{!?python3lang:%global python3lang 1}
+# PHP drop support for 32-bit builds since Fedora 41.
+%if 0%{?fedora} >= 41 || 0%{?rhel} >= 11
+%ifarch %{ix86}
+%global phplang 0
+%endif
+%endif
+%{!?phplang:%global phplang 1}
+
+# OCaml packages not built on i686 since OCaml 5 / Fedora 39.
+%ifarch %{ix86}
+%{!?ocamllang:%global ocamllang 0}
+%else
+%{!?ocamllang:%global ocamllang 1}
+%endif
+
%if 0%{?rhel}
%{!?golang:%global golang 0}
+%{!?guile:%global guile 0}
%{!?octave:%global octave 0}
%{!?Rlang:%global Rlang 0}
%bcond_with build_ccache_swig
%else
+%{!?guile:%global guile 1}
%{!?octave:%global octave 1}
-%{!?Rlang:%global Rlang 1}
+# R-core requires tcl < 9.0.0
+%{!?Rlang:%global Rlang 0}
%bcond_without build_ccache_swig
%endif
-%ifarch aarch64 %{arm} %{mips} ppc64le ppc %{power64} s390 s390x
+
+%ifarch %{ix86}
%{!?javalang:%global javalang 0}
%else
+# Temporary disable java tests, because they doesn't pass with java-21-openjdk
+# https://github.com/swig/swig/issues/2767
%{!?javalang:%global javalang 1}
%endif
-# Do not run Go tests, they failed with 4.0.0 on ppc64le
-%ifarch %{ix86} x86_64 %{arm} aarch64
+# Do not run Go tests, they failed with 4.0.0 on ppc64le, s390
+%ifarch x86_64 %{arm} aarch64
%{!?golang:%global golang 1}
%else
%{!?golang:%global golang 0}
@@ -52,10 +68,10 @@
Summary: Connects C/C++/Objective C to some high-level programming languages
Name: swig
-Version: 4.0.1
-Release: 7%{?dist}
-License: GPLv3+ and BSD
-URL: http://swig.sourceforge.net/
+Version: 4.4.1
+Release: 1%{?dist}
+License: GPL-3.0-or-later AND BSD-3-Clause
+URL: https://www.swig.org/
Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz
# Define the part of man page sections
Source1: description.h2m
@@ -65,25 +81,15 @@ Source3: ccache-swig.sh
Source4: ccache-swig.csh
%endif
-Patch0: swig308-Do-not-use-isystem.patch
-# Fix code generated for Ruby global variables
-# https://github.com/swig/swig/issues/1668
-Patch1: swig-4.0.1-Fix-code-generated-for-Ruby-global-variables.patch
-# Add support for Ruby 2.7
-# https://github.com/swig/swig/pull/1692
-Patch2: swig-4.0.1-Add-support-for-Ruby-2.7.patch
-# Fix crash in Python backend when using empty docstrings
-# https://github.com/swig/swig/pull/1710
-Patch3: swig-4.0.1-Fix-crash-in-Python-backend-when-using-empty-docstrings.patch
-
-BuildRequires: perl-interpreter, pcre-devel
-%if %{python2lang}
-BuildRequires: python2-devel
-%endif
+BuildRequires: coreutils
+BuildRequires: findutils
+BuildRequires: make
+BuildRequires: perl-interpreter, pcre2-devel
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: autoconf, automake, gawk, dos2unix
BuildRequires: gcc-c++
BuildRequires: help2man
+BuildRequires: sed
BuildRequires: perl-devel
BuildRequires: perl(base)
BuildRequires: perl(Config)
@@ -99,7 +105,7 @@ BuildRequires: boost-devel
# Need when Source/CParse/parser.y is patched
BuildRequires: bison
%if %{tcl}
-BuildRequires: tcl-devel
+BuildRequires: tcl-devel >= 9.0.0
%endif
%if %{guile}
BuildRequires: guile-devel
@@ -110,7 +116,9 @@ BuildRequires: octave-devel
%if %{golang}
BuildRequires: golang
BuildRequires: golang-bin
+%ifnarch s390x
BuildRequires: golang-shared
+%endif
BuildRequires: golang-src
%endif
%if %{lualang}
@@ -128,6 +136,10 @@ BuildRequires: java, java-devel
%if %{phplang}
BuildRequires: php, php-devel
%endif
+%if %{ocamllang}
+BuildRequires: ocaml
+BuildRequires: ocaml-findlib
+%endif
%description
Simplified Wrapper and Interface Generator (SWIG) is a software
@@ -145,7 +157,7 @@ testing and prototyping C/C++ software.
%if %{with build_ccache_swig}
%package -n ccache-swig
Summary: Fast compiler cache
-License: GPLv2+
+License: GPL-2.0-or-later
Requires: swig
Conflicts: swig < 3.0.8-2
@@ -157,7 +169,7 @@ being done again. ccache-swig is ccache plus support for SWIG.
%package doc
Summary: Documentation files for SWIG
-License: BSD
+License: BSD-3-Clause
BuildArch: noarch
%description doc
@@ -165,7 +177,7 @@ This package contains documentation for SWIG and useful examples
%package gdb
Summary: Commands for easier debugging of SWIG
-License: BSD
+License: BSD-3-Clause
Requires: swig
%description gdb
@@ -173,12 +185,7 @@ This package contains file with commands for easier debugging of SWIG
in gdb.
%prep
-%setup -q -n swig-%{version}
-
-%patch0 -p1 -b .isystem
-%patch1 -p1 -b .global
-%patch2 -p1 -b .ruby27
-%patch3 -p1 -b .python
+%autosetup -p1
for all in CHANGES README; do
iconv -f ISO88591 -t UTF8 < $all > $all.new
@@ -193,22 +200,24 @@ done
# code produces lots of the warnings demanded by strict ISO C and ISO C++.
# It causes that log had more then 600M.
%configure \
- --without-ocaml \
-%if %{python2lang}
- --with-python=%__python2\
+%if %{ocamllang}
+ --with-ocaml \
%else
- --without-python \
+ --without-ocaml \
%endif
%if %{python3lang}
- --with-python3=%__python3 \
+ --with-python3=python3 \
%else
--without-python3 \
%endif
%if %{phplang}
- --with-php=%{__php} \
+ --with-php \
%else
--without-php \
%endif
+%if ! %{perllang}
+ --without-perl5 \
+%endif
%if ! %{tcl}
--without-tcl \
%endif
@@ -221,19 +230,22 @@ done
%if ! %{golang}
--without-go \
%endif
+%if ! %{guile}
+ --without-guile \
+%endif
%if %{octave}
- --with-octave=/usr/bin/octave \
+ --with-octave=%{_bindir}/octave \
--without-maximum-compile-warnings \
%endif
%if %{without build_ccache_swig}
--disable-ccache \
%endif
;
-make %{?_smp_mflags}
+%{make_build}
%if %{with testsuite}
# Test suite
-make check
+make check PY3=1
%endif
%install
@@ -256,7 +268,7 @@ for all in `find -type f`; do
done
popd
-make DESTDIR=%{buildroot} install
+%{make_install}
#################################################
# Use help output for generating of man page swig
@@ -351,6 +363,190 @@ install -pm 644 Tools/swig.gdb %{buildroot}%{_datadir}/%{name}/gdb
%{_datadir}/%{name}/gdb
%changelog
+* Mon Dec 08 2025 Jitka Plesnikova - 4.4.1-1
+- 4.4.1 bump (rhbz#2419819, rhbz#2415440)
+
+* Tue Oct 21 2025 Jitka Plesnikova - 4.4.0-1
+- 4.4.0 bump (rhbz#2405182)
+
+* Mon Oct 13 2025 Richard W.M. Jones - 4.3.1-6
+- OCaml 5.4.0 rebuild
+
+* Thu Aug 07 2025 Orion Poplawski - 4.3.1-5
+- Rebuild for Octave 10.2
+
+* Thu Jul 31 2025 Jitka Plesnikova - 4.3.1-4
+- Fix Python DeprecationWarning
+
+* Fri Jul 25 2025 Fedora Release Engineering - 4.3.1-3
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
+
+* Wed Jun 25 2025 Yaakov Selkowitz - 4.3.1-2
+- Add Python 3.14 support
+
+* Wed Apr 16 2025 Jitka Plesnikova - 4.3.1-1
+- 4.3.1 bump (rhbz#2360009)
+
+* Mon Feb 17 2025 Jitka Plesnikova - 4.3.0-5
+- Disable R tests, because they need tcl < 9
+
+* Sun Jan 19 2025 Fedora Release Engineering - 4.3.0-4
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
+
+* Thu Nov 14 2024 Orion Poplawski - 4.3.0-3
+- Rebuild for octave 9.2
+
+* Tue Oct 29 2024 Jitka Plesnikova - 4.3.0-2
+- Fix precedence of casts
+
+* Mon Oct 21 2024 Jitka Plesnikova - 4.3.0-1
+- 4.3.0 bump (rhbz#2320047)
+
+* Sat Jul 20 2024 Fedora Release Engineering - 4.2.1-8
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
+
+* Sun Jun 23 2024 Yaakov Selkowitz - 4.2.1-7
+- Rebuild for Python 3.13
+
+* Wed Jun 19 2024 Richard W.M. Jones - 4.2.1-6
+- OCaml 5.2.0 ppc64le fix
+
+* Wed May 29 2024 Richard W.M. Jones - 4.2.1-5
+- OCaml 5.2.0 for Fedora 41
+
+* Mon Apr 29 2024 Jitka Plesnikova - 4.2.1-4
+- Fix gcc's -Wformat-security warning in R Raise function (rhbz#2277767)
+
+* Fri Apr 12 2024 Remi Collet - 4.2.1-3
+- disable PHP support on 32-bit
+ https://fedoraproject.org/wiki/Changes/php_no_32_bit
+
+* Tue Feb 27 2024 Jiri Vanek - 4.2.1-2
+- Rebuilt for java-21-openjdk as system jdk
+- Temporary disable java tests (rhbz#2266693)
+
+* Mon Feb 26 2024 Jitka Plesnikova - 4.2.1-1
+- 4.2.1 bump (rhbz#2265786)
+
+* Tue Jan 23 2024 Jitka Plesnikova - 4.2.0-1
+- 4.2.0 bump
+
+* Mon Dec 18 2023 Richard W.M. Jones - 4.1.1-15
+- OCaml 5.1.1 + s390x code gen fix for Fedora 40
+
+* Tue Dec 12 2023 Richard W.M. Jones - 4.1.1-14
+- OCaml 5.1.1 rebuild for Fedora 40
+
+* Thu Dec 07 2023 Jitka Plesnikova - 4.1.1-13
+- Fix PHP director_classes testcase failures on x86
+
+* Fri Oct 20 2023 Jitka Plesnikova - 4.1.1-12
+- Stop using Python's 2to3
+
+* Wed Oct 11 2023 Jitka Plesnikova - 4.1.1-11
+- Fix PHP test, it fails with PHP 8.3
+
+* Thu Oct 05 2023 Richard W.M. Jones - 4.1.1-10
+- OCaml 5.1 rebuild for Fedora 40
+
+* Sat Jul 22 2023 Fedora Release Engineering - 4.1.1-9
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
+
+* Wed Jul 12 2023 Jerry James - 4.1.1-8
+- Add patch for python 3.12
+
+* Tue Jul 11 2023 Richard W.M. Jones - 4.1.1-8
+- OCaml 5.0 rebuild for Fedora 39
+
+* Tue Jun 20 2023 Jerry James - 4.1.1-7
+- Enable OCaml support
+- Add patch for OCaml 5.0.0
+
+* Sat Apr 08 2023 Orion Poplawski - 4.1.1-6
+- Rebuild with octave 8.1.0
+
+* Thu Mar 16 2023 Orion Poplawski - 4.1.1-5
+- Add patch to support octave 8.1
+
+* Thu Feb 02 2023 Jitka Plesnikova - 4.1.1-4
+- Disable PHP test on i686
+
+* Sat Jan 21 2023 Fedora Release Engineering - 4.1.1-3
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
+
+* Thu Jan 12 2023 Florian Weimer - 4.1.1-2
+- Port configure script to C99
+
+* Thu Dec 01 2022 Jitka Plesnikova - 4.1.1-1
+- Update to 4.1.1
+
+* Tue Oct 25 2022 Jitka Plesnikova - 4.1.0-1
+- Update to 4.1.0
+
+* Thu Jul 21 2022 Maxwell G - 4.0.2-18
+- Exclude golang extension from i686
+
+* Tue Jul 19 2022 Maxwell G - 4.0.2-17
+- Rebuild for CVE-2022-{1705,32148,30631,30633,28131,30635,30632,30630,1962} in
+ golang
+
+* Sat Jun 18 2022 Robert-André Mauchin - 4.0.2-16
+- Rebuilt for CVE-2022-1996, CVE-2022-24675, CVE-2022-28327, CVE-2022-27191,
+ CVE-2022-29526, CVE-2022-30629
+
+* Wed Jun 01 2022 Orion Poplawski - 4.0.2-15
+- Rebuild for octave 7.1
+
+* Thu Feb 24 2022 Jitka Plesnikova - 4.0.2-14
+- Disable Java tests
+
+* Sat Jan 22 2022 Jitka Plesnikova - 4.0.2-13
+- Fix tests against GCC12, enable Guile tests
+
+* Sat Jan 22 2022 Fedora Release Engineering - 4.0.2-12
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
+
+* Wed Nov 24 2021 Jitka Plesnikova - 4.0.2-11
+- Disable PHP test, it fails with PHP 8.1
+
+* Thu Oct 07 2021 Jitka Plesnikova - 4.0.2-10
+- Enable Python tests
+
+* Tue Aug 10 2021 Orion Poplawski - 4.0.2-9
+- Rebuild for octave 6.3.0
+
+* Fri Jul 23 2021 Fedora Release Engineering - 4.0.2-8
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
+
+* Thu Jul 15 2021 Jitka Plesnikova - 4.0.2-7
+- Disable Python tests, they fail with 3.10.0~b2
+
+* Mon May 31 2021 Orion Poplawski - 4.0.2-6
+- Add patch for octave 6 support (bz#1919617)
+
+* Fri Mar 05 2021 Jitka Plesnikova - 4.0.2-5
+- Backport support of PHP8 from upstream
+
+* Wed Jan 27 2021 Fedora Release Engineering - 4.0.2-4
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
+
+* Fri Aug 28 2020 Jitka Plesnikova - 4.0.2-3
+- Enable tests for Python 3
+
+* Wed Jul 29 2020 Tom Stellard - 4.0.2-2
+- Use make macros
+ https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
+- Disable Go tests
+
+* Mon Jun 08 2020 Jitka Plesnikova - 4.0.2-1
+- Update to 4.0.2
+
+* Fri Mar 06 2020 Jitka Plesnikova - 4.0.1-9
+- Remove BR for Python 2 (bug#1807547)
+
+* Tue Feb 25 2020 Peter Robinson - 4.0.1-8
+- Add fix for newer NodeJS version
+
* Tue Feb 04 2020 Michael Jeanson - 4.0.1-7
- Fix crash in Python backend when using empty docstrings
diff --git a/swig308-Do-not-use-isystem.patch b/swig308-Do-not-use-isystem.patch
deleted file mode 100644
index efd0312..0000000
--- a/swig308-Do-not-use-isystem.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -up swig-3.0.8/configure.ac.orig swig-3.0.8/configure.ac
---- swig-3.0.8/configure.ac.orig 2016-02-02 16:01:09.094852303 +0100
-+++ swig-3.0.8/configure.ac 2016-02-02 16:01:42.096702679 +0100
-@@ -118,7 +118,8 @@ AC_SUBST(BOOST_CPPFLAGS)
- dnl How to specify include directories that may be system directories.
- # -I should not be used on system directories (GCC)
- if test "$GCC" = yes; then
-- ISYSTEM="-isystem "
-+# ISYSTEM="-isystem "
-+ ISYSTEM="-I"
- else
- ISYSTEM="-I"
- fi