diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml index 12182965..d6475e16 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/posix.yml @@ -29,7 +29,8 @@ jobs: fail-fast: false matrix: include: - - { os: ubuntu-latest, PLAT: i686, INTERFACE64: '0', MB_ML_VER: '_2_28', MB_ML_LIBC: manylinux} + # Pin docker builds to ubuntu-24.04 https://github.com/actions/runner-images/issues/14790 + - { os: ubuntu-24.04, PLAT: i686, INTERFACE64: '0', MB_ML_VER: '_2_28', MB_ML_LIBC: manylinux} - { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '_2_28', MB_ML_LIBC: manylinux} - { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '_2_28', MB_ML_LIBC: manylinux} @@ -58,8 +59,8 @@ jobs: - { os: ubuntu-24.04-arm, PLAT: riscv64, INTERFACE64: '0', MB_ML_VER: '_2_39', MB_ML_LIBC: manylinux} - { os: ubuntu-24.04-arm, PLAT: riscv64, INTERFACE64: '1', MB_ML_VER: '_2_39', MB_ML_LIBC: manylinux} - - { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_LIBC: android} - - { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_LIBC: android} + - { os: ubuntu-24.04, PLAT: x86_64, INTERFACE64: '0', MB_ML_LIBC: android} + - { os: ubuntu-24.04, PLAT: x86_64, INTERFACE64: '1', MB_ML_LIBC: android} - { os: ubuntu-latest, PLAT: arm64_v8a, INTERFACE64: '0', MB_ML_LIBC: android} - { os: ubuntu-latest, PLAT: arm64_v8a, INTERFACE64: '1', MB_ML_LIBC: android} diff --git a/.github/workflows/windows-arm.yml b/.github/workflows/windows-arm.yml index d6472edd..bce9ad0d 100644 --- a/.github/workflows/windows-arm.yml +++ b/.github/workflows/windows-arm.yml @@ -1,4 +1,4 @@ -name: Windows-on-ARM +name: Windows on: push: @@ -24,18 +24,30 @@ env: # Without this, invoking bash will cd to the home directory CHERE_INVOKING: "yes" BASH_PATH: "C:\\Program Files\\Git\\bin\\bash.exe" - PLAT: arm64 + LLVM_VERSION: "22.1.8" + NINJA_VERSION: "1.13.1" jobs: build: - runs-on: windows-11-arm + name: ${{ matrix.PLAT }}_${{ matrix.INTERFACE64 }} + runs-on: ${{ matrix.os }} timeout-minutes: 90 strategy: + fail-fast: false matrix: - INTERFACE64: ['1', '0'] + # Both architectures build with the same toolchain (clang-cl + + # flang-new + cmake + ninja) and the same script, so they differ only + # in the runner, the installer assets and the wheel tag. + include: + - { os: windows-latest, PLAT: x86_64, WHEEL_PLAT: win_amd64, PY_ARCH: x64, LLVM_ASSET: win64, NINJA_ASSET: win, INTERFACE64: '0' } + - { os: windows-latest, PLAT: x86_64, WHEEL_PLAT: win_amd64, PY_ARCH: x64, LLVM_ASSET: win64, NINJA_ASSET: win, INTERFACE64: '1' } + - { os: windows-11-arm, PLAT: arm64, WHEEL_PLAT: win_arm64, PY_ARCH: arm64, LLVM_ASSET: woa64, NINJA_ASSET: winarm64, INTERFACE64: '0' } + - { os: windows-11-arm, PLAT: arm64, WHEEL_PLAT: win_arm64, PY_ARCH: arm64, LLVM_ASSET: woa64, NINJA_ASSET: winarm64, INTERFACE64: '1' } env: + PLAT: ${{ matrix.PLAT }} + WHEEL_PLAT: ${{ matrix.WHEEL_PLAT }} INTERFACE64: ${{ matrix.INTERFACE64 }} # A scheduled or manually triggered run builds against the latest # OpenBLAS HEAD instead of openblas_commit.txt @@ -50,28 +62,39 @@ jobs: uses: actions/setup-python@v6.2.0 with: python-version: 3.12 - architecture: arm64 + architecture: ${{ matrix.PY_ARCH }} - name: Download and install LLVM installer + # The runner images' preinstalled LLVM has no flang; the official + # installer does. run: | - Invoke-WebRequest https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/LLVM-20.1.8-woa64.exe -UseBasicParsing -OutFile LLVM-woa64.exe - Start-Process -FilePath ".\LLVM-woa64.exe" -ArgumentList "/S" -Wait + $url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${env:LLVM_VERSION}/LLVM-${env:LLVM_VERSION}-${{ matrix.LLVM_ASSET }}.exe" + echo "Downloading $url" + Invoke-WebRequest $url -UseBasicParsing -OutFile LLVM-installer.exe + Start-Process -FilePath ".\LLVM-installer.exe" -ArgumentList "/S" -Wait echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - name: Install CMake and Ninja for Win-ARM64 + - name: Install Ninja + shell: pwsh + run: | + $url = "https://github.com/ninja-build/ninja/releases/download/v${env:NINJA_VERSION}/ninja-${{ matrix.NINJA_ASSET }}.zip" + echo "Downloading $url" + Invoke-WebRequest $url -OutFile ninja.zip + Expand-Archive ninja.zip -DestinationPath ninja + Copy-Item ninja\ninja.exe -Destination "C:\Windows\System32" + + - name: Install CMake for Win-ARM64 + # windows-latest already ships a usable cmake; the ARM64 image does not. + if: matrix.PLAT == 'arm64' shell: pwsh run: | Invoke-WebRequest https://github.com/Kitware/CMake/releases/download/v3.29.4/cmake-3.29.4-windows-arm64.msi -OutFile cmake-arm64.msi Start-Process msiexec.exe -ArgumentList "/i cmake-arm64.msi /quiet /norestart" -Wait echo "C:\Program Files\CMake\bin" >> $env:GITHUB_PATH - Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-winarm64.zip -OutFile ninja-winarm64.zip - Expand-Archive ninja-winarm64.zip -DestinationPath ninja - Copy-Item ninja\ninja.exe -Destination "C:\Windows\System32" - - name: Set env variables run: | - if ( ${{ matrix.INTERFACE64 }} -eq "1" ) { + if ( "${{ matrix.INTERFACE64 }}" -eq "1" ) { echo "INTERFACE_BITS=64" >> $env:GITHUB_ENV } else { echo "INTERFACE_BITS=32" >> $env:GITHUB_ENV @@ -80,9 +103,9 @@ jobs: - name: Build run: | git submodule update --init --recursive - .\tools\build_steps_win_arm64.bat 64 ${env:INTERFACE_BITS} + .\tools\build_steps_win.bat 64 ${env:INTERFACE_BITS} - - name: Test ${{ matrix.INTERFACE_BITS }}-bit interface wheel + - name: Test wheel, INTERFACE64=${{ matrix.INTERFACE64 }} run: | python -m pip install --no-index --find-links dist scipy_openblas${env:INTERFACE_BITS} python -m scipy_openblas${env:INTERFACE_BITS} @@ -90,7 +113,7 @@ jobs: - uses: actions/upload-artifact@v6.0.0 with: - name: wheels-${{ env.PLAT }}-${{ env.INTERFACE64 }} + name: wheels-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }} path: dist/scipy_openblas*.whl upload: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 18b0eb89..453e7567 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -22,18 +22,14 @@ env: # Preserve working directory for calls into bash # Without this, invoking bash will cd to the home directory CHERE_INVOKING: "yes" - BASH_PATH: "c:\\rtools40\\usr\\bin\\bash.exe" jobs: build: strategy: matrix: - plat: ['x64', 'x86'] + plat: ['x64'] INTERFACE64: ['1', '0'] os: [windows-latest] - exclude: - - plat: x86 - INTERFACE64: '1' fail-fast: false runs-on: ${{ matrix.os }} @@ -46,30 +42,28 @@ jobs: timeout-minutes: 90 steps: - uses: actions/checkout@v6.0.1 - - name: install-rtools - run: | - # rtools 42+ does not support 32 bits builds. - choco install -y rtools --no-progress --force --version=4.0.0.20220206 + + - name: Install MSYS2 toolchain + uses: msys2/setup-msys2@v2.33.0 + with: + msystem: UCRT64 + update: true + install: >- + git + make + zip + unzip + pacboy: >- + cc:p + fc:p - name: Set env variables run: | echo "START_DIR=$PWD" >> $env:GITHUB_ENV - # For interpretation of MSYSTEM, see: - # https://sourceforge.net/p/msys2/discussion/general/thread/b7dfdac8/#3939 - if ( "${{ matrix.plat }}" -eq "x86") { - echo "PLAT=i686" >> $env:GITHUB_ENV - echo "WHEEL_PLAT=win32" >> $env:GITHUB_ENV - echo "MSYSTEM=MINGW32" >> $env:GITHUB_ENV - # No ucrt on 32-bits, so use _snprintf_c instead - echo "LDFLAGS=-static -static-libgcc -Wl,--defsym,_quadmath_snprintf=__snprintf_c" >> $env:GITHUB_ENV - echo "BUILD_BITS=32" >> $env:GITHUB_ENV - } else { - echo "PLAT=x86_64" >> $env:GITHUB_ENV - echo "WHEEL_PLAT=win_amd64" >> $env:GITHUB_ENV - echo "MSYSTEM=UCRT64" >> $env:GITHUB_ENV - echo "LDFLAGS=-lucrt -static -static-libgcc -Wl,--defsym,quadmath_snprintf=snprintf" >> $env:GITHUB_ENV - echo "BUILD_BITS=64" >> $env:GITHUB_ENV - } + echo "PLAT=x86_64" >> $env:GITHUB_ENV + echo "WHEEL_PLAT=win_amd64" >> $env:GITHUB_ENV + echo "LDFLAGS=-lucrt -static -static-libgcc -Wl,--defsym,quadmath_snprintf=snprintf" >> $env:GITHUB_ENV + echo "BUILD_BITS=64" >> $env:GITHUB_ENV if ( ${{ matrix.INTERFACE64 }} -eq "1" ) { echo "INTERFACE64=1" >> $env:GITHUB_ENV } @@ -82,15 +76,17 @@ jobs: echo CIBW_ENVIRONMENT_WINDOWS=$env:CIBW_ENVIRONMENT_WINDOWS - name: Build + shell: msys2 {0} run: | git submodule update --init --recursive - & $env:BASH_PATH -lc tools/build_steps_windows.sh + tools/build_steps_windows.sh - name: Test + shell: msys2 {0} run: | - & $env:BASH_PATH -lc tools/build_gfortran.sh + tools/build_gfortran.sh echo "Dynamic test" - .\for_test\test_dyn.exe + ./for_test/test_dyn.exe - name: Copy run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 019d8b61..45df8ca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## OpenBLAS v0.3.34 (v0.3.34) +### 0.3.34.481.4 (2026-11-19) + +- Drop 32-bit windows wheels, update rtools + ### 0.3.34.481.3 (2026-11-2) - Refactor gha upload to anaconda.org diff --git a/local/scipy_openblas64/__init__.py b/local/scipy_openblas64/__init__.py index 06bb744e..82264580 100644 --- a/local/scipy_openblas64/__init__.py +++ b/local/scipy_openblas64/__init__.py @@ -8,7 +8,6 @@ import re import sys from textwrap import dedent -import platform _HERE = Path(__file__).resolve().parent @@ -74,12 +73,10 @@ def get_pkg_config(use_preloading=False, use_prefix=False): """ extralib = "" if sys.platform == "win32": - machine = platform.machine().lower() - if machine != "arm64": - extralib = "-defaultlib:advapi32 -lgfortran -lquadmath" + extralib = "-defaultlib:advapi32" libs_flags = f"-L${{libdir}} -l{get_library()}" else: - extralib = f"-lm -lpthread -lgfortran -lquadmath -L${{libdir}} -l{get_library()}" + extralib = f"-lm -lpthread -L${{libdir}} -l{get_library()}" if use_preloading: libs_flags = "" else: diff --git a/pyproject.toml b/pyproject.toml index f03f77a9..1a9b3199 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta" [project] name = "scipy-openblas64" # 0.3.34-481-g5137bb62 -version = "0.3.34.481.3" +version = "0.3.34.481.4" requires-python = ">=3.7" description = "Provides OpenBLAS for python packaging" readme = "README.md" diff --git a/tools/LICENSE_win_flang.txt b/tools/LICENSE_win_flang.txt new file mode 100644 index 00000000..0a79b382 --- /dev/null +++ b/tools/LICENSE_win_flang.txt @@ -0,0 +1,324 @@ + +---- + +This binary distribution of NumPy also bundles the following software: + + +Name: OpenBLAS +Files: libs/libscipy_openblas*.dll +Description: bundled as a dynamically linked library +Availability: https://github.com/OpenMathLib/OpenBLAS/ +License: BSD-3-Clause-Attribution + Copyright (c) 2011-2014, The OpenBLAS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name of the OpenBLAS project nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Name: LAPACK +Files: libs/libscipy_openblas*.dll +Description: bundled in OpenBLAS +Availability: https://github.com/OpenMathLib/OpenBLAS/ +License: BSD-3-Clause-Attribution + Copyright (c) 1992-2013 The University of Tennessee and The University + of Tennessee Research Foundation. All rights + reserved. + Copyright (c) 2000-2013 The University of California Berkeley. All + rights reserved. + Copyright (c) 2006-2013 The University of Colorado Denver. All rights + reserved. + + $COPYRIGHT$ + + Additional copyrights may follow + + $HEADER$ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer listed + in this license in the documentation and/or other materials + provided with the distribution. + + - Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + The copyright holders provide no reassurances that the source code + provided does not infringe any patent, copyright, or any other + intellectual property rights of third parties. The copyright holders + disclaim any liability to any recipient for claims brought against + recipient by any third party for infringement of that parties + intellectual property rights. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Name: Flang runtime library +Files: libs/libscipy_openblas*.dll +Description: statically linked into files compiled with LLVM flang +Availability: https://github.com/llvm/llvm-project/tree/main/flang-rt +License: Apache-2.0-with-LLVM-exception + ============================================================================== + The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: + ============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + ---- LLVM Exceptions to the Apache 2.0 License ---- + + As an exception, if, as a result of your compiling your source code, portions + of this Software are embedded into an Object form of such source code, you + may redistribute such embedded portions in such Object form without complying + with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + + In addition, if you combine or link compiled forms of this Software with + software that is licensed under the GPLv2 ("Combined Software") and if a + court of competent jurisdiction determines that the patent provision (Section + 3), the indemnity provision (Section 9) or other Section of the License + conflicts with the conditions of the GPLv2, you may retroactively and + prospectively choose to deem waived or otherwise exclude such Section(s) of + the License, but only in their entirety and only with respect to the Combined + Software. diff --git a/tools/OpenBLASConfig.cmake.in b/tools/OpenBLASConfig.cmake.in new file mode 100644 index 00000000..5e6396b9 --- /dev/null +++ b/tools/OpenBLASConfig.cmake.in @@ -0,0 +1,35 @@ +# OpenBLASConfig.cmake for the scipy_openblas wheels. +# +# OpenBLAS's own cmake export (OpenBLASConfig.cmake plus an +# OpenBLASTargets.cmake that it does not write into the build tree) describes +# the layout of "make install", where the DLL lands in bin/. In these wheels +# everything lives in /lib, so build_steps_win.bat writes this file +# from tools/OpenBLASConfig.cmake.in instead. +# +# Sets: +# OpenBLAS_VERSION - version of the bundled OpenBLAS +# OpenBLAS_INCLUDE_DIR - directory holding the headers +# OpenBLAS_INCLUDE_DIRS - same as above +# OpenBLAS_LIBRARY - import library to link against +# OpenBLAS_LIBRARIES - same as above +# OpenBLAS_FOUND - TRUE +# and defines the imported target OpenBLAS::OpenBLAS. + +set(OpenBLAS_VERSION "@VERSION@") + +get_filename_component(_OpenBLAS_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) + +set(OpenBLAS_INCLUDE_DIR "${_OpenBLAS_ROOT_DIR}/include") +set(OpenBLAS_INCLUDE_DIRS "${OpenBLAS_INCLUDE_DIR}") +set(OpenBLAS_LIBRARY "${_OpenBLAS_ROOT_DIR}/lib/@LIBNAME@.lib") +set(OpenBLAS_LIBRARIES "${OpenBLAS_LIBRARY}") + +if (NOT TARGET OpenBLAS::OpenBLAS) + add_library(OpenBLAS::OpenBLAS SHARED IMPORTED) + set_target_properties(OpenBLAS::OpenBLAS PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenBLAS_INCLUDE_DIR}" + IMPORTED_LOCATION "${_OpenBLAS_ROOT_DIR}/lib/@LIBNAME@.dll" + IMPORTED_IMPLIB "${OpenBLAS_LIBRARY}") +endif () + +set(OpenBLAS_FOUND TRUE) diff --git a/tools/build_steps_win_arm64.bat b/tools/build_steps_win.bat similarity index 59% rename from tools/build_steps_win_arm64.bat rename to tools/build_steps_win.bat index 6446b3ca..5116e75b 100755 --- a/tools/build_steps_win_arm64.bat +++ b/tools/build_steps_win.bat @@ -1,17 +1,17 @@ -REM Build script for scipy_openblas wheel on Windows on ARM64 +REM Build script for scipy_openblas wheels on Windows, x86_64 and ARM64 alike. -REM Usage: build_steps_win_arm64.bat [build_bits] [if_bits] -REM e.g build_steps_win_arm64.bat 64 64 +REM Usage: build_steps_win.bat [build_bits] [if_bits] +REM e.g build_steps_win.bat 64 64 REM build_bits (default binary architecture, 32 or 64, unspec -> 64). REM if_bits (default interface size, 32 or 64, unspec -> 32) REM If INTERFACE64 environment variable is 1, then if_bits defaults to 64 +REM PLAT (target architecture, x86_64 or arm64; unspec -> derived from +REM PROCESSOR_ARCHITECTURE) +REM WHEEL_PLAT (wheel platform tag, win_amd64 or win_arm64; unspec -> +REM derived from PLAT) REM Expects these binaries on the PATH: -REM clang-cl, flang-new, cmake, perl -REM First commit containing WoA build fixes. -REM Minimum OpenBLAS commit to build; we'll update to this if commit not -REM present. -set first_woa_buildable_commit="de2380e5a6149706a633322a16a0f66faa5591fc" +REM clang-cl, flang, cmake, perl @echo off setlocal enabledelayedexpansion @@ -31,8 +31,29 @@ if "%2"=="" ( ) else ( set "if_bits=%2" ) -echo Building for %build_bits%-bit binary, %if_bits%-bit interface... - +REM Resolve the target architecture. The workflow passes PLAT and WHEEL_PLAT, +REM but derive them when running locally so the script is usable by hand. +if "%PLAT%"=="" ( + if /I "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( + set "PLAT=arm64" + ) else ( + set "PLAT=x86_64" + ) +) +if "%WHEEL_PLAT%"=="" ( + if "%PLAT%"=="arm64" ( + set "WHEEL_PLAT=win_arm64" + ) else ( + set "WHEEL_PLAT=win_amd64" + ) +) +if "%PLAT%"=="arm64" ( + set "vcvars_arch=arm64" +) else ( + set "vcvars_arch=x64" +) +echo Building %PLAT% for %build_bits%-bit binary, %if_bits%-bit interface, wheel tag %WHEEL_PLAT%... + REM Define destination directory pushd "%~dp0\.." set "ob_out_root=%CD%\local\scipy_openblas" @@ -70,13 +91,7 @@ if "%NIGHTLY%"=="true" ( git checkout %OPENBLAS_COMMIT% ) if errorlevel 1 exit /b 1 -git merge-base --is-ancestor %first_woa_buildable_commit% HEAD 2>NUL -if errorlevel 1 ( - echo OpenBLAS commit does not contain WoA build fixes. - echo Commit needs to contain %first_woa_buildable_commit%. - exit /b 2 -) - + REM Patch set patch_rc=0 for %%f in (..\patches-common\*.patch ..\patches\*.patch ..\patches-windows\*.patch) do ( @@ -97,10 +112,18 @@ if "%NIGHTLY%"=="true" ( for /f "tokens=3 delims= " %%v in ('findstr /b "version = " ..\pyproject.toml') do set version=%%v set version=%version:"=% -REM cwd is already OpenBLAS here, so the source is Makefile.rule, not -REM OpenBLAS/Makefile.rule -- that path never existed, Get-Content errored, -REM and the VERSION substitution silently never happened. -powershell -Command "(Get-Content Makefile.rule) -replace '^VERSION = .*', 'VERSION = %version%' | Set-Content Makefile.rule" +REM The cmake build ignores Makefile.rule and takes the version from +REM CMakeLists.txt, which bakes it into scipy-openblas.pc, +REM OpenBLASConfigVersion.cmake and the OPENBLAS_VERSION in openblas_config.h +REM that openblas_get_config() reports. Without this it stays at 0.3.34.dev. +powershell -Command "(Get-Content CMakeLists.txt) -replace '^set\(OpenBLAS_VERSION .*', 'set(OpenBLAS_VERSION \"%version%\")' | Set-Content CMakeLists.txt" +if errorlevel 1 exit /b 1 +findstr /b /c:"set(OpenBLAS_VERSION" CMakeLists.txt +findstr /b /c:"set(OpenBLAS_VERSION" CMakeLists.txt | findstr /c:"%version%" >NUL +if errorlevel 1 ( + echo Error: could not set OpenBLAS_VERSION to %version% in CMakeLists.txt. + exit /b 1 +) REM Set suffixed-ILP64 flags if "%if_bits%"=="64" ( @@ -113,9 +136,9 @@ REM Create build directory and navigate to it if exist build (rmdir /S /Q build || exit /b 1) mkdir build || exit /b 1 & cd build || exit /b 1 -echo Setting up ARM64 Developer Command Prompt and running CMake... +echo Setting up %vcvars_arch% Developer Command Prompt and running CMake... -REM Initialize VS ARM64 environment. +REM Initialize the VS environment for the target architecture. REM REM Ask vswhere where Visual Studio is rather than hardcoding the version and REM edition: the windows-11-arm image migrated from VS 2022 to VS 2026 in @@ -144,9 +167,9 @@ if not exist "%VCVARSALL%" ( exit /b 1 ) echo Using Visual Studio at "%VSINSTALL%" -CALL "%VCVARSALL%" arm64 +CALL "%VCVARSALL%" %vcvars_arch% if errorlevel 1 ( - echo Error: "%VCVARSALL%" arm64 failed. + echo Error: "%VCVARSALL%" %vcvars_arch% failed. exit /b 1 ) where mt.exe >NUL 2>&1 @@ -159,22 +182,82 @@ if errorlevel 1 ( REM Prefer LLVM flang PATH=C:\Program Files\LLVM\bin;%PATH% +REM Visual Studio ships its own LLVM with an incomplete flang, so confirm +REM which compilers we actually resolved to. +where clang-cl +if errorlevel 1 ( + echo Error: clang-cl is not on PATH. + exit /b 1 +) +where flang +if errorlevel 1 ( + echo Error: flang is not on PATH. + exit /b 1 +) +clang-cl --version +flang --version + +REM flang's objects carry a /DEFAULTLIB:flang_rt.runtime.dynamic directive, but +REM OpenBLAS links the DLL with a hand-written lld-link call (no flang driver, +REM no /LIBPATH), so the runtime archive must be findable through LIB. It +REM lives in LLVM's per-target resource directory, whose version component +REM tracks the LLVM release, so look it up rather than hardcoding it. +if "%PLAT%"=="arm64" ( + set "flang_rt_triple=aarch64-pc-windows-msvc" +) else ( + set "flang_rt_triple=x86_64-pc-windows-msvc" +) +REM "for /d" over a quoted wildcard matches nothing, and the path has a space +REM in it, so list the version directories with dir instead. +set "clang_res_root=C:\Program Files\LLVM\lib\clang" +set "FLANG_RT_DIR=" +for /f "delims=" %%v in ('dir /b /ad "%clang_res_root%" 2^>NUL') do ( + if exist "%clang_res_root%\%%v\lib\%flang_rt_triple%\flang_rt.runtime.dynamic.lib" set "FLANG_RT_DIR=%clang_res_root%\%%v\lib\%flang_rt_triple%" +) +if not defined FLANG_RT_DIR ( + echo Error: no flang_rt.runtime.dynamic.lib for %flang_rt_triple% under + echo "%clang_res_root%" - the DLL link would fail with + echo "lld-link: error: could not open flang_rt.runtime.dynamic.lib". + exit /b 1 +) +echo Using flang runtime from "%FLANG_RT_DIR%" +set "LIB=%FLANG_RT_DIR%;%LIB%" + REM Run CMake and Ninja build -set CFLAGS=-Wno-reserved-macro-identifier -Wno-unsafe-buffer-usage -Wno-unused-macros -Wno-sign-conversion -Wno-reserved-identifier +REM CONSISTENT_FPCSR is x86-only: it makes blas_server_win32.c save and restore +REM the FPU/SSE control words with ldmxcsr/fldcw/fnstcw/stmxcsr inline asm, +REM which clang-cl rejects on arm64 ("unrecognized instruction mnemonic"). +if "%PLAT%"=="arm64" ( + set "arch_flags=-DTARGET=ARMV8 -DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_SYSTEM_NAME=Windows" +) else ( + set "arch_flags=-DTARGET=PRESCOTT -DDYNAMIC_ARCH=ON -DDYNAMIC_LIST=NEHALEM;SANDYBRIDGE;HASWELL;SKYLAKEX -DCONSISTENT_FPCSR=1" +) + +REM OpenBLAS's cmake/cc.cmake appends -Wall for any Clang, but clang-cl parses +REM -Wall as MSVC /Wall, i.e. -Weverything: that produced 63k warnings and a +REM 30MB log. It is appended to CMAKE_C_FLAGS after anything we put in CFLAGS, +REM so the only slot that lands later is CMAKE_C_FLAGS_RELEASE. +set CFLAGS= +set "release_flags=/MD /O2 /Ob2 /DNDEBUG -Wno-everything" cmake .. -G Ninja ^ -DCMAKE_BUILD_TYPE=Release ^ - -DTARGET=ARMV8 ^ + -DCMAKE_C_FLAGS_RELEASE="%release_flags%" ^ + -DCMAKE_Fortran_FLAGS_RELEASE="-O2 -DNDEBUG" ^ -DBINARY=%build_bits% ^ -DCMAKE_C_COMPILER=clang-cl ^ - -DCMAKE_Fortran_COMPILER=flang-new ^ + -DCMAKE_Fortran_COMPILER=flang ^ -DBUILD_SHARED_LIBS=ON ^ - -DCMAKE_SYSTEM_PROCESSOR=arm64 ^ - -DCMAKE_SYSTEM_NAME=Windows ^ -DSYMBOLPREFIX="scipy_" ^ -DLIBNAMEPREFIX="scipy_" ^ - -DUSE_THREADS=1 ^ + -DUSE_THREAD=1 ^ + -DUSE_OPENMP=0 ^ -DNUM_THREADS=24 ^ + -DNO_WARMUP=1 ^ + -DBUILD_LAPACK_DEPRECATED=ON ^ + -DFIXED_LIBNAME=1 ^ + -DBUFFERSIZE=20 ^ + %arch_flags% ^ %interface_flags% if errorlevel 1 exit /b 1 @@ -201,7 +284,7 @@ if "%if_bits%"=="32" ( REM Prepare destination directory cd OpenBLAS/build echo Preparing destination directory at %DEST_DIR% -if not exist "%DEST_DIR%\lib\cmake\OpenBLAS" mkdir "%DEST_DIR%\lib\cmake\OpenBLAS" +if not exist "%DEST_DIR%\lib\cmake\openblas" mkdir "%DEST_DIR%\lib\cmake\openblas" if not exist "%DEST_DIR%\include" mkdir "%DEST_DIR%\include" REM Move library files @@ -220,9 +303,22 @@ if exist lib\release ( exit /b 1 ) -REM Copy CMake configuration files -echo Copying CMake configuration files... -if exist openblasconfig.cmake copy /Y openblasconfig.cmake "%DEST_DIR%\lib\cmake\openblas\" +REM Write the CMake package configuration. OpenBLAS generates +REM OpenBLASConfig.cmake, which include()s an OpenBLASTargets.cmake +REM describing the "make install" layout; neither suits the wheel, so write +REM our own from the template and keep OpenBLAS's version file. +echo Writing CMake configuration files... +if "%if_bits%"=="64" ( + set "cm_libname=scipy_openblas_64" +) else ( + set "cm_libname=scipy_openblas" +) +powershell -Command "(Get-Content '%~dp0OpenBLASConfig.cmake.in') -replace '@VERSION@', '%version%' -replace '@LIBNAME@', '%cm_libname%' | Set-Content '%DEST_DIR%\lib\cmake\openblas\OpenBLASConfig.cmake'" +if errorlevel 1 exit /b 1 +if not exist "%DEST_DIR%\lib\cmake\openblas\OpenBLASConfig.cmake" ( + echo Error: failed to write OpenBLASConfig.cmake. + exit /b 1 +) if exist openblasconfigversion.cmake copy /Y openblasconfigversion.cmake "%DEST_DIR%\lib\cmake\openblas\" REM Copy header files @@ -248,6 +344,12 @@ if errorlevel 1 ( exit /b 1 ) +(echo.)>> LICENSE.txt +(echo ----)>> LICENSE.txt +(echo.)>> LICENSE.txt +type tools\LICENSE_win_flang.txt >> LICENSE.txt +if errorlevel 1 exit /b 1 + REM Build the Wheel & Install It echo Running 'python -m build' to build the wheel in %CD% python -c "import build" 2>NUL || pip install build @@ -269,7 +371,7 @@ REM Rename the wheel for %%f in (dist\*any.whl) do ( set WHEEL_FILE=dist\%%f set "filename=%%~nxf" - set "newname=!filename:any.whl=win_arm64.whl!" + set "newname=!filename:any.whl=%WHEEL_PLAT%.whl!" ren "dist\!filename!" "!newname!" )