diff --git a/.github/workflows/punchboot-tools.yml b/.github/workflows/punchboot-tools.yml index 397d2316..fd91baf9 100644 --- a/.github/workflows/punchboot-tools.yml +++ b/.github/workflows/punchboot-tools.yml @@ -8,11 +8,22 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, windows-2022] + os: [windows-latest] steps: - uses: actions/checkout@v4 + - if: startsWith(matrix.os, 'windows') == true + name: Windows deps + uses: lukka/run-vcpkg@main + id: vcpkg + with: + pkgs: libusb + # This specifies the location of vcpkg, where it is going to be restored from cache, or create from scratch. + vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg' + # The Git commit id of vcpkg to be checked out. This is only needed because we are not using a submodule. + vcpkgGitCommitId: 'c9f906558f9bb12ee9811d6edc98ec9255c6cda5' + - name: Build wheels uses: pypa/cibuildwheel@v2.16.2 with: diff --git a/setup.py b/setup.py index a14738a0..e0cabf56 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,19 @@ """Punchboot setuptools configuration.""" +import platform from setuptools import setup, Extension # type: ignore pb_base_path: str = "tools/punchboot" +plat: str = platform.system() + +if plat == "Windows": + _libraries = ["libusb-1.0"] + _library_dirs = ["c:\\SPB_Data\\vcpkg\\installed\\x64-windows\\lib"] + _include_dirs = ["include", "c:\\SPB_Data\\vcpkg\\installed\\x64-windows\\include"] +else: + _libraries = ["usb-1.0"] + _library_dirs = [] + _include_dirs = ["include"] setup( name="punchboot", @@ -38,12 +49,13 @@ f"{pb_base_path}/api_slc.c", f"{pb_base_path}/api_stream.c", f"{pb_base_path}/usb.c", + f"{pb_base_path}/socket.c" if plat == "Linux" else "", f"{pb_base_path}/python_wrapper.c", f"{pb_base_path}/exceptions.c", ], - libraries=["libusb-1.0"], - library_dirs=["c:\\SPB_Data\\vcpkg\\installed\\x64-windows\\lib"], - include_dirs=["include", "c:\\SPB_Data\\vcpkg\\installed\\x64-windows\\include"], + libraries=_libraries, + library_dirs=_library_dirs, + include_dirs=_include_dirs, ) ], install_requires=["semver>=3,<4", "click>=8,<9"], diff --git a/tools/punchboot/socket.c b/tools/punchboot/socket.c index b7b5bd46..75cab304 100644 --- a/tools/punchboot/socket.c +++ b/tools/punchboot/socket.c @@ -13,14 +13,9 @@ #include #include -#ifdef WINDOWS -#include -#include -#else #include #include #include -#endif #include "api.h" #include "socket.h"