Skip to content

Commit

Permalink
update windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
peekxc committed Dec 7, 2023
1 parent aed42aa commit 335c650
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 30 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,24 @@ jobs:
python -m pytest tests/ --cov=primate --benchmark-skip
coverage report -m
- name: Build a wheel
run: |
run: |
python -m pip wheel --no-deps -w wheelhouse .
delvewheel repair -w dist -v wheelhouse/*.whl
# delvewheel repair -w dist -v wheelhouse/*.whl
# python -m build --wheel
# $env:wheel_name=Get-ChildItem -Path dist/* -Include *.whl
# delvewheel repair -w dist $env:wheel_name
- name: Repair the wheel
run: |
bash tools/repair_windows.sh
- name: Uninstall the package
run: |
python -m pip uninstall primate -y
- name: Install the wheel
# python -m pip install $(find "$output_dir" -type f | grep *primate*.whl)
# python -m pip install $env:wheel_name
run: |
python -m pip install dist/*.whl
# python -m pip install dist/*.whl
- name: Wheel dry-run
run: |
python -c "import primate; print(primate.__version__)"
Expand Down
5 changes: 4 additions & 1 deletion tools/cibw_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
# Get-Command rc.exe | Format-Table -AutoSize

choco install rtools -y --no-progress --force --version=4.0.0.20220206
set PATH=C:\rtools40\ucrt64\bin\;%PATH%

export PATH=$PATH:/c/msys64/usr/bin:/c/msys64/mingw64/bin
export PATH=$PATH:/c:/rtools40/ucrt64/bin:$PATH
# set PATH=C:\rtools40\ucrt64\bin\;%PATH%
g++ --version

# $env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
Expand Down
71 changes: 45 additions & 26 deletions tools/repair_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,48 @@ set -xe
WHEEL="$1"
DEST_DIR="$2"

## Need delvewheel for this
pip install delvewheel

# create a temporary directory in the destination folder and unpack the wheel into there
pushd $DEST_DIR
mkdir -p tmp
pushd tmp
wheel unpack $WHEEL
pushd primate*

# To avoid DLL hell, the file name of libopenblas that's being vendored with
# the wheel has to be name-mangled. delvewheel is unable to name-mangle PYD
# containing extra data at the end of the binary, which frequently occurs when
# building with mingw.
# We therefore find each PYD in the directory structure and strip them.
for f in $(find ./primate* -name '*.pyd'); do strip $f; done

# now repack the wheel and overwrite the original
wheel pack .
mv -fv *.whl $WHEEL

cd $DEST_DIR
rm -rf tmp

# the libopenblas.dll is placed into this directory in the cibw_before_build script.
delvewheel repair -v -w $DEST_DIR $WHEEL
strip .local/bin/*.dll

# Make sure to leave the wheel in the same directory
wheeldir=$(dirname $WHEELNAME)
pushd $wheeldir
# Unpack the wheel and strip any .pyd DLLs inside
wheel unpack $WHEELNAME
rm $WHEELNAME
strip python_flint-*/flint/*.pyd
wheel pack python_flint-*
popd

# Make the wheel relocatable. This will fail with an error message about
# --no-mangle if strip has not been applied to all mingw64-created .dll and
# .pyd files that are needed for the wheel.
delvewheel repair $WHEELNAME \
-w $WHEELHOUSE \
--add-path .local/bin

# ## Need delvewheel for this
# pip install delvewheel

# # create a temporary directory in the destination folder and unpack the wheel into there
# pushd $DEST_DIR
# mkdir -p tmp
# pushd tmp
# wheel unpack $WHEEL
# pushd primate*

# # To avoid DLL hell, the file name of libopenblas that's being vendored with
# # the wheel has to be name-mangled. delvewheel is unable to name-mangle PYD
# # containing extra data at the end of the binary, which frequently occurs when
# # building with mingw.
# # We therefore find each PYD in the directory structure and strip them.
# for f in $(find ./primate* -name '*.pyd'); do strip $f; done

# # now repack the wheel and overwrite the original
# wheel pack .
# mv -fv *.whl $WHEEL

# cd $DEST_DIR
# rm -rf tmp

# # the libopenblas.dll is placed into this directory in the cibw_before_build script.
# delvewheel repair -v -w $DEST_DIR $WHEEL

0 comments on commit 335c650

Please sign in to comment.