Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BLD: vendor meson-python to make the Windows builds with SIMD work #24396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2023
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
55 changes: 23 additions & 32 deletions .github/workflows/windows_clangcl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
meson:
name: Meson windows build/test
runs-on: windows-2019
# if: "github.repository == 'numpy/numpy'"
if: "github.repository == 'numpy/numpy'"
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
Expand All @@ -32,14 +32,14 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
- name: Install build dependencies from PyPI
run: |
pip install -r build_requirements.txt
- name: openblas-libs
pip install spin Cython

- name: Install OpenBLAS and Clang-cl
run: |
# Download and install pre-built OpenBLAS library
# with 32-bit interfaces
# Unpack it in the pkg-config hardcoded path
# Download and install pre-built OpenBLAS library with 32-bit
# interfaces Unpack it in the pkg-config hardcoded path
choco install unzip -y
choco install wget -y
# Install llvm, which contains clang-cl
Expand All @@ -48,44 +48,35 @@ jobs:
wget https://anaconda.org/multibuild-wheels-staging/openblas-libs/v0.3.21/download/openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
unzip -d c:\opt openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
echo "PKG_CONFIG_PATH=c:\opt\64\lib\pkgconfig;" >> $env:GITHUB_ENV
- name: meson-configure
run: |
"[binaries]","c = 'clang-cl'","cpp = 'clang-cl'","ar = 'llvm-lib'","c_ld = 'lld-link'","cpp_ld = 'lld-link'" | Out-File $PWD/clang-cl-build.ini -Encoding ascii
meson setup build --prefix=$PWD\build-install --native-file=$PWD/clang-cl-build.ini -Ddebug=false --optimization 2 --vsenv
- name: meson-build
run: |
meson compile -C build -v

- name: meson-install
- name: Write native file for Clang-cl binaries
run: |
cd build
meson install --no-rebuild
- name: build-path
# TODO: this job is identical to the one in `windows_meson.yml` aside
# from installing Clang-cl and usage of this .ini file. So merge the
# two and use a matrix'ed CI job run.
"[binaries]","c = 'clang-cl'","cpp = 'clang-cl'","ar = 'llvm-lib'","c_ld = 'lld-link'","cpp_ld = 'lld-link'" | Out-File $PWD/clang-cl-build.ini -Encoding ascii

- name: Install NumPy
run: |
echo "installed_path=$PWD\build-install\Lib\site-packages" >> $env:GITHUB_ENV
- name: post-install
spin build -j2 -- --vsenv --native-file=$PWD/clang-cl-build.ini

- name: Copy OpenBLAS DLL, write _distributor_init.py
run: |
$numpy_path = "${env:installed_path}\numpy"
# Getting the OpenBLAS DLL to the right place so it loads
$installed_path = "$PWD\build-install\usr\Lib\site-packages"
$numpy_path = "${installed_path}\numpy"
$libs_path = "${numpy_path}\.libs"
mkdir ${libs_path}
$ob_path = "C:/opt/64/bin/"
cp $ob_path/*.dll $libs_path
# Write _distributor_init.py to load .libs DLLs.
python -c "from tools import openblas_support; openblas_support.make_init(r'${numpy_path}')"

- name: prep-test
- name: Install test dependencies
run: |
echo "PYTHONPATH=${env:installed_path}" >> $env:GITHUB_ENV
python -m pip install -r test_requirements.txt
python -m pip install threadpoolctl

- name: test
- name: Run test suite
run: |
mkdir tmp
cd tmp
echo "============================================"
python -c "import numpy; print(numpy.show_runtime())"
echo "============================================"
echo "LASTEXITCODE is '$LASTEXITCODE'"
python -c "import numpy, sys; sys.exit(numpy.test(verbose=3) is False)"
echo "LASTEXITCODE is '$LASTEXITCODE'"
spin test
48 changes: 17 additions & 31 deletions .github/workflows/windows_meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,65 +27,51 @@ jobs:
with:
submodules: recursive
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
- name: Install build dependencies from PyPI
run: |
pip install -r build_requirements.txt
- name: openblas-libs
python -m pip install spin Cython

- name: Install OpenBLAS (MacPython build)
run: |
# Download and install pre-built OpenBLAS library
# with 32-bit interfaces
# Unpack it in the pkg-config hardcoded path
# Download and install pre-built OpenBLAS library with 32-bit
# interfaces. Unpack it in the pkg-config hardcoded path
choco install unzip -y
choco install wget -y
choco install -y --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
wget https://anaconda.org/multibuild-wheels-staging/openblas-libs/v0.3.21/download/openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
unzip -d c:\opt openblas-v0.3.21-win_amd64-gcc_10_3_0.zip
echo "PKG_CONFIG_PATH=c:\opt\64\lib\pkgconfig;" >> $env:GITHUB_ENV
- name: meson-configure
run: |
meson setup build --prefix=$PWD\build-install -Ddebug=false --optimization 2 --vsenv
- name: meson-build
run: |
meson compile -C build -v

- name: meson-install
run: |
cd build
meson install --no-rebuild
- name: build-path
- name: Install NumPy
run: |
echo "installed_path=$PWD\build-install\Lib\site-packages" >> $env:GITHUB_ENV
- name: post-install
spin build -j2 -- --vsenv

- name: Copy OpenBLAS DLL, write _distributor_init.py
run: |
$numpy_path = "${env:installed_path}\numpy"
# Getting the OpenBLAS DLL to the right place so it loads
$installed_path = "$PWD\build-install\usr\Lib\site-packages"
$numpy_path = "${installed_path}\numpy"
$libs_path = "${numpy_path}\.libs"
mkdir ${libs_path}
$ob_path = "C:/opt/64/bin/"
cp $ob_path/*.dll $libs_path
# Write _distributor_init.py to load .libs DLLs.
python -c "from tools import openblas_support; openblas_support.make_init(r'${numpy_path}')"

- name: prep-test
- name: Install test dependencies
run: |
echo "PYTHONPATH=${env:installed_path}" >> $env:GITHUB_ENV
python -m pip install -r test_requirements.txt
python -m pip install threadpoolctl

- name: test
- name: Run test suite
run: |
mkdir tmp
cd tmp
echo "============================================"
python -c "import numpy; print(numpy.show_runtime())"
echo "============================================"
echo "LASTEXITCODE is '$LASTEXITCODE'"
python -c "import numpy, sys; sys.exit(numpy.test(verbose=3) is False)"
echo "LASTEXITCODE is '$LASTEXITCODE'"
spin test

msvc_32bit_python_openblas:
name: MSVC, 32-bit Python, no BLAS
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "vendored-meson/meson"]
path = vendored-meson/meson
url = https://github.com/numpy/meson.git
[submodule "vendored-meson/meson-python"]
path = vendored-meson/meson-python
url = https://github.com/numpy/meson-python.git
29 changes: 29 additions & 0 deletions .spin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2021--2022, Scientific Python 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 copyright holder 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 HOLDER 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.
Loading