Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions bdsf/multi_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',)

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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" \
Expand Down