git: 8f9a4da343b5 - main - devel/py-cibuildwheel: New port: Build Python wheels on CI with minimal configuration

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Mon, 31 Mar 2025 16:43:39 UTC
The branch main has been updated by yuri:

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

commit 8f9a4da343b5449cfed608ccab78994bf283d6f1
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2025-03-31 15:09:22 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2025-03-31 16:43:35 +0000

    devel/py-cibuildwheel: New port: Build Python wheels on CI with minimal configuration
---
 devel/Makefile                                     |  1 +
 devel/py-cibuildwheel/Makefile                     | 28 ++++++++++++++++++++++
 devel/py-cibuildwheel/distinfo                     |  3 +++
 .../files/patch-cibuildwheel_architecture.py       | 15 ++++++++++++
 devel/py-cibuildwheel/files/patch-test_utils.py    | 20 ++++++++++++++++
 ...-unit__test_main__tests_main__platform__test.py | 20 ++++++++++++++++
 devel/py-cibuildwheel/pkg-descr                    |  6 +++++
 7 files changed, 93 insertions(+)

diff --git a/devel/Makefile b/devel/Makefile
index d66582ed8d43..9cc824bb0dd4 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -4639,6 +4639,7 @@
     SUBDIR += py-check-sdist
     SUBDIR += py-check-wheel-contents
     SUBDIR += py-cheetah3
+    SUBDIR += py-cibuildwheel
     SUBDIR += py-circuitbreaker
     SUBDIR += py-circuits
     SUBDIR += py-ciso8601
