Skip to content

Commit f21613c

Browse files
committed
Try to use pkgconf-pypi for blas dependency
1 parent 4fb7760 commit f21613c

4 files changed

Lines changed: 31 additions & 84 deletions

File tree

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ for more details.
8686
.. code-block:: bash
8787
8888
pip install --group dev --group blas
89-
pip install --editable . \
89+
FORCE_PKGCONF_PYPI=1 pip install --editable . \
9090
--no-build-isolation \
9191
--config-settings=editable-verbose=true \
9292
--config-settings=setup-args="-Dblas=enabled"

dwave/optimization/_build/_find_openblas.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

meson.build

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,12 @@ dwave_optimization_dependencies = []
6060
# Set up BLAS. _find_openblas.py will return the include directory, the library
6161
# directory and the library name.
6262
if not get_option('blas').disabled()
63-
blasinfo = run_command(
64-
['dwave/optimization/_build/_find_openblas.py'],
65-
capture: true,
66-
check: true
67-
).stdout().splitlines()
68-
if blasinfo.length() != 0
69-
assert(blasinfo.length() == 3, '_find_openblas.py returned an unexpected value')
70-
71-
dwave_optimization_dependencies += [
72-
declare_dependency(
73-
dependencies: cpp.find_library(
74-
blasinfo[2],
75-
dirs: blasinfo[1],
76-
required: true,
77-
),
78-
include_directories: blasinfo[0],
79-
)
80-
]
81-
elif get_option('blas').enabled()
82-
error(
83-
'No BLAS available.' +
84-
'Install scipy_openblas64 into the build environment or disable the blas user option'
85-
)
86-
endif
63+
blas = dependency(
64+
'scipy-openblas',
65+
method: 'pkg-config',
66+
required: get_option('blas').enabled(),
67+
)
68+
dwave_optimization_dependencies += [blas]
8769
endif
8870

8971
if host_machine.system() == 'windows'

pyproject.toml

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Documentation = "https://docs.dwavequantum.com"
5555
[dependency-groups]
5656
blas = [
5757
# Optional build requirement, last refreshed April 2026
58+
"pkgconf==2.5.1.post2",
5859
"scipy_openblas64==0.3.31.188.0",
5960
]
6061
build = [
@@ -93,20 +94,18 @@ test = [
9394

9495
[tool.cibuildwheel]
9596
build-verbosity = "1"
96-
skip = "pp* *musllinux*"
97+
skip = "*musllinux*"
9798

98-
# When building with cibuildwheel, we want scipy_openblas64 available to the
99-
# build step. There isn't (as of Dec 2025) a way to override the
100-
# build-system.requires so we need to build without isolation
101-
before-build = "pip install --group blas-build"
99+
before-build = "pip install --group build"
102100
build-frontend = { name = "build", args = ["--no-isolation"] }
103101

102+
# Customize the test running by installing our test requirements and by turning
103+
# on -Werror
104104
before-test = "pip install --group test"
105105
test-command = "python -Werror -m unittest discover {project}/tests/"
106106

107107
[tool.cibuildwheel.config-settings]
108108
compile-args = ["-v"]
109-
setup-args = ["-Dblas=enabled"] # require BLAS
110109

111110
[tool.cibuildwheel.linux]
112111
archs = "x86_64 aarch64"
@@ -115,11 +114,11 @@ archs = "x86_64 aarch64"
115114
# We follow NumPy and don't build universal wheels, see https://github.com/numpy/numpy/pull/20787
116115
archs = "x86_64 arm64"
117116

118-
# Lowest version that has the C++ features we want, see https://cibuildwheel.pypa.io/en/stable/cpp_standards/
119-
environment = "MACOSX_DEPLOYMENT_TARGET=10.13"
117+
environment = { MACOSX_DEPLOYMENT_TARGET = "10.13" }
120118

121119
[tool.cibuildwheel.windows]
122120
archs = "AMD64"
121+
123122
repair-wheel-command = [
124123
"pip install delvewheel",
125124
# We put the commands in an .sh so we can use bash
@@ -130,34 +129,33 @@ repair-wheel-command = [
130129
# For Python3.12+, rather than building individual wheels we build an abi3
131130
# wheel. 313t and 314t do not support abi wheels yet.
132131
select = "cp31[!01]-*" # uses fnmatch, will fail for 3.20+ but good enough for now
133-
build-frontend = { name = "build", args = ["-Csetup-args=-Dpython.allow_limited_api=true", "--no-isolation"] }
132+
133+
inherit.config-settings = "append"
134+
config-settings = { "setup-args" = ["-Dpython.allow_limited_api=true"] }
135+
134136
inherit.repair-wheel-command = "append"
135137
repair-wheel-command = [
136138
"pip install abi3audit",
137139
"abi3audit --strict --report {wheel}",
138140
]
139141

140142
[[tool.cibuildwheel.overrides]]
141-
select = "*-????linux_*"
142-
inherit.repair-wheel-command = "prepend"
143-
repair-wheel-command = "python /project/dwave/optimization/_build/_fix_rpath.py {wheel}"
143+
# For everything we build except macosx_x86_64, we want to include scipy-openblas
144+
select = "*-{????linux_*,macosx_arm64,win_*}"
144145

145-
[[tool.cibuildwheel.overrides]]
146-
select = "*-macosx_*"
147-
inherit.repair-wheel-command = "prepend"
148-
repair-wheel-command = "python ./dwave/optimization/_build/_fix_rpath.py {wheel}"
146+
inherit.environent = "append"
147+
environment = { FORCE_PKGCONF_PYPI = "1" }
148+
149+
inherit.before-build = "append"
150+
before-build = "pip install --group blas"
151+
152+
inhert.test-command = "append"
153+
test-command = "python -c \"from dwave.optimization.symbols import MatrixMultiply; assert(MatrixMultiply.implementation() == 'blas')\""
149154

150155
[[tool.cibuildwheel.overrides]]
151-
# We need a universal build of scipy_openblas so we need to make one on the fly
152-
select = "*-macosx_*"
153-
before-build = [
154-
"pip download --group blas -d .openblas_arm64 --platform macosx_11_0_arm64 --no-deps",
155-
"pip download --group blas -d .openblas_x86_64 --platform macosx_11_0_x86_64 --no-deps",
156-
"pip install delocate",
157-
"delocate-merge .openblas_x86_64/scipy_openblas*.whl .openblas_arm64/scipy_openblas*.whl -w .openblas",
158-
"pip install .openblas/scipy_openblas*.whl",
159-
"pip install --group build",
160-
]
156+
select = "*-{????linux,macosx}_*"
157+
inherit.repair-wheel-command = "prepend"
158+
repair-wheel-command = "python {project}/dwave/optimization/_build/_fix_rpath.py {wheel}"
161159

162160
[tool.coverage.run]
163161
source = ["dwave/optimization"]

0 commit comments

Comments
 (0)