From 018bda0a32db419e742d81b6f65269c6c39b2f9c Mon Sep 17 00:00:00 2001 From: Marcel Loose Date: Thu, 30 Oct 2025 18:01:44 +0100 Subject: [PATCH 1/3] Fix binary wheel build for Python 3.14 In Python 3.14, the default method that `multiprocessing` uses to start a process on POSIX platforms changed from `fork` to `forkserver`. We cannot use `forkserver`, unless we restructure our code, so we need to explicitly set the start method to `fork` when running on Linux using Python 3.14 or later. --- bdsf/multi_proc.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/bdsf/multi_proc.py b/bdsf/multi_proc.py index 049b447..182361c 100644 --- a/bdsf/multi_proc.py +++ b/bdsf/multi_proc.py @@ -8,30 +8,31 @@ (http://www.astropython.org/snippet/2010/3/Parallel-map-using-multiprocessing). """ -from __future__ import print_function -import traceback -import sys + +import multiprocessing import os +import sys +import traceback + import numpy -import multiprocessing -_ncpus = 1 - -# Get the number of available cores. We use os.sched_getaffinity() for this if -# possible, as the number of available cores may be less than the total number -# of CPU cores in the machine, which is returned by, e.g., -# multiprocessing.cpu_count() -# -# Note: since macOS (Darwin) does not support os.sched_getaffinity(), we use -# multiprocessing.cpu_count() instead -if sys.platform == 'darwin': - if sys.version_info[0] == 3 and sys.version_info[1] >= 8: - # We need to set spawn method to "fork" for macOS on Python 3.8+ where - # the default has been changed to "spawn", causing problems (see the - # discussion at https://github.com/ipython/ipython/issues/12396) - multiprocessing.set_start_method('fork') - _ncpus = multiprocessing.cpu_count() -else: + +# Try to determine the number of CPU cores _available_ to the current process, +# similar to what the Linux `nproc` command does. If that fails, return the +# total number of CPU cores in the machine. +try: _ncpus = len(os.sched_getaffinity(0)) +except AttributeError: + _ncpus = multiprocessing.cpu_count() + +if sys.platform == 'darwin' and sys.version_info >= (3, 8): + # We need to set spawn method to "fork" for macOS on Python 3.8+ where + # the default has been changed to "spawn", causing problems (see the + # discussion at https://github.com/ipython/ipython/issues/12396) + multiprocessing.set_start_method('fork') +elif sys.platform == 'linux' and sys.version_info >= (3, 14): + # In Python 3.14, the default start method changed from "fork" to + # "forkserver" on Unix-like systems, but we need "fork". + multiprocessing.set_start_method('fork') __all__ = ('parallel_map',) From 0ce606f91101edb00da6da3605417bed8b905137 Mon Sep 17 00:00:00 2001 From: Marcel Loose Date: Thu, 30 Oct 2025 18:13:20 +0100 Subject: [PATCH 2/3] Add binary wheels for Python 3.14 --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9760c32..2bed944 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Scientific/Engineering :: Astronomy", ] dependencies = [ @@ -75,7 +76,7 @@ Documentation = "https://pybdsf.readthedocs.io" [tool.cibuildwheel] before-all = "cibuildwheel/before_all.sh" before-build = "cibuildwheel/before_build.sh" -build = "cp3{9,10,11,12,13}-*" +build = "cp3{9,10,11,12,13,14}-*" build-verbosity = 1 environment = """ \ BOOST_VERSION="1.87.0" \ From f46bf24d5ba7aac4c15c4eb1a4c50e151a68b0ae Mon Sep 17 00:00:00 2001 From: Marcel Loose Date: Mon, 3 Nov 2025 11:39:46 +0100 Subject: [PATCH 3/3] Always use 'fork' as start method in multiprocessing --- bdsf/multi_proc.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/bdsf/multi_proc.py b/bdsf/multi_proc.py index 182361c..9d3c010 100644 --- a/bdsf/multi_proc.py +++ b/bdsf/multi_proc.py @@ -24,16 +24,8 @@ except AttributeError: _ncpus = multiprocessing.cpu_count() -if sys.platform == 'darwin' and sys.version_info >= (3, 8): - # We need to set spawn method to "fork" for macOS on Python 3.8+ where - # the default has been changed to "spawn", causing problems (see the - # discussion at https://github.com/ipython/ipython/issues/12396) - multiprocessing.set_start_method('fork') -elif sys.platform == 'linux' and sys.version_info >= (3, 14): - # In Python 3.14, the default start method changed from "fork" to - # "forkserver" on Unix-like systems, but we need "fork". - multiprocessing.set_start_method('fork') - +# Set the start method to "fork". Other methods don't work with our codebase. +multiprocessing.set_start_method('fork') __all__ = ('parallel_map',)