Skip to content

Commit

Permalink
Add Windows, fix Mac builds
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Jun 18, 2024
1 parent f23068f commit 6bc3378
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 21 deletions.
67 changes: 60 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ on:


jobs:
build_wheels:
build_linux:
runs-on: ubuntu-latest # Use a Linux runner
env:
PYQRACK_SHARED_LIB_PATH: "/home/runner/work/pyqrack/pyqrack/qrack/build/libqrack_pinvoke.so"
strategy:
matrix:
platform:
Expand Down Expand Up @@ -64,7 +62,7 @@ jobs:
mkdir build
cd build
cmake -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DQBCAPPOW=12 -DCPP_STD=14 ..
make all
make qrack_pinvoke
- name: Build Qrack Linux ARM64
if: matrix.platform == 'linux_aarch64' || matrix.platform == 'linux_armv7l'
Expand All @@ -73,7 +71,7 @@ jobs:
mkdir build
cd build
cmake -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DENABLE_COMPLEX_X2=OFF -DQBCAPPOW=12 -DCPP_STD=14 ..
make all
make qrack_pinvoke
- name: Build Qrack MacOS
if: matrix.platform == 'macosx_10_4_universal2'
Expand All @@ -82,12 +80,67 @@ jobs:
mkdir build
cd build
cmake -DQBCAPPOW=12 -DCPP_STD=14 ..
make all
make qrack_pinvoke
- name: Build Wheel
run: |
mkdir pyqrack/qrack_system/qrack_lib
cp $PYQRACK_SHARED_LIB_PATH pyqrack/qrack_system/qrack_lib/
cp qrack/build/libqrack_pinvoke.* pyqrack/qrack_system/qrack_lib/
python setup.py bdist_wheel --plat-name=${{ matrix.platform }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: pyqrack-${{ matrix.platform }}
path: dist/

build_windows:
runs-on: windows-latest # Use a Linux runner
strategy:
matrix:
platform:
- win-amd64
dependencies: [vcpkg]
steps:
- name: Checkout PyQrack
uses: actions/checkout@v4

- name: Checkout Qrack
uses: actions/checkout@v4
with:
repository: 'unitaryfund/qrack'
path: qrack

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Mount vcpkg cache
uses: actions/cache@v4
with:
path: "~/.cache/vcpkg/archives"
key: vcpkg-${{ matrix.os }}

- name: Install vcpkg dependencies
run: |
vcpkg install opencl
- name: Build Qrack Windows x86-64
if: matrix.platform == 'win-amd64'
run: |
cd qrack
mkdir build
cd build
powershell -c "Invoke-WebRequest -Uri 'https://github.com/ckormanyos/xxd/releases/download/v1.1/xxd-win64-msvc.zip' -OutFile 'xxd-win64-msvc.zip'"
powershell -c "Expand-Archive -Path xxd-win64-msvc.zip -DestinationPath ."
cmake .. -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DXXD_BIN="xxd.exe" -DQBCAPPOW=12 -DCPP_STD=14
cmake --build . --config Release --target qrack_invoke
- name: Build Wheel
run: |
mkdir pyqrack/qrack_system/qrack_lib
copy qrack/build/Release/qrack_pinvoke.dll pyqrack/qrack_system/qrack_lib/
python setup.py bdist_wheel --plat-name=${{ matrix.platform }}
- name: Upload Artifacts
Expand Down
19 changes: 5 additions & 14 deletions pyqrack/qrack_system/qrack_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,14 @@
class QrackSystem:
def __init__(self):
path = pathlib.Path(__file__).absolute().parent
if _platform == "win32":
shared_lib_path = str(path / "qrack_lib/libqrack_pinvoke.dll")
else:
shared_lib_path = str(path / "qrack_lib/libqrack_pinvoke.so")
if os.environ.get('PYQRACK_SHARED_LIB_PATH') != None:
shared_lib_path = os.environ.get('PYQRACK_SHARED_LIB_PATH')
elif _platform == "darwin":
shared_lib_path = "/usr/local/lib/libqrack_pinvoke.dylib"
elif _platform == "win32":
shared_lib_path = "C:\\Program Files\\Qrack\\bin\\qrack_pinvoke.dll"
elif _platform != "linux" and _platform != "linux2":
print(
"No Qrack binary for your platform, attempting to use /usr/lib/libqrack_pinvoke.so"
)
print(
"You can choose the binary file to load with the environment variable: PYQRACK_SHARED_LIB_PATH"
)
shared_lib_path = str(path / "qrack_lib/qrack_pinvoke.dll")
elif _platform == "darwin":
shared_lib_path = str(path / "qrack_lib/qrack_pinvoke.dylib")
else:
shared_lib_path = str(path / "qrack_lib/libqrack_pinvoke.so")

try:
self.qrack_lib = CDLL(shared_lib_path)
Expand Down

0 comments on commit 6bc3378

Please sign in to comment.