Skip to content

Commit

Permalink
TST: Test with nightly OpenBLAS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
honno committed Jul 24, 2023
1 parent 1351bee commit 90034ad
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/linux_meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
meson_spin:
if: "github.repository == 'numpy/numpy'"
runs-on: ubuntu-latest
strategy:
matrix:
USE_NIGHTLY_OPENBLAS: [false, true]
env:
USE_NIGHTLY_OPENBLAS: ${{ matrix.USE_NIGHTLY_OPENBLAS }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
Expand All @@ -36,8 +41,13 @@ jobs:
run: |
pip install -r build_requirements.txt
# Install OpenBLAS
set -xe
chmod +x tools/wheels/cibw_before_build.sh
sudo RUNNER_OS=${{ runner.os }} tools/wheels/cibw_before_build.sh .
if [[ $USE_NIGHTLY_OPENBLAS == "true" ]]; then
sudo RUNNER_OS=${{ runner.os }} tools/wheels/cibw_before_build.sh .
else
sudo RUNNER_OS=${{ runner.os }} tools/wheels/cibw_before_build.sh .
fi
- name: Build
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
Expand Down
18 changes: 12 additions & 6 deletions tools/openblas_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

OPENBLAS_V = '0.3.23.dev'
OPENBLAS_LONG = 'v0.3.23-246-g3d31191b'
BASE_LOC = 'https://anaconda.org/multibuild-wheels-staging/openblas-libs'
BASEURL = f'{BASE_LOC}/{OPENBLAS_LONG}/download'
BASE_LOC = 'https://anaconda.org/scientific-python-nightly-wheels/openblas-libs'
SUPPORTED_PLATFORMS = [
'linux-aarch64',
'linux-x86_64',
Expand Down Expand Up @@ -91,7 +90,7 @@ def get_linux(arch):
return get_musllinux(arch)


def download_openblas(target, plat, ilp64):
def download_openblas(target, plat, ilp64, *, openblas_version=OPENBLAS_LONG):
osname, arch = plat.split("-")
fnsuffix = {None: "", "64_": "64_"}[ilp64]
filename = ''
Expand Down Expand Up @@ -120,7 +119,8 @@ def download_openblas(target, plat, ilp64):

if not suffix:
return None
filename = f'{BASEURL}/openblas{fnsuffix}-{OPENBLAS_LONG}-{suffix}'
BASEURL = f'{BASE_LOC}/{openblas_version}/download'
filename = f'{BASEURL}/openblas{fnsuffix}-{openblas_version}-{suffix}'
req = Request(url=filename, headers=headers)
try:
response = urlopen(req)
Expand All @@ -141,7 +141,7 @@ def download_openblas(target, plat, ilp64):
return typ


def setup_openblas(plat=get_plat(), ilp64=get_ilp64()):
def setup_openblas(plat=get_plat(), ilp64=get_ilp64(), nightly=False):
'''
Download and setup an openblas library for building. If successful,
the configuration script will find it automatically.
Expand All @@ -156,6 +156,10 @@ def setup_openblas(plat=get_plat(), ilp64=get_ilp64()):
if not plat:
raise ValueError('unknown platform')
typ = download_openblas(tmp, plat, ilp64)
openblas_version = "HEAD" if nightly else OPENBLAS_LONG
typ = download_openblas(
tmp, plat, ilp64, openblas_version=openblas_version
)
if not typ:
return ''
osname, arch = plat.split("-")
Expand Down Expand Up @@ -343,11 +347,13 @@ def test_version(expected_version=None):
parser.add_argument('--check_version', nargs='?', default='',
help='Check provided OpenBLAS version string '
'against available OpenBLAS')
parser.add_argument('--nightly', action='store_true',
help='If set, use nightly OpenBLAS build.')
args = parser.parse_args()
if args.check_version != '':
test_version(args.check_version)
elif args.test is None:
print(setup_openblas())
print(setup_openblas(nightly=args.nightly))
else:
if len(args.test) == 0 or 'all' in args.test:
test_setup(SUPPORTED_PLATFORMS)
Expand Down
31 changes: 29 additions & 2 deletions tools/wheels/cibw_before_build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
#!/bin/bash
set -xe

PROJECT_DIR="$1"
NIGHTLY_FLAG=""

usage() {
echo "Usage: $0 [--nightly] <project_dir>"
exit 1
}

TEMP=$(getopt -o n -l nightly -- "$@")
if [ $? != 0 ]; then
usage
fi

eval set -- "$TEMP"

while true ; do
case "$1" in
-n|--nightly)
NIGHTLY_FLAG="--nightly"; shift ;;
--) shift ; break ;;
esac
done

if [ -z "$1" ]; then
usage
else
PROJECT_DIR="$1"
fi

PLATFORM=$(PYTHONPATH=tools python -c "import openblas_support; print(openblas_support.get_plat())")

# Update license
Expand All @@ -15,7 +42,7 @@ fi

# Install Openblas
if [[ $RUNNER_OS == "Linux" || $RUNNER_OS == "macOS" ]] ; then
basedir=$(python tools/openblas_support.py)
basedir=$(python tools/openblas_support.py $NIGHTLY_FLAG)
if [[ $RUNNER_OS == "macOS" && $PLATFORM == "macosx-arm64" ]]; then
# /usr/local/lib doesn't exist on cirrus-ci runners
sudo mkdir -p /usr/local/lib /usr/local/include /usr/local/lib/cmake/openblas
Expand Down

0 comments on commit 90034ad

Please sign in to comment.