10000 Merge pull request #24980 from rgommers/remove-ilp64-envvar · numpy/numpy@057ac96 · GitHub
[go: up one dir, main page]

Skip to content

Commit 057ac96

Browse files
authored
Merge pull request #24980 from rgommers/remove-ilp64-envvar
BLD: remove `NPY_USE_BLAS_ILP64` environment variable [wheel build]
2 parents d03d4ed + 26411a9 commit 057ac96

10 files changed

+27
-62
lines changed

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ stages:
9999
PYTHON_ARCH: 'x64'
100100
TEST_MODE: full
101101
BITS: 64
102-
NPY_USE_BLAS_ILP64: '1'
102+
_USE_BLAS_ILP64: '1'
103103
PyPy39-64bit-fast:
104104
PYTHON_VERSION: 'pypy3.9'
105105
PYTHON_ARCH: 'x64'
106106
TEST_MODE: fast
107107
BITS: 64
108-
NPY_USE_BLAS_ILP64: '1'
108+
_USE_BLAS_ILP64: '1'
109109

110110
steps:
111111
- template: azure-steps-windows.yml

azure-steps-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ steps:
2929
If ( Test-Path env:DISABLE_BLAS ) {
3030
python -m pip install . -v -Csetup-args="--vsenv" -Csetup-args="-Dblas=none" -Csetup-args="-Dlapack=none" -Csetup-args="-Dallow-noblas=true"
3131
}
32-
elseif ( Test-Path env:NPY_USE_BLAS_ILP64 ) {
32+
elseif ( Test-Path env:_USE_BLAS_ILP64 ) {
3333
python -m pip install scipy-openblas64 spin
3434
spin config-openblas --with-scipy-openblas=64
3535
$env:PKG_CONFIG_PATH="$pwd/.openblas"

numpy/linalg/lapack_litemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef CBLAS_INT fortran_int;
2727
#else
2828
#error No compatible 64-bit integer size. \
2929
Please contact NumPy maintainers and give detailed information about your \
30-
compiler and platform, or set NPY_USE_BLAS64_=0
30+
compiler and platform, or dont try to use ILP64 BLAS
3131
#endif
3232

3333
#else

numpy/meson.build

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ allow_noblas = get_option('allow-noblas')
5656
blas_symbol_suffix = get_option('blas-symbol-suffix')
5757

5858
use_ilp64 = get_option('use-ilp64')
59-
if not use_ilp64
60-
# TODO: clean this up
61-
# For now, keep supporting the `NPY_USE_BLAS_ILP64` environment variable too
62-
# `false` is the default for the CLI flag, so check if env var was set
63-
use_ilp64 = run_command(py,
64-
[
65-
'-c',
66-
'import os; print(1) if os.environ.get("NPY_USE_BLAS_ILP64", "0") != "0" else print(0)'
67-
],
68-
check: true
69-
).stdout().strip() == '1'
70-
endif
71-
7259
if use_ilp64
7360
blas_interface = ['interface: ilp64']
7461
else

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ test-command = "bash {project}/tools/wheels/cibw_test_command.sh {project}"
166166
manylinux-x86_64-image = "manylinux2014"
167167
manylinux-aarch64-image = "manylinux2014"
168168
musllinux-x86_64-image = "musllinux_1_1"
169-
environment = {CFLAGS="-fno-strict-aliasing", LDFLAGS="-Wl,--strip-debug", NPY_USE_BLAS_ILP64="1", RUNNER_OS="Linux"}
169+
environment = {CFLAGS="-fno-strict-aliasing", LDFLAGS="-Wl,--strip-debug", RUNNER_OS="Linux"}
170170

171171
[tool.cibuildwheel.macos]
172172
# For universal2 wheels, we will need to fuse them manually
@@ -177,11 +177,10 @@ environment = {CFLAGS="-fno-strict-aliasing", LDFLAGS="-Wl,--strip-debug", NPY_U
177177
archs = "x86_64 arm64"
178178
test-skip = "*_universal2:arm64"
179179
# MACOS linker doesn't support stripping symbols.
180-
# Note that NPY_USE_BLAS_ILP64 is used in `tools/openblas_support.py`.
181-
environment = {CFLAGS="-fno-strict-aliasing", CC="clang", CXX = "clang++", NPY_USE_BLAS_ILP64="1", RUNNER_OS="macOS"}
180+
environment = {CFLAGS="-fno-strict-aliasing", RUNNER_OS="macOS"}
182181

183182
[tool.cibuildwheel.windows]
184-
environment = {NPY_USE_BLAS_ILP64="1", PKG_CONFIG_PATH="C:/opt/64/lib/pkgconfig"}
183+
environment = {PKG_CONFIG_PATH="C:/opt/64/lib/pkgconfig"}
185184
config-settings = "setup-args=--vsenv setup-args=-Duse-ilp64=true setup-args=-Dblas=openblas setup-args=-Dlapack=openblas"
186185
repair-wheel-command = "bash ./tools/wheels/repair_windows.sh {wheel} {dest_dir}"
187186

tools/ci/cirrus_wheels.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ macosx_arm64_task:
7979
RUNNER_OS=macOS
8080
SDKROOT=/Applications/Xcode-14.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk
8181
LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
82-
CFLAGS="-fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64"
83-
CXXFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64"
84-
OPENBLAS64_="/usr/local"
85-
NPY_USE_BLAS_ILP64="1"
8682
8783
build_script:
8884
- brew install python@3.10

tools/openblas_support.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ def get_plat():
4747
return plat
4848

4949

50-
def get_ilp64():
51-
if os.environ.get("NPY_USE_BLAS_ILP64", "0") == "0":
52-
return None
53-
if IS_32BIT:
54-
raise RuntimeError("NPY_USE_BLAS_ILP64 set on 32-bit arch")
55-
return "64_"
56-
57-
5850
def get_manylinux(arch):
5951
default = '2014'
6052
ml_ver = os.environ.get("MB_ML_VER", default)
@@ -92,9 +84,9 @@ def get_linux(arch):
9284
return get_musllinux(arch)
9385

9486

95-
def download_openblas(target, plat, ilp64, *, nightly=False):
87+
def download_openblas(target, plat, libsuffix, *, nightly=False):
9688
osname, arch = plat.split("-")
97-
fnsuffix = {None: "", "64_": "64_"}[ilp64]
89+
fnsuffix = {None: "", "64_": "64_"}[libsuffix]
9890
filename = ''
9991
headers = {'User-Agent':
10092
('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 ; '
@@ -147,7 +139,7 @@ def download_openblas(target, plat, ilp64, *, nightly=False):
147139
return typ
148140

149141

150-
def setup_openblas(plat=get_plat(), ilp64=get_ilp64(), nightly=False):
142+
def setup_openblas(plat=get_plat(), use_ilp64=False, nightly=False):
151143
'''
152144
Download and setup an openblas library for building. If successful,
153145
the configuration script will find it automatically.
@@ -158,10 +150,15 @@ def setup_openblas(plat=get_plat(), ilp64=get_ilp64(), nightly=False):
158150
path to extracted files on success, otherwise indicates what went wrong
159151
To determine success, do ``os.path.exists(msg)``
160152
'''
153+
if use_ilp64 and IS_32BIT:
154+
raise RuntimeError("Cannot use 64-bit BLAS on 32-bit arch")
155+
161156
_, tmp = mkstemp()
162157
if not plat:
163158
raise ValueError('unknown platform')
164-
typ = download_openblas(tmp, plat, ilp64, nightly=nightly)
159+
160+
libsuffix = '64_' if use_ilp64 else None
161+
typ = download_openblas(tmp, plat, libsuffix, nightly=nightly)
165162
if not typ:
166163
return ''
167164
osname, arch = plat.split("-")
@@ -345,6 +342,7 @@ def test_version(expected_version=None):
345342
)
346343
print("OK")
347344

345+
348346
if __name__ == '__main__':
349347
import argparse
350348
parser = argparse.ArgumentParser(
@@ -358,11 +356,13 @@ def test_version(expected_version=None):
358356
'against available OpenBLAS')
359357
parser.add_argument('--nightly', action='store_true',
360358
help='If set, use nightly OpenBLAS build.')
359+
parser.add_argument('--use-ilp64', action='store_true',
360+
help='If set, download the ILP64 OpenBLAS build.')
361361
args = parser.parse_args()
362362
if args.check_version != '':
363363
test_version(args.check_version)
364364
elif args.test is None:
365-
print(setup_openblas(nightly=args.nightly))
365+
print(setup_openblas(nightly=args.nightly, use_ilp64=args.use_ilp64))
366366
else:
367367
if len(args.test) == 0 or 'all' in args.test:
368368
test_setup(SUPPORTED_PLATFORMS)

tools/wheels/cibw_before_build.sh

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fi
1515

1616
# Install Openblas
1717
if [[ $RUNNER_OS == "Linux" || $RUNNER_OS == "macOS" ]] ; then
18-
basedir=$(python tools/openblas_support.py)
18+
basedir=$(python tools/openblas_support.py --use-ilp64)
1919
if [[ $RUNNER_OS == "macOS" && $PLATFORM == "macosx-arm64" ]]; then
2020
# /usr/local/lib doesn't exist on cirrus-ci runners
2121
sudo mkdir -p /usr/local/lib /usr/local/include /usr/local/lib/cmake/openblas
@@ -33,27 +33,14 @@ elif [[ $RUNNER_OS == "Windows" ]]; then
3333
# delvewheel is the equivalent of delocate/auditwheel for windows.
3434
python -m pip install delvewheel
3535

36-
# make the DLL available for tools/wheels/repair_windows.sh. If you change
37-
# this location you need to alter that script.
38-
mkdir -p /c/opt/openblas/openblas_dll
39-
40-
mkdir -p /c/opt/32/lib/pkgconfig
41-
mkdir -p /c/opt/64/lib/pkgconfig
42-
target=$(python -c "import tools.openblas_support as obs; plat=obs.get_plat(); ilp64=obs.get_ilp64(); target=f'openblas_{plat}.zip'; obs.download_openblas(target, plat, ilp64);print(target)")
4336
if [[ $PLATFORM == 'win-32' ]]; then
44-
# 32-bit openBLAS
45-
# Download 32 bit openBLAS and put it into c/opt/32/lib
46-
unzip -o -d /c/opt/ $target
47-
cp /c/opt/32/bin/*.dll /c/opt/openblas/openblas_dll
37+
echo "No BLAS used for 32-bit wheels"
4838
else
49-
# 64-bit openBLAS
39+
# Note: DLLs are copied from /c/opt/64/bin by delvewheel, see
40+
# tools/wheels/repair_windows.sh
41+
mkdir -p /c/opt/64/lib/pkgconfig
42+
target=$(python -c "import tools.openblas_support as obs; plat=obs.get_plat(); target=f'openblas_{plat}.zip'; obs.download_openblas(target, plat, libsuffix='64_');print(target)")
5043
unzip -o -d /c/opt/ $target
51-
if [[ -f /c/opt/64/lib/pkgconfig/openblas64.pc ]]; then
52-
# As of v0.3.23, the 64-bit interface has a openblas64.pc file,
53-
# but this is wrong. It should be openblas.pc
54-
cp /c/opt/64/lib/pkgconfig/openblas{64,}.pc
55-
fi
56-
cp /c/opt/64/bin/*.dll /c/opt/openblas/openblas_dll
5744
fi
5845
fi
5946

tools/wheels/cibw_test_command.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ elif [[ $RUNNER_OS == "Windows" && $IS_32_BIT == true ]] ; then
2222
echo "Skip OpenBLAS version check for 32-bit Windows, no OpenBLAS used"
2323
# Avoid this in GHA: "ERROR: Found GNU link.exe instead of MSVC link.exe"
2424
rm /c/Program\ Files/Git/usr/bin/link.EXE
25-
else
26-
# For some reason the macos-x86_64 runner does not work with threadpoolctl
27-
# Skip this check there
28-
python $PROJECT_DIR/tools/openblas_support.py --check_version
2925
fi
3026
# Set available memory value to avoid OOM problems on aarch64.
3127
# See gh-22418.

tools/wheels/repair_windows.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ rm -rf tmp
2929

3030
# the libopenblas.dll is placed into this directory in the cibw_before_build
3131
# script.
32-
delvewheel repair --add-path /c/opt/openblas/openblas_dll -w $DEST_DIR $WHEEL
32+
delvewheel repair --add-path /c/opt/64/bin -w $DEST_DIR $WHEEL

0 commit comments

Comments
 (0)
< 2947 /div>
0