Skip to content

Commit 92dce7e

Browse files
authored
Merge pull request #217 from ffgan/cibuildwheel
Use cibuildwheel to replace multibuild
2 parents 8c01500 + a11dabd commit 92dce7e

15 files changed

+683
-228
lines changed

.github/workflows/posix.yml

Lines changed: 45 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -23,141 +23,89 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
os: [ubuntu-latest, macos-latest]
27-
PLAT: [i686, x86_64]
28-
INTERFACE64: ['0', '1']
29-
MB_ML_VER: ['2014']
30-
MB_ML_LIBC: ['manylinux']
3126
include:
32-
- os: macos-latest
33-
PLAT: arm64
34-
INTERFACE64: '1'
35-
- os: macos-latest
36-
PLAT: arm64
37-
INTERFACE64: '0'
38-
- os: ubuntu-latest
39-
PLAT: x86_64
40-
INTERFACE64: '1'
41-
MB_ML_LIBC: musllinux
42-
MB_ML_VER: _1_2
43-
- os: ubuntu-latest
44-
PLAT: x86_64
45-
INTERFACE64: '0'
46-
MB_ML_LIBC: musllinux
47-
MB_ML_VER: _1_2
48-
49-
- os: ubuntu-24.04-arm
50-
PLAT: aarch64
51-
INTERFACE64: '0'
52-
MB_ML_VER: '2014'
53-
- os: ubuntu-24.04-arm
54-
PLAT: aarch64
55-
INTERFACE64: '1'
56-
MB_ML_VER: '2014'
57-
- os: ubuntu-24.04-arm
58-
PLAT: aarch64
59-
INTERFACE64: '0'
60-
MB_ML_LIBC: musllinux
61-
MB_ML_VER: _1_2
62-
- os: ubuntu-24.04-arm
63-
PLAT: aarch64
64-
INTERFACE64: '1'
65-
MB_ML_LIBC: musllinux
66-
MB_ML_VER: _1_2
67-
68-
exclude:
69-
- PLAT: i686
70-
os: macos-latest
71-
- PLAT: i686
72-
INTERFACE64: '1'
27+
- { os: ubuntu-latest, PLAT: i686, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
28+
29+
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
30+
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
31+
32+
- { os: macos-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_LIBC: macosx}
33+
- { os: macos-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_LIBC: macosx}
34+
35+
- { os: macos-latest, PLAT: arm64, INTERFACE64: '0', MB_ML_LIBC: macosx}
36+
- { os: macos-latest, PLAT: arm64, INTERFACE64: '1', MB_ML_LIBC: macosx}
37+
38+
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
39+
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
40+
41+
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
42+
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
43+
44+
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
45+
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
46+
7347
env:
7448
NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
75-
MB_PYTHON_VERSION: ${{ matrix.python-version }}
76-
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
7749
MB_ML_LIBC: ${{ matrix.MB_ML_LIBC }}
7850
MB_ML_VER: ${{ matrix.MB_ML_VER }}
7951
INTERFACE64: ${{ matrix.INTERFACE64 }}
8052
BUILD_DIR: ${{ github.workspace }}
8153
PLAT: ${{ matrix.PLAT }}
54+
OS-NAME: ${{ matrix.os }}
8255

8356
steps:
8457
- uses: actions/[email protected]
8558
with:
8659
submodules: recursive
8760
fetch-depth: 0
88-
- name: Set up Python
89-
uses: actions/setup-python@v5
90-
with:
91-
python-version: 3.9
61+
9262
- name: Set extra env
9363
run: |
9464
echo "DOCKER_TEST_IMAGE=$(echo multibuild/xenial_${{ matrix.PLAT}})" >> $GITHUB_ENV;
9565
9666
- uses: maxim-lobanov/[email protected]
97-
if: ${{ matrix.os == 'macos-latest' }}
67+
if: ${{ contains(matrix.os, 'macos') }}
9868
with:
99-
xcode-version: '15.4'
69+
xcode-version: '16.0'
10070

10171
- name: Print some Environment variable
10272
run: |
10373
echo "PLAT: ${PLAT}"
10474
echo "DOCKER_TEST_IMAGE: ${DOCKER_TEST_IMAGE}"
105-
- name: Install VirtualEnv
106-
run: |
107-
python3 -m pip install --upgrade pip
108-
pip install virtualenv
109-
- name: Build OpenBLAS
110-
run: |
111-
set -xeo pipefail
112-
source tools/build_steps.sh
113-
echo "------ BEFORE BUILD ---------"
114-
before_build
115-
if [[ "$NIGHTLY" = "true" ]]; then
116-
echo "------ CLEAN CODE --------"
117-
clean_code $REPO_DIR develop
118-
echo "------ BUILD LIB --------"
119-
build_lib "$PLAT" "$INTERFACE64" "1"
120-
else
121-
echo "------ CLEAN CODE --------"
122-
clean_code $REPO_DIR $OPENBLAS_COMMIT
123-
echo "------ BUILD LIB --------"
124-
build_lib "$PLAT" "$INTERFACE64" "0"
125-
fi
12675
12776
# - name: Setup tmate session
12877
# if: ${{ failure() }}
12978
# uses: mxschmitt/action-tmate@v3
13079
# with:
13180
# limit-access-to-actor: true
13281

133-
- name: Build and test wheel
134-
run: |
135-
if [[ "$NIGHTLY" = "true" ]]; then
136-
# Set the pyproject.toml version: convert v0.3.24-30-g138ed79f to 0.3.34.30
137-
version=$(cd OpenBLAS && git describe --tags --abbrev=8 | sed -e "s/^v\(.*\)-g.*/\1/" | sed -e "s/-/./g")
138-
sed -e "s/^version = .*/version = \"${version}\"/" -i.bak pyproject.toml
139-
fi
140-
if [ "macos-latest" == "${{ matrix.os }}" ]; then
141-
source tools/build_wheel.sh
142-
else
143-
libc=${MB_ML_LIBC:-manylinux}
144-
docker_image=quay.io/pypa/${libc}${MB_ML_VER}_${PLAT}
145-
docker run --rm -e INTERFACE64="${INTERFACE64}" \
146-
-e MB_ML_LIBC="${MB_ML_LIBC}" \
147-
-v $(pwd):/openblas $docker_image \
148-
/bin/bash -xe /openblas/tools/build_wheel.sh
149-
sudo chmod -R a+w dist
150-
fi
151-
152-
- uses: actions/[email protected]
82+
- name: Build and Test wheels
83+
uses: pypa/[email protected]
84+
with:
85+
output-dir: dist
86+
env:
87+
CIBW_ARCHS: ${{matrix.PLAT}}
88+
CIBW_BUILD_VERBOSITY: 1
89+
CIBW_BUILD: "cp39-${{ matrix.MB_ML_LIBC }}_${{matrix.PLAT}}"
90+
91+
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
92+
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
93+
CIBW_MUSLLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
94+
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
95+
CIBW_MUSLLINUX_AARCH64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
96+
97+
- name: Upload wheels to artifacts
98+
uses: actions/[email protected]
15399
with:
154100
name: wheels-${{ matrix.os }}-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }}-${{ matrix.MB_ML_LIBC }}-${{ matrix.MB_ML_VER }}
155101
path: dist/scipy_openblas*.whl
156102

157-
- uses: actions/[email protected]
103+
104+
- name: Upload openblas to artifacts
105+
uses: actions/[email protected]
158106
with:
159107
name: openblas-${{ matrix.os }}-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }}-${{ matrix.MB_ML_LIBC }}-${{ matrix.MB_ML_VER }}
160-
path: libs/openblas*.tar.gz
108+
path: dist/openblas*.tar.gz
161109

162110
- uses: conda-incubator/[email protected]
163111
with:

.gitmodules

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
[submodule "OpenBLAS"]
22
path = OpenBLAS
33
url = https://github.com/xianyi/OpenBLAS.git
4-
[submodule "multibuild"]
5-
path = multibuild
6-
url = https://github.com/multi-build/multibuild.git
7-
[submodule "gfortran-install"]
8-
path = gfortran-install
9-
url = https://github.com/MacPython/gfortran-install.git

build-openblas.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#! /bin/bash
2+
3+
4+
# Most of the content in this file comes from https://github.com/multi-build/multibuild, with some modifications
5+
# Follow the license below
6+
7+
8+
9+
# .. _license:
10+
11+
# *********************
12+
# Copyright and License
13+
# *********************
14+
15+
# The multibuild package, including all examples, code snippets and attached
16+
# documentation is covered by the 2-clause BSD license.
17+
18+
# Copyright (c) 2013-2024, Matt Terry and Matthew Brett; all rights
19+
# reserved.
20+
21+
# Redistribution and use in source and binary forms, with or without
22+
# modification, are permitted provided that the following conditions are
23+
# met:
24+
25+
# 1. Redistributions of source code must retain the above copyright notice,
26+
# this list of conditions and the following disclaimer.
27+
28+
# 2. Redistributions in binary form must reproduce the above copyright
29+
# notice, this list of conditions and the following disclaimer in the
30+
# documentation and/or other materials provided with the distribution.
31+
32+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43+
44+
45+
set -xeo pipefail
46+
source tools/build_steps.sh
47+
echo "------ BEFORE BUILD ---------"
48+
before_build
49+
50+
function fill_submodule {
51+
# Restores .git directory to submodule, if necessary
52+
# See:
53+
# https://stackoverflow.com/questions/41776331/is-there-a-way-to-reconstruct-a-git-directory-for-a-submodule
54+
local repo_dir="$1"
55+
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
56+
local git_loc="$repo_dir/.git"
57+
# For ordinary submodule, .git is a file.
58+
[ -d "$git_loc" ] && return
59+
# Need to recreate .git directory for submodule
60+
local origin_url=$(cd "$repo_dir" && git config --get remote.origin.url)
61+
local repo_copy="$repo_dir-$RANDOM"
62+
git clone --recursive "$repo_dir" "$repo_copy"
63+
rm -rf "$repo_dir"
64+
mv "${repo_copy}" "$repo_dir"
65+
(cd "$repo_dir" && git remote set-url origin $origin_url)
66+
}
67+
68+
function clean_code {
69+
local repo_dir=${1:-$REPO_DIR}
70+
local build_commit=${2:-$BUILD_COMMIT}
71+
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
72+
[ -z "$build_commit" ] && echo "build_commit not defined" && exit 1
73+
# The package $repo_dir may be a submodule. git submodules do not
74+
# have a .git directory. If $repo_dir is copied around, tools like
75+
# Versioneer which require that it be a git repository are unable
76+
# to determine the version. Give submodule proper git directory
77+
fill_submodule "$repo_dir"
78+
(cd $repo_dir \
79+
&& git fetch origin --tags \
80+
&& git checkout $build_commit \
81+
&& git clean -fxd \
82+
&& git reset --hard \
83+
&& git submodule update --init --recursive)
84+
}
85+
86+
87+
if [[ "$NIGHTLY" = "true" ]]; then
88+
echo "------ CLEAN CODE --------"
89+
clean_code $REPO_DIR develop
90+
echo "------ BUILD LIB --------"
91+
build_lib "$PLAT" "$INTERFACE64" "1"
92+
else
93+
echo "------ CLEAN CODE --------"
94+
clean_code $REPO_DIR $OPENBLAS_COMMIT
95+
echo "------ BUILD LIB --------"
96+
build_lib "$PLAT" "$INTERFACE64" "0"
97+
fi

ci-before-build.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#! /bin/bash
2+
3+
4+
# Most of the content in this file comes from https://github.com/multi-build/multibuild, with some modifications
5+
# Follow the license below
6+
7+
8+
9+
# .. _license:
10+
11+
# *********************
12+
# Copyright and License
13+
# *********************
14+
15+
# The multibuild package, including all examples, code snippets and attached
16+
# documentation is covered by the 2-clause BSD license.
17+
18+
# Copyright (c) 2013-2024, Matt Terry and Matthew Brett; all rights
19+
# reserved.
20+
21+
# Redistribution and use in source and binary forms, with or without
22+
# modification, are permitted provided that the following conditions are
23+
# met:
24+
25+
# 1. Redistributions of source code must retain the above copyright notice,
26+
# this list of conditions and the following disclaimer.
27+
28+
# 2. Redistributions in binary form must reproduce the above copyright
29+
# notice, this list of conditions and the following disclaimer in the
30+
# documentation and/or other materials provided with the distribution.
31+
32+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43+
44+
45+
46+
#! /bin/bash
47+
set -xe
48+
49+
if [[ "$NIGHTLY" = "true" ]]; then
50+
# Set the pyproject.toml version: convert v0.3.24-30-g138ed79f to 0.3.34.30
51+
version=$(cd OpenBLAS && git describe --tags --abbrev=8 | sed -e "s/^v\(.*\)-g.*/\1/" | sed -e "s/-/./g")
52+
sed -e "s/^version = .*/version = \"${version}\"/" -i.bak pyproject.toml
53+
fi
54+
55+
56+
#!/bin/bash
57+
# Utilities for both OSX and Docker Linux
58+
# python or python3 should be on the PATH
59+
60+
# Only source common_utils once
61+
if [ -n "$COMMON_UTILS_SOURCED" ]; then
62+
return
63+
fi
64+
COMMON_UTILS_SOURCED=1
65+
66+
# Turn on exit-if-error
67+
set -e
68+
69+
MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
70+
DOWNLOADS_SDIR=downloads
71+
PYPY_URL=https://downloads.python.org/pypy
72+
73+
if [ $(uname) == "Darwin" ]; then
74+
IS_MACOS=1; IS_OSX=1;
75+
else
76+
# In the manylinux_2_24 image, based on Debian9, "python" is not installed
77+
# so link in something for the various system calls before PYTHON_EXE is set
78+
which python || export PATH=/opt/python/cp39-cp39/bin:$PATH
79+
80+
if [ "$MB_ML_LIBC" == "musllinux" ]; then
81+
IS_ALPINE=1;
82+
MB_ML_VER=${MB_ML_VER:-"_1_2"}
83+
else
84+
# Default Manylinux version
85+
MB_ML_VER=${MB_ML_VER:-2014}
86+
fi
87+
fi
88+
89+
# Work round bug in travis xcode image described at
90+
# https://github.com/direnv/direnv/issues/210
91+
shell_session_update() { :; }
92+
93+
# Workaround for https://github.com/travis-ci/travis-ci/issues/8703
94+
# suggested by Thomas K at
95+
# https://github.com/travis-ci/travis-ci/issues/8703#issuecomment-347881274
96+
unset -f cd
97+
unset -f pushd
98+
unset -f popd
99+
100+
# Build OpenBLAS
101+
source build-openblas.sh
102+
103+
source tools/build_prepare.sh

0 commit comments

Comments
 (0)