Skip to content

Commit

Permalink
Merge pull request #2166 from kif/2162_openmp
Browse files Browse the repository at this point in the history
Options to force-disable openmp
  • Loading branch information
kif authored May 17, 2024
2 parents b97fbbc + 1ff9328 commit b04f286
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ jobs:
env:
# Use silx wheelhouse: needed for ppc64le
CIBW_ENVIRONMENT_LINUX: "PIP_FIND_LINKS=https://www.silx.org/pub/wheelhouse/ PIP_TRUSTED_HOST=www.silx.org"
# diable OpenMP under windows
CIBW_ENVIRONMENT_WINDOWS: >
CIBW_BEFORE_BUILD="${{ echo False > PYFAI_WITH_OPENMP }}"
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* cp311-* cp312-*
# Do not build for pypy and muslinux
Expand All @@ -125,7 +128,7 @@ jobs:
CIBW_TEST_COMMAND: python -c "import pyFAI.test, sys; sys.exit(pyFAI.test.run_tests())"
# Skip tests for emulated architectures
# and Python3.8 on macos/arm64 (https://github.com/pypa/cibuildwheel/pull/1169)
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x} cp38-macosx_arm64 cp3*-win_amd64"
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x} cp38-macosx_arm64"
WITH_QT_TEST: "False" # skip GUI tests
PYFAI_OPENCL: "False" # skip GPU tests
PYFAI_LOW_MEM: "True" # skip all tests >100Mb
Expand Down
1 change: 0 additions & 1 deletion bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def build_project(name, root_dir):
libdir = "lib"
if sys.platform == "win32":
libdir = "Lib"
# extra = ["--buildtype", "plain"]

build = os.path.join(root_dir, "build")
if not(os.path.isdir(build) and os.path.isdir(os.path.join(build, name))):
Expand Down
12 changes: 11 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('pyFAI',
'c', 'cpp', 'cython',
license: 'MIT',
meson_version: '>= 0.60',
meson_version: '>= 1.1',
version: run_command(['version.py', '--wheel'],
check:true).stdout().strip(),
default_options: ['buildtype=plain', ],
Expand All @@ -13,6 +13,16 @@ if meson.backend() != 'ninja'
error('Ninja backend required')
endif

# Read configuration files to disable OpenMP:
# 'PYFAI_WITH_OPENMP' file should contain 'False'
os = import('fs')
if os.is_file('PYFAI_WITH_OPENMP')
openmp_var = os.read('PYFAI_WITH_OPENMP').strip()
else
openmp_var = ''
endif


cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
cy = meson.get_compiler('cython')
Expand Down
2 changes: 2 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
option('use_openmp', type : 'feature', value : 'auto',
description : 'force enable/disable the usage of OpenMP')
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ dependencies = [
build-backend = 'mesonpy'
requires = [
'meson-python>=0.11',
"meson>=0.64; platform_system=='Windows'",
"meson>=0.60; platform_system!='Windows'",
"meson>=1.1",
'ninja',
'wheel',
'oldest-supported-numpy',
Expand Down
8 changes: 6 additions & 2 deletions src/pyFAI/ext/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# OpenMP can be used
omp = dependency('openmp', required : false)
# OpenMP can be used? several ways to disable it:
# -> use -Duse_openmp=disabled
# -> or the file PYFAI_WITH_OPENMP should contain False
# -> or OpenMP can be unsuported on your achitecture/compiler

omp = dependency('openmp', required: get_option('use_openmp').disable_auto_if(openmp_var=='False'))

py.install_sources(['__init__.py'],
pure: false, # Will be installed next to binaries
Expand Down

0 comments on commit b04f286

Please sign in to comment.