diff --git a/devel/py-cibuildwheel/Makefile b/devel/py-cibuildwheel/Makefile
new file mode 100644
index 000000000000..34a5c9c0ef23
--- /dev/null
+++ b/devel/py-cibuildwheel/Makefile
@@ -0,0 +1,28 @@
+PORTNAME=	cibuildwheel # doesn't fully support FreeBSD
+DISTVERSION=	2.23.2
+CATEGORIES=	devel science
+MASTER_SITES=	PYPI
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Build Python wheels on CI with minimal configuration
+WWW=		https://cibuildwheel.pypa.io/en/stable \
+		https://github.com/pypa/cibuildwheel
+
+LICENSE=	BSD2CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	hatchling:devel/py-hatchling@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}bashlex>=0.13:devel/py-bashlex@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}bracex>0:textproc/py-bracex@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}certifi>0:security/py-certifi@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}dependency-groups>=1.2:devel/py-dependency-groups@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}filelock>=0:sysutils/py-filelock@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}packaging>=20.9:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}platformdirs>=0:devel/py-platformdirs@${PY_FLAVOR}
+
+USES=		python
+USE_PYTHON=	pep517 autoplist pytest
+
+.include <bsd.port.mk>
diff --git a/devel/py-cibuildwheel/distinfo b/devel/py-cibuildwheel/distinfo
new file mode 100644
index 000000000000..690aba1dcc65
--- /dev/null
+++ b/devel/py-cibuildwheel/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1743408200
+SHA256 (cibuildwheel-2.23.2.tar.gz) = fba11162a4c0b3c4f0f5302661abb2dccdb26b0e9449ea0389c5ff18d4ef0c55
+SIZE (cibuildwheel-2.23.2.tar.gz) = 295372
diff --git a/devel/py-cibuildwheel/files/patch-cibuildwheel_architecture.py b/devel/py-cibuildwheel/files/patch-cibuildwheel_architecture.py
new file mode 100644
index 000000000000..fe7bd19d3ac7
--- /dev/null
+++ b/devel/py-cibuildwheel/files/patch-cibuildwheel_architecture.py
@@ -0,0 +1,15 @@
+--- cibuildwheel/architecture.py.orig	2025-03-31 08:32:45 UTC
++++ cibuildwheel/architecture.py
+@@ -87,7 +87,11 @@ class Architecture(Enum):
+         host_platform: PlatformName = (
+             "windows"
+             if sys.platform.startswith("win")
+-            else ("macos" if sys.platform.startswith("darwin") else "linux")
++            else (
++                "macos" if sys.platform.startswith("darwin") else (
++                    "freebsd" if sys.platform.startswith("freebsd") else "linux"
++                )
++             )
+         )
+ 
+         native_machine = platform_module.machine()
diff --git a/devel/py-cibuildwheel/files/patch-test_utils.py b/devel/py-cibuildwheel/files/patch-test_utils.py
new file mode 100644
index 000000000000..7fbd93784d0a
--- /dev/null
+++ b/devel/py-cibuildwheel/files/patch-test_utils.py
@@ -0,0 +1,20 @@
+--- test/utils.py.orig	2025-03-31 08:27:36 UTC
++++ test/utils.py
+@@ -30,6 +30,8 @@ elif sys.platform.startswith("linux"):
+     pass
+ elif sys.platform.startswith("linux"):
+     platform = "linux"
++elif sys.platform.startswith("freebsd"):
++    platform = "freebsd"
+ elif sys.platform.startswith("darwin"):
+     platform = "macos"
+ elif sys.platform.startswith(("win32", "cygwin")):
+@@ -67,7 +69,7 @@ def _update_pip_cache_dir(env: dict[str, str]) -> None
+ def _update_pip_cache_dir(env: dict[str, str]) -> None:
+     # Fix for pip concurrency bug https://github.com/pypa/pip/issues/11340
+     # See https://github.com/pypa/cibuildwheel/issues/1254 for discussion.
+-    if platform == "linux":
++    if platform == "linux" or platform == "freebsd":
+         return
+     if "PIP_CACHE_DIR" in env:
+         return
diff --git a/devel/py-cibuildwheel/files/patch-unit__test_main__tests_main__platform__test.py b/devel/py-cibuildwheel/files/patch-unit__test_main__tests_main__platform__test.py
new file mode 100644
index 000000000000..d5148b3fcd42
--- /dev/null
+++ b/devel/py-cibuildwheel/files/patch-unit__test_main__tests_main__platform__test.py
@@ -0,0 +1,20 @@
+--- unit_test/main_tests/main_platform_test.py.orig	2025-03-31 08:24:58 UTC
++++ unit_test/main_tests/main_platform_test.py
+@@ -25,6 +25,8 @@ def test_platform_unset_or_auto(monkeypatch, intercept
+     # check that the platform was auto detected to build for the current system
+     if sys.platform.startswith("linux"):
+         assert options.platform == "linux"
++    elif sys.platform.startswith("freebsd"):
++        assert options.platform == "freebsd"
+     elif sys.platform == "darwin":
+         assert options.platform == "macos"
+     elif sys.platform == "win32":
+@@ -82,6 +84,8 @@ def test_archs_default(platform, intercepted_build_arg
+ 
+     if platform == "linux":
+         assert options.globals.architectures == {Architecture.x86_64, Architecture.i686}
++    elif platform == "freebsd":
++        assert options.globals.architectures == {Architecture.AMD64, Architecture.x86}
+     elif platform == "windows":
+         assert options.globals.architectures == {Architecture.AMD64, Architecture.x86}
+     else:
diff --git a/devel/py-cibuildwheel/pkg-descr b/devel/py-cibuildwheel/pkg-descr
new file mode 100644
index 000000000000..60f8256da939
--- /dev/null
+++ b/devel/py-cibuildwheel/pkg-descr
@@ -0,0 +1,6 @@
+cibuildwheel allows building Python wheels across Mac, Linux, Windows,
+on multiple versions of Python.
+
+cibuildwheel runs on your CI server - currently it supports GitHub Actions,
+Azure Pipelines, Travis CI, AppVeyor, CircleCI, and GitLab CI - and it builds
+and tests your wheels across all of your platforms.