Skip to content

cherry-pick changes to shrink wheel #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion 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"
# v0.3.28
version = "0.3.28.0.1"
version = "0.3.28.0.2"
requires-python = ">=3.7"
description = "Provides OpenBLAS for python packaging"
readme = "README.md"
Expand Down
37 changes: 15 additions & 22 deletions tools/build_steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ function build_lib {
# BUILD_PREFIX - install suffix e.g. "/usr/local"
# GFORTRAN_DMG
# MB_ML_VER
echo running build_lib
set -x
local plat=${1:-$PLAT}
local interface64=${2:-$INTERFACE64}
Expand All @@ -72,16 +71,13 @@ function build_lib {
# Make directory to store built archive
if [ -n "$IS_OSX" ]; then
# Do build, add gfortran hash to end of name
echo building on macox since IS_OSX is defined
wrap_wheel_builder do_build_lib "$plat" "gf_${GFORTRAN_SHA:0:7}" "$interface64" "$nightly"
return
fi
# Manylinux wrapper
local libc=${MB_ML_LIBC:-manylinux}
local docker_image=quay.io/pypa/${libc}${manylinux}_${plat}
echo pulling image ${docker_image}
docker pull $docker_image
echo done pulling image, starting docker run
# Docker sources this script, and runs `do_build_lib`
docker run --rm \
-e BUILD_PREFIX="$BUILD_PREFIX" \
Expand All @@ -93,7 +89,6 @@ function build_lib {
-e MB_ML_LIBC=${libc} \
-v $PWD:/io \
$docker_image /io/tools/docker_build_wrap.sh
echo done docker run of docker_build_wrap.sh
}

function patch_source {
Expand All @@ -102,7 +97,7 @@ function patch_source {
for f in $(ls ../patches); do
echo applying patch $f
git apply ../patches/$f
done
done
}

function do_build_lib {
Expand All @@ -124,34 +119,34 @@ function do_build_lib {
case $(get_os)-$plat in
Linux-x86_64)
local bitness=64
local target_flags="TARGET=PRESCOTT"
local target="PRESCOTT"
local dynamic_list="PRESCOTT NEHALEM SANDYBRIDGE HASWELL SKYLAKEX"
;;
Darwin-x86_64)
local bitness=64
local target_flags="TARGET=CORE2"
local target="CORE2"
# Pick up the gfortran runtime libraries
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH
;;
*-i686)
local bitness=32
local target_flags="TARGET=PRESCOTT"
local target="PRESCOTT"
local dynamic_list="PRESCOTT NEHALEM SANDYBRIDGE HASWELL"
;;
Linux-aarch64)
local bitness=64
local target_flags="TARGET=ARMV8"
local target="ARMV8"
;;
Darwin-arm64)
local bitness=64
local target_flags="TARGET=VORTEX"
local target="VORTEX"
;;
*-s390x)
local bitness=64
;;
*-ppc64le)
local bitness=64
local target_flags="TARGET=POWER8"
local target="POWER8"
;;
*) echo "Strange plat value $plat"; exit 1 ;;
esac
Expand All @@ -176,21 +171,19 @@ function do_build_lib {
patch_source
echo start building
if [ -v dynamic_list ]; then
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized -fno-ident" \
make BUFFERSIZE=20 DYNAMIC_ARCH=1 \
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \
make BUFFERSIZE=20 DYNAMIC_ARCH=1 QUIET_MAKE=1 \
USE_OPENMP=0 NUM_THREADS=64 \
DYNAMIC_LIST="$dynamic_list" \
BINARY=$bitness $interface_flags $target_flags shared 2>&1 1>/dev/null
BINARY="$bitness" $interface_flags \
TARGET="$target"
else
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized -fno-ident" \
make BUFFERSIZE=20 DYNAMIC_ARCH=1 \
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \
make BUFFERSIZE=20 DYNAMIC_ARCH=1 QUIET_MAKE=1 \
USE_OPENMP=0 NUM_THREADS=64 \
BINARY=$bitness $interface_flags $target_flags shared 2>&1 1>/dev/null
BINARY="$bitness" $interface_flags \
TARGET="$target"
fi
echo done building, now testing
make BUFFERSIZE=20 DYNAMIC_ARCH=1 \
USE_OPENMP=0 NUM_THREADS=64 \
BINARY=$bitness $interface_flags $target_flags tests
make PREFIX=$BUILD_PREFIX $interface_flags install
popd
if [ "$nightly" = "1" ]; then
Expand Down
19 changes: 15 additions & 4 deletions tools/download-wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_wheel_names(package, version):
return soup.find_all(string=tmpl)


def download_wheels(package, version, wheelhouse):
def download_wheels(package, version, wheelhouse, test=False):
"""Download release wheels.

The release wheels for the given package version are downloaded
Expand All @@ -87,8 +87,15 @@ def download_wheels(package, version, wheelhouse):
wheel_path = os.path.join(wheelhouse, wheel_name)
with open(wheel_path, "wb") as f:
with http.request("GET", wheel_url, preload_content=False,) as r:
print(f"{i + 1:<4}{wheel_name}")
shutil.copyfileobj(r, f)
info = r.info()
length = int(info.get('Content-Length', '0'))
if length == 0:
length = 'unknown size'
else:
length = f"{(length / 1024 / 1024):.2f}MB"
print(f"{i + 1:<4}{wheel_name} {length}")
if not test:
shutil.copyfileobj(r, f)
print(f"\nTotal files downloaded: {len(wheel_names)}")


Expand All @@ -107,6 +114,10 @@ def download_wheels(package, version, wheelhouse):
default=os.path.join(os.getcwd(), "release", "installers"),
help="Directory in which to store downloaded wheels\n"
"[defaults to <cwd>/release/installers]")
parser.add_argument(
"-t", "--test",
action = 'store_true',
help="only list available wheels, do not download")

args = parser.parse_args()

Expand All @@ -116,4 +127,4 @@ def download_wheels(package, version, wheelhouse):
f"{wheelhouse} wheelhouse directory is not present."
" Perhaps you need to use the '-w' flag to specify one.")

download_wheels(args.package, args.version, wheelhouse)
download_wheels(args.package, args.version, wheelhouse, test=args.test)
Loading