diff --git a/bdsf/multi_proc.py b/bdsf/multi_proc.py index 049b447..9d3c010 100644 --- a/bdsf/multi_proc.py +++ b/bdsf/multi_proc.py @@ -8,31 +8,24 @@ (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() +# Set the start method to "fork". Other methods don't work with our codebase. +multiprocessing.set_start_method('fork') __all__ = ('parallel_map',) 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" \