Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
142 changes: 45 additions & 97 deletions .github/workflows/posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,141 +23,89 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
PLAT: [i686, x86_64]
INTERFACE64: ['0', '1']
MB_ML_VER: ['2014']
MB_ML_LIBC: ['manylinux']
include:
- os: macos-latest
PLAT: arm64
INTERFACE64: '1'
- os: macos-latest
PLAT: arm64
INTERFACE64: '0'
- os: ubuntu-latest
PLAT: x86_64
INTERFACE64: '1'
MB_ML_LIBC: musllinux
MB_ML_VER: _1_2
- os: ubuntu-latest
PLAT: x86_64
INTERFACE64: '0'
MB_ML_LIBC: musllinux
MB_ML_VER: _1_2

- os: ubuntu-24.04-arm
PLAT: aarch64
INTERFACE64: '0'
MB_ML_VER: '2014'
- os: ubuntu-24.04-arm
PLAT: aarch64
INTERFACE64: '1'
MB_ML_VER: '2014'
- os: ubuntu-24.04-arm
PLAT: aarch64
INTERFACE64: '0'
MB_ML_LIBC: musllinux
MB_ML_VER: _1_2
- os: ubuntu-24.04-arm
PLAT: aarch64
INTERFACE64: '1'
MB_ML_LIBC: musllinux
MB_ML_VER: _1_2

exclude:
- PLAT: i686
os: macos-latest
- PLAT: i686
INTERFACE64: '1'
- { os: ubuntu-latest, PLAT: i686, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}

- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}

- { os: macos-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_LIBC: macosx}
- { os: macos-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_LIBC: macosx}

- { os: macos-latest, PLAT: arm64, INTERFACE64: '0', MB_ML_LIBC: macosx}
- { os: macos-latest, PLAT: arm64, INTERFACE64: '1', MB_ML_LIBC: macosx}

- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}

- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}

- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we no longer use multibuild, the env variables should not have the MB_ prefix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce the difficulty of review, I have tried to preserve the content of the original script as much as possible in this PR, without making excessive modifications. If you think modifications are needed, I can add a commit now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it would be invasive in other places. Let's leave it for a clean-up PR.

env:
NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
MB_PYTHON_VERSION: ${{ matrix.python-version }}
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
MB_ML_LIBC: ${{ matrix.MB_ML_LIBC }}
MB_ML_VER: ${{ matrix.MB_ML_VER }}
INTERFACE64: ${{ matrix.INTERFACE64 }}
BUILD_DIR: ${{ github.workspace }}
PLAT: ${{ matrix.PLAT }}
OS-NAME: ${{ matrix.os }}

steps:
- uses: actions/[email protected]
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Set extra env
run: |
echo "DOCKER_TEST_IMAGE=$(echo multibuild/xenial_${{ matrix.PLAT}})" >> $GITHUB_ENV;

- uses: maxim-lobanov/[email protected]
if: ${{ matrix.os == 'macos-latest' }}
if: ${{ contains(matrix.os, 'macos') }}
with:
xcode-version: '15.4'
xcode-version: '16.0'

- name: Print some Environment variable
run: |
echo "PLAT: ${PLAT}"
echo "DOCKER_TEST_IMAGE: ${DOCKER_TEST_IMAGE}"
- name: Install VirtualEnv
run: |
python3 -m pip install --upgrade pip
pip install virtualenv
- name: Build OpenBLAS
run: |
set -xeo pipefail
source tools/build_steps.sh
echo "------ BEFORE BUILD ---------"
before_build
if [[ "$NIGHTLY" = "true" ]]; then
echo "------ CLEAN CODE --------"
clean_code $REPO_DIR develop
echo "------ BUILD LIB --------"
build_lib "$PLAT" "$INTERFACE64" "1"
else
echo "------ CLEAN CODE --------"
clean_code $REPO_DIR $OPENBLAS_COMMIT
echo "------ BUILD LIB --------"
build_lib "$PLAT" "$INTERFACE64" "0"
fi

# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true

