Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 May 2026 02:43:09 +0000
From:      Yuri Victorovich <yuri@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: cc56436f36d9 - main - devel/py-swig: New port: Python wrapper for the SWIG code generation tool
Message-ID:  <6a17abbd.27afd.3e627078@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cc56436f36d9824228c5e4ed72ab8393d2daa1dd

commit cc56436f36d9824228c5e4ed72ab8393d2daa1dd
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-05-28 00:41:48 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-05-28 02:43:02 +0000

    devel/py-swig: New port: Python wrapper for the SWIG code generation tool
---
 devel/Makefile                                     |  1 +
 devel/py-swig/Makefile                             | 25 +++++++++
 devel/py-swig/distinfo                             |  3 ++
 devel/py-swig/files/patch-pyproject.toml           | 63 ++++++++++++++++++++++
 devel/py-swig/files/patch-src_swig_____init____.py | 36 +++++++++++++
 devel/py-swig/pkg-descr                            |  6 +++
 6 files changed, 134 insertions(+)

diff --git a/devel/Makefile b/devel/Makefile
index 137f4008c23a..9475470525b9 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -6173,6 +6173,7 @@
     SUBDIR += py-super-collections
     SUBDIR += py-sure
     SUBDIR += py-swagger-spec-validator
+    SUBDIR += py-swig
     SUBDIR += py-sybil
     SUBDIR += py-synr
     SUBDIR += py-syrupy
diff --git a/devel/py-swig/Makefile b/devel/py-swig/Makefile
new file mode 100644
index 000000000000..0368a828fe7c
--- /dev/null
+++ b/devel/py-swig/Makefile
@@ -0,0 +1,25 @@
+PORTNAME=	swig
+DISTVERSION=	4.4.1
+CATEGORIES=	devel
+MASTER_SITES=	PYPI
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+DIST_SUBDIR=	python
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Python wrapper for the SWIG code generation tool
+WWW=		https://swig.org/ \
+		https://github.com/nightlark/swig-pypi
+
+LICENSE=	APACHE20
+
+RUN_DEPENDS=	swig:devel/swig
+
+USES=		python
+USE_PYTHON=	pep517 autoplist
+
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py-setuptools@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR}
+
+NO_ARCH=	yes
+
+.include <bsd.port.mk>
diff --git a/devel/py-swig/distinfo b/devel/py-swig/distinfo
new file mode 100644
index 000000000000..145ac84a0b2f
--- /dev/null
+++ b/devel/py-swig/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1779912709
+SHA256 (python/swig-4.4.1.tar.gz) = db9a625653f6454530a6c6553d17cf576d7aa2d253c76dc8cdd5979f0cb15012
+SIZE (python/swig-4.4.1.tar.gz) = 25956
diff --git a/devel/py-swig/files/patch-pyproject.toml b/devel/py-swig/files/patch-pyproject.toml
new file mode 100644
index 000000000000..4103f99a6abc
--- /dev/null
+++ b/devel/py-swig/files/patch-pyproject.toml
@@ -0,0 +1,63 @@
+-- Switch build backend from scikit-build-core to setuptools to avoid
+-- the complex CMake build that tries to download SWIG, PCRE2, and Bison
+-- from the internet. Instead, we use the system swig from devel/swig.
+
+--- pyproject.toml.orig	2022-11-09 12:37:21 UTC
++++ pyproject.toml
+@@ -1,6 +1,6 @@
+ [build-system]
+-requires = ["scikit-build-core"]
+-build-backend = "scikit_build_core.build"
++requires = ["setuptools>=61", "wheel"]
++build-backend = "setuptools.build_meta"
+ 
+ [project]
+ name = "swig"
+@@ -21,42 +21,15 @@ dynamic = ["version"]
+ ]
+ dynamic = ["version"]
+ 
++[tool.setuptools]
++package-dir = {"" = "src"}
++packages = {find = {where = ["src"]}}
+ 
+-[tool.scikit-build]
+-wheel.py-api = "py3"
+-wheel.expand-macos-universal-tags = true
+-metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
+-sdist.include = ["src/swig/_version.py"]
+-wheel.install-dir = "swig/data"
++[tool.setuptools.dynamic]
++version = {attr = "swig._version.__version__"}
+ 
+-[tool.cibuildwheel]
+-archs = ["auto64", "auto32"]
+-build = "cp39-*"
+-test-command = [
+-  "swig -version",
+-  "swig -pcreversion",
+-  "swig -help",
+-]
+-environment.PIP_ONLY_BINARY = ":all:"
+-
+-[tool.cibuildwheel.linux]
+-manylinux-x86_64-image = "quay.io/pypa/manylinux2010_x86_64:2022-08-05-4535177"
+-manylinux-i686-image = "quay.io/pypa/manylinux2010_i686:2022-08-05-4535177"
+-manylinux-aarch64-image = "manylinux2014"
+-manylinux-ppc64le-image = "manylinux2014"
+-manylinux-s390x-image = "manylinux2014"
+-manylinux-riscv64-image = "ghcr.io/mayeut/manylinux_2_31:2025.07.25-1"
+-
+-
+-[project.scripts]
+-swig = "swig:swig"
+-"swig4.0" = "swig:swig"
+-
+ [project.urls]
+ Homepage = "https://swig.org/"
+ Download = "https://swig.org/download.html"
+ "Source Code" = "https://github.com/nightlark/swig-pypi"
+ "Bug Tracker" = "https://github.com/nightlark/swig-pypi/issues"
+-
+-[tool.setuptools_scm]
+-version_file = "src/swig/_version.py"
diff --git a/devel/py-swig/files/patch-src_swig_____init____.py b/devel/py-swig/files/patch-src_swig_____init____.py
new file mode 100644
index 000000000000..6939862cde6b
--- /dev/null
+++ b/devel/py-swig/files/patch-src_swig_____init____.py
@@ -0,0 +1,36 @@
+-- Replace the bundled swig binary lookup with a call to the system swig
+-- installed by devel/swig. This avoids duplicating the swig binary and
+-- instead provides a thin Python wrapper around the installed system swig.
+
+--- src/swig/__init__.py.orig	2026-05-27 20:12:44 UTC
++++ src/swig/__init__.py
+@@ -1,23 +1,15 @@
+-import os
+-import platform
+ import subprocess
+ import sys
+-import glob
++import shutil
+ from ._version import __version__, __version_tuple__
+ 
+-DATA = os.path.join(os.path.dirname(__file__), "data")
+ 
+-BIN_DIR = os.path.join(DATA, "bin")
+-SWIG_SHARE_DIR = os.path.join(DATA, "share" + os.path.sep + "swig")
+-
+-# should only be one swig_lib version in the data subfolder
+-# make nicer if swig adds support for custom SWIG_LIB paths or relative swig_lib paths
+-SWIG_LIB_ENV = os.environ
+-SWIG_LIB_ENV["SWIG_LIB"] = glob.glob(SWIG_SHARE_DIR + os.path.sep + "*")[0]
+-
+-
+ def _program(name, args):
+-    return subprocess.call([os.path.join(BIN_DIR, name)] + args, env=SWIG_LIB_ENV)
++    swig_path = shutil.which(name)
++    if swig_path is None:
++        print(f"swig: {name}: command not found", file=sys.stderr)
++        return 1
++    return subprocess.call([swig_path] + args)
+ 
+ 
+ def swig():
diff --git a/devel/py-swig/pkg-descr b/devel/py-swig/pkg-descr
new file mode 100644
index 000000000000..420cbd829226
--- /dev/null
+++ b/devel/py-swig/pkg-descr
@@ -0,0 +1,6 @@
+This Python package provides a thin wrapper around the SWIG code generation
+tool, making it available as a Python console script and module. It delegates
+to the system-installed swig binary from devel/swig.
+
+SWIG is a software development tool that connects programs written in C and
+C++ with a variety of high-level programming languages.


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a17abbd.27afd.3e627078>