Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ for_test/
test.exe
dist/
build/
sbom-work/
libs/
# These are artifacts when using editable builds
local/lib
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## OpenBLAS v0.3.34 (v0.3.34)

### 0.3.34.481.7 (2026-12-04)

- Add a sbom cdx.json attestation file

### 0.3.34.481.6 (2026-11-30)

- Use the correct lapack headers for windows builds (function names with
Expand Down
4 changes: 4 additions & 0 deletions ci-repair-wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ else
# copy libs/openblas*.tar.gz to dist/
cp libs/openblas*.tar.gz /output/
fi

# PEP 770 SBOM, from what tools/build_steps.sh recorded during the build.
# On Linux this sits next to the one auditwheel writes for anything it grafts.
$(command -v python3 || command -v python) tools/make_sbom.py inject sbom-work/sbom-build.json "$1"/*.whl
15 changes: 13 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "scipy-openblas64"
# 0.3.34-481-g5137bb62
version = "0.3.34.481.6"
version = "0.3.34.481.7"
requires-python = ">=3.7"
description = "Provides OpenBLAS for python packaging"
readme = "README.md"
Expand Down Expand Up @@ -51,12 +51,23 @@ environment-pass = [
# On emulated architectures, RUNNER_ARCH makes manylinux-install-clang install a
# compiler for the native architecture, which will be much faster.
"RUNNER_ARCH",

# Recorded in the wheel's SBOM by tools/make_sbom.py
"GITHUB_SHA",
"GITHUB_REPOSITORY",
"GITHUB_SERVER_URL",
"GITHUB_RUN_ID",
"GITHUB_RUN_ATTEMPT",
"GITHUB_WORKFLOW_REF",
]

[tool.cibuildwheel.android]
# The Linux code in ci-repair-wheel.sh isn't relevant to Android, so use the default
# repair command from the cibuildwheel documentation.
repair-wheel-command = "auditwheel repair --ldpaths {ldpaths} -w {dest_dir} {wheel}"
repair-wheel-command = [
"auditwheel repair --ldpaths {ldpaths} -w {dest_dir} {wheel}",
"python tools/make_sbom.py inject sbom-work/sbom-build.json {dest_dir}/*.whl",
]

# Mobile platforms only support Python test-commands, not shell scripts.
test-command = """python -c '
Expand Down
57 changes: 57 additions & 0 deletions tools/build_steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ function clean_code {
function patch_source {
# Runs inside OpenBLAS directory
# Make the patches by git format-patch <old commit>
# tools/make_sbom.py reads the list of what was applied
local applied="$ROOT_DIR/sbom-work/applied-patches.txt"
mkdir -p "$(dirname "$applied")"
: > "$applied"
for f in ../patches-common/*.patch ../patches/*.patch; do
[ -e "$f" ] || continue
echo applying patch $f
git apply "$f"
echo "$f" >> "$applied"
done
}

Expand Down Expand Up @@ -213,6 +218,10 @@ function build_lib {
echo "the utest samin/damin have been temporarily disabled."
echo "QEMU does not support the 'lper' /'lpdr' instructions used"
fi
# The tree is final now: patched, and edited above. Save its diff for the
# SBOM before compiling (tools/make_sbom.py).
$(command -v python3 || command -v python) "$ROOT_DIR/tools/make_sbom.py" \
snapshot --out "$ROOT_DIR/sbom-work/openblas-source.diff"
if [ -n "$dynamic_list" ]; then
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \
make BUFFERSIZE=20 QUIET_MAKE=1 \
Expand Down Expand Up @@ -259,6 +268,9 @@ function build_lib {
$BUILD_PREFIX/lib/libscipy_openblas*.dylib
fi

record_sbom_build "$plat" "$interface64" "$target" "$dynamic_list" \
"$interface_flags" "$compat_lib"

local out_name="openblas.tar.gz"
pushd $BUILD_PREFIX
tar zcvf $ROOT_DIR/libs/$out_name \
Expand All @@ -269,3 +281,48 @@ function build_lib {
lib/cmake/openblas
popd
}

function record_sbom_build {
# Write sbom-work/sbom-build.json, from which ci-repair-wheel.sh puts an SBOM
# into the wheel (tools/make_sbom.py). It has to run here, in the build
# environment: this is the only place that knows which compiler and which
# libgfortran.a went into the library.
local plat=$1 interface64=$2 target=$3 dynamic_list=$4 flags=$5
local compat_lib=$6
local py
py=$(command -v python3 || command -v python)
local args=(
--out "$ROOT_DIR/sbom-work/sbom-build.json"
--config "MB_ML_LIBC=$MB_ML_LIBC" --config "PLAT=$plat"
--config "INTERFACE64=$interface64" --config "TARGET=$target"
--config "DYNAMIC_LIST=$dynamic_list" --config "make_flags=$flags"
--config "CFLAGS=$CFLAGS" --config "NIGHTLY=${NIGHTLY:-false}"
--tool "cc=${CC:-cc}" --tool "ld=${LD:-ld}"
)
if [ "$MB_ML_LIBC" != "android" ]; then
args+=(--tool "fc=${FC:-gfortran}")
fi
if [ -n "$compat_lib" ]; then
local compat_dir=$(dirname "$compat_lib")
args+=(--static "gfortran_compat=$ROOT_DIR/tools/gfortran_compat.c,license=BSD-3-Clause")
# Only INTERFACE64 builds take objects out of libgfortran.a
if [ -s "$compat_dir/members.txt" ]; then
local gcc_ver=$(${FC:-gfortran} -dumpfullversion 2>/dev/null \
|| ${FC:-gfortran} -dumpversion)
local spec="libgfortran=$(cat "$compat_dir/archive.txt"),version=$gcc_ver"
spec+=",members_file=$compat_dir/members.txt"
if [ "$MB_ML_LIBC" == "macosx" ]; then
# Not from a system package; from the pinned conda-forge one
local pkg sha
read -r pkg sha < <(macos_libgfortran_pkg "$plat")
local file=$(basename "$pkg" .tar.bz2)
local subdir=${pkg%%/*}
local name=${file%-*-*} build=${file##*-}
spec+=",purl=pkg:conda/conda-forge/$name@$gcc_ver?build=$build&subdir=$subdir"
spec+=",url=https://conda.anaconda.org/conda-forge/$pkg"
fi
args+=(--static "$spec")
fi
fi
"$py" "$ROOT_DIR/tools/make_sbom.py" collect "${args[@]}"
}
31 changes: 29 additions & 2 deletions tools/build_steps_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,20 @@ if "%NIGHTLY%"=="true" (
)
if errorlevel 1 exit /b 1

REM Patch
REM Patch, logging what was applied for tools\make_sbom.py. Its records go
REM in sbom-work, not build: a build directory in the repo root would shadow
REM the PyPA build package in the `python -m build` below.
if not exist ..\sbom-work mkdir ..\sbom-work
if exist ..\sbom-work\applied-patches.txt del ..\sbom-work\applied-patches.txt
type nul > ..\sbom-work\applied-patches.txt
set patch_rc=0
for %%f in (..\patches-common\*.patch ..\patches\*.patch ..\patches-windows\*.patch) do (
git apply --ignore-whitespace %%f
if errorlevel 1 set patch_rc=1
if errorlevel 1 (
set patch_rc=1
) else (
>>..\sbom-work\applied-patches.txt echo %%f
)
)
if not "%patch_rc%"=="0" exit /b 1

Expand Down Expand Up @@ -134,6 +143,11 @@ if "%if_bits%"=="64" (

REM Create build directory and navigate to it
if exist build (rmdir /S /Q build || exit /b 1)

REM The tree is final now: patched, and CMakeLists.txt edited above. Save its
REM diff for the SBOM before compiling (tools\make_sbom.py).
python ..\tools\make_sbom.py snapshot --out ..\sbom-work\openblas-source.diff
if errorlevel 1 exit /b 1
mkdir build || exit /b 1 & cd build || exit /b 1

echo Setting up %vcvars_arch% Developer Command Prompt and running CMake...
Expand Down Expand Up @@ -269,6 +283,16 @@ if errorlevel 1 exit /b 1
echo Build complete. Returning to Batch.

cd ../..

REM Record the toolchain for the wheel's SBOM (tools/make_sbom.py). The flang
REM runtime is the one third-party archive linked into the DLL.
python tools\make_sbom.py collect --out sbom-work\sbom-build.json ^
--config "PLAT=%PLAT%" --config "INTERFACE_BITS=%if_bits%" ^
--config "cmake_flags=%arch_flags% %interface_flags%" ^
--config "C_FLAGS_RELEASE=%release_flags%" --config "NIGHTLY=%NIGHTLY%" ^
--tool cc=clang-cl --tool fc=flang --tool ld=lld-link ^
--static "flang-rt=%FLANG_RT_DIR%\flang_rt.runtime.dynamic.lib,version=%LLVM_VERSION%,purl=pkg:github/llvm/llvm-project@llvmorg-%LLVM_VERSION%,url=https://github.com/llvm/llvm-project/releases/tag/llvmorg-%LLVM_VERSION%"
if errorlevel 1 exit /b 1
if "%if_bits%"=="32" (
echo Rewrite to scipy_openblas32
set out_pyproject=pyproject_64_32.toml
Expand Down Expand Up @@ -392,6 +416,9 @@ if not defined WHEEL_FILE (
exit /b 1
)

python tools\make_sbom.py inject sbom-work\sbom-build.json %WHEEL_FILE%
if errorlevel 1 exit /b 1

echo Installing wheel: %WHEEL_FILE%
pip install "%WHEEL_FILE%"
if errorlevel 1 exit /b 1
Expand Down
6 changes: 6 additions & 0 deletions tools/gfortran_compat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ function build_gfortran_compat {
wanted="_gfortran_pow_r4_i8 _gfortran_pow_r8_i8"
fi

# tools/make_sbom.py reads these to list the libgfortran objects that
# end up inside the library: "<member> <symbol>" per line.
: > members.txt
echo "$archive" > archive.txt

local sym member
for sym in $wanted; do
# `|| true`: grep exits 1 when the member is absent, and under
Expand Down Expand Up @@ -227,6 +232,7 @@ function build_gfortran_compat {
echo "gfortran_compat: $member is not self-contained: $undef" >&2
cd "$here"; return 1
fi
echo "$member $sym" >> members.txt
echo "gfortran_compat: took $member for $sym" >&2
done

Expand Down
Loading