- name: Build and test wheel
run: |
if [[ "$NIGHTLY" = "true" ]]; then
# Set the pyproject.toml version: convert v0.3.24-30-g138ed79f to 0.3.34.30
version=$(cd OpenBLAS && git describe --tags --abbrev=8 | sed -e "s/^v\(.*\)-g.*/\1/" | sed -e "s/-/./g")
sed -e "s/^version = .*/version = \"${version}\"/" -i.bak pyproject.toml
fi
if [ "macos-latest" == "${{ matrix.os }}" ]; then
source tools/build_wheel.sh
else
libc=${MB_ML_LIBC:-manylinux}
docker_image=quay.io/pypa/${libc}${MB_ML_VER}_${PLAT}
docker run --rm -e INTERFACE64="${INTERFACE64}" \
-e MB_ML_LIBC="${MB_ML_LIBC}" \
-v $(pwd):/openblas $docker_image \
/bin/bash -xe /openblas/tools/build_wheel.sh
sudo chmod -R a+w dist
fi

- uses: actions/[email protected]
- name: Build and Test wheels
uses: pypa/[email protected]
with:
output-dir: dist
env:
CIBW_ARCHS: ${{matrix.PLAT}}
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: "cp39-${{ matrix.MB_ML_LIBC }}_${{matrix.PLAT}}"

CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
CIBW_MUSLLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
CIBW_MUSLLINUX_AARCH64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}

- name: Upload wheels to artifacts
uses: actions/[email protected]
with:
name: wheels-${{ matrix.os }}-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }}-${{ matrix.MB_ML_LIBC }}-${{ matrix.MB_ML_VER }}
path: dist/scipy_openblas*.whl

- uses: actions/[email protected]

- name: Upload openblas to artifacts
uses: actions/[email protected]
with:
name: openblas-${{ matrix.os }}-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }}-${{ matrix.MB_ML_LIBC }}-${{ matrix.MB_ML_VER }}
path: libs/openblas*.tar.gz
path: dist/openblas*.tar.gz

- uses: conda-incubator/[email protected]
with:
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "OpenBLAS"]
path = OpenBLAS
url = https://github.com/xianyi/OpenBLAS.git
[submodule "multibuild"]
path = multibuild
url = https://github.com/multi-build/multibuild.git
[submodule "gfortran-install"]
path = gfortran-install
url = https://github.com/MacPython/gfortran-install.git
97 changes: 97 additions & 0 deletions build-openblas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#! /bin/bash


# Most of the content in this file comes from https://github.com/multi-build/multibuild, with some modifications
# Follow the license below



# .. _license:

# *********************
# Copyright and License
# *********************

# The multibuild package, including all examples, code snippets and attached
# documentation is covered by the 2-clause BSD license.

# Copyright (c) 2013-2024, Matt Terry and Matthew Brett; 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.

# 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.


set -xeo pipefail
source tools/build_steps.sh
echo "------ BEFORE BUILD ---------"
before_build

function fill_submodule {
# Restores .git directory to submodule, if necessary
# See:
# https://stackoverflow.com/questions/41776331/is-there-a-way-to-reconstruct-a-git-directory-for-a-submodule
local repo_dir="$1"
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
local git_loc="$repo_dir/.git"
# For ordinary submodule, .git is a file.
[ -d "$git_loc" ] && return
# Need to recreate .git directory for submodule
local origin_url=$(cd "$repo_dir" && git config --get remote.origin.url)
local repo_copy="$repo_dir-$RANDOM"
git clone --recursive "$repo_dir" "$repo_copy"
rm -rf "$repo_dir"
mv "${repo_copy}" "$repo_dir"
(cd "$repo_dir" && git remote set-url origin $origin_url)
}

function clean_code {
local repo_dir=${1:-$REPO_DIR}
local build_commit=${2:-$BUILD_COMMIT}
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
[ -z "$build_commit" ] && echo "build_commit not defined" && exit 1
# The package $repo_dir may be a submodule. git submodules do not
# have a .git directory. If $repo_dir is copied around, tools like
# Versioneer which require that it be a git repository are unable
# to determine the version. Give submodule proper git directory
fill_submodule "$repo_dir"
(cd $repo_dir \
&& git fetch origin --tags \
&& git checkout $build_commit \
&& git clean -fxd \
&& git reset --hard \
&& git submodule update --init --recursive)
}


if [[ "$NIGHTLY" = "true" ]]; then
echo "------ CLEAN CODE --------"
clean_code $REPO_DIR develop
echo "------ BUILD LIB --------"
build_lib "$PLAT" "$INTERFACE64" "1"
else
echo "------ CLEAN CODE --------"
clean_code $REPO_DIR $OPENBLAS_COMMIT
echo "------ BUILD LIB --------"
build_lib "$PLAT" "$INTERFACE64" "0"
fi
Loading