Skip to content

Commit

Permalink
BLD: start openblas wheel in cibuildwheel [wheel build][skip cirrus]
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfaff committed Oct 16, 2023
1 parent ac094cd commit 8578647
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
get_commit_message:
name: Get commit message
runs-on: ubuntu-latest
if: github.repository == 'scipy/scipy'
if: github.repository == 'andyfaff/scipy'
outputs:
message: ${{ steps.commit_message.outputs.message }}
steps:
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ test-command = "bash {project}/tools/wheels/cibw_test_command.sh {project}"
manylinux-x86_64-image = "manylinux2014"
manylinux-aarch64-image = "manylinux2014"
before-build = "bash {project}/tools/wheels/cibw_before_build_linux.sh {project}"
environment = { PKG_CONFIG_PATH="$PWD/.openblas" }


[tool.cibuildwheel.macos]
before-build = "bash {project}/tools/wheels/cibw_before_build_macos.sh {project}"
Expand Down
13 changes: 6 additions & 7 deletions tools/wheels/cibw_before_build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ else
echo "Usage: $0 [--nightly] <project_dir>"
exit 1
fi

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

printenv
# Update license
cat $PROJECT_DIR/tools/wheels/LICENSE_linux.txt >> $PROJECT_DIR/LICENSE.txt

# Install Openblas
basedir=$(python tools/openblas_support.py $NIGHTLY_FLAG)
cp -r $basedir/lib/* /usr/local/lib
cp $basedir/include/* /usr/local/include
if [ NIGHTLY_FLAG=="--nightly"];then
python -m pip install --pre --upgrade --timeout=60 -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple scipy-openblas32
else
python -m pip install scipy_openblas32
fi
PYTHONPATH=tools/wheels python -c "import openblas; openblas.configure_scipy_openblas()"
25 changes: 25 additions & 0 deletions tools/wheels/openblas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import importlib


def configure_scipy_openblas(blas_variant='32'):
"""Create .openblas/scipy-openblas.pc
Requires a pre-installed scipy-openblas32 wheel from PyPI.
"""
basedir = os.getcwd()
openblas_dir = os.path.join(basedir, ".openblas")
pkg_config_fname = os.path.join(openblas_dir, "scipy-openblas.pc")

if os.path.exists(pkg_config_fname):
return None

module_name = f"scipy_openblas{blas_variant}"
try:
openblas = importlib.import_module(module_name)
except ModuleNotFoundError:
raise RuntimeError(f"'pip install {module_name} first")

os.makedirs(openblas_dir, exist_ok=True)
with open(pkg_config_fname, "wt", encoding="utf8") as fid:
fid.write(openblas.get_pkg_config().replace("\\", "/"))

0 comments on commit 8578647

Please sign in to comment.