diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2c28b44..eef60e1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -45,6 +45,37 @@ jobs: with: files: | ./wheelhouse/** + build_windows: + name: Build wheels on windows-latest ${{ matrix.python }} + runs-on: windows-latest + strategy: + matrix: + python: [ cp38-*, cp39-*, cp310-*, cp311-*, cp312-*, cp313-* ] + steps: + - uses: actions/checkout@v4 + # Used to host cibuildwheel + - uses: actions/setup-python@v4 + with: + python-version: | + 3.11 + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.21.3 + - name: Build wheels + env: + CIBW_BUILD: ${{ matrix.python }} + CIBW_BEFORE_BUILD: python -m pip install pip Cython ninja --upgrade + CIBW_ARCHS_WINDOWS: AMD64 + CIBW_SKIP: pp* + run: python -m cibuildwheel --output-dir wheelhouse + - name: Install dependencies + run: python -m pip install setuptools wheel twine + - name: Publish to PyPI + run: twine upload -u __token__ -p ${{ secrets.PYPI_ACCESS_TOKEN }} ./wheelhouse/* + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + ./wheelhouse/** build_mac: name: Build wheels on macos-14 runs-on: macos-14 diff --git a/_custom_build.py b/_custom_build.py index aff3436..d31bc2d 100644 --- a/_custom_build.py +++ b/_custom_build.py @@ -57,29 +57,39 @@ def build_cmake(self, ext): config = 'Debug' if self.debug else 'Release' num_cpus = 4 + try: + num_cpus = multiprocessing.cpu_count() + except NotImplementedError: + pass + if os.name == "posix": - try: - num_cpus = multiprocessing.cpu_count() - except NotImplementedError: - pass CMAKE_GENERATOR = "Unix Makefiles" + cmake_args = [ + '-G', CMAKE_GENERATOR, + f'-DCMAKE_BUILD_TYPE={config}', + str(Path(ext.name).absolute()) # src directory path + ] + build_args = [ + '--config', config, + '--', f'-j{num_cpus}' + ] elif os.name == "nt": - CMAKE_GENERATOR = "MinGW Makefiles" + # On Windows, use Ninja or Visual Studio generator + # Ninja is preferred for better compatibility with cibuildwheel + CMAKE_GENERATOR = "Ninja" + cmake_args = [ + '-G', CMAKE_GENERATOR, + f'-DCMAKE_BUILD_TYPE={config}', + str(Path(ext.name).absolute()) # src directory path + ] + build_args = [ + '--config', config, + '--parallel', str(num_cpus) + ] else: print("Unsupported OS: " + os.name) sys.exit(1) - cmake_args = [ - '-G', CMAKE_GENERATOR, - f'-DCMAKE_BUILD_TYPE={config}', - Path(ext.name).absolute() # src directory path - ] - - build_args = [ - '--config', config, - '--', f'-j{num_cpus}' - ] - os.chdir(str(build_temp)) self.spawn(['cmake', str(cwd)] + cmake_args) if not self.dry_run: diff --git a/src/search/bliss/timer.cc b/src/search/bliss/timer.cc index 070f1a1..fbb26b6 100644 --- a/src/search/bliss/timer.cc +++ b/src/search/bliss/timer.cc @@ -1,5 +1,9 @@ +#ifdef _WIN32 +#include +#else #include #include +#endif #include "timer.h" /* @@ -24,6 +28,47 @@ namespace bliss { +#ifdef _WIN32 +// Windows implementation using GetProcessTimes +Timer::Timer() +{ + reset(); +} + +void Timer::reset() +{ + FILETIME creationTime, exitTime, kernelTime, userTime; + if (GetProcessTimes(GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime)) { + ULARGE_INTEGER kt, ut; + kt.LowPart = kernelTime.dwLowDateTime; + kt.HighPart = kernelTime.dwHighDateTime; + ut.LowPart = userTime.dwLowDateTime; + ut.HighPart = userTime.dwHighDateTime; + // Convert 100-nanosecond intervals to seconds + start_time = (double)(kt.QuadPart + ut.QuadPart) / 10000000.0; + } else { + start_time = 0.0; + } +} + +double Timer::get_duration() +{ + FILETIME creationTime, exitTime, kernelTime, userTime; + if (GetProcessTimes(GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime)) { + ULARGE_INTEGER kt, ut; + kt.LowPart = kernelTime.dwLowDateTime; + kt.HighPart = kernelTime.dwHighDateTime; + ut.LowPart = userTime.dwLowDateTime; + ut.HighPart = userTime.dwHighDateTime; + // Convert 100-nanosecond intervals to seconds + double current_time = (double)(kt.QuadPart + ut.QuadPart) / 10000000.0; + return current_time - start_time; + } + return 0.0; +} + +#else +// Unix/Linux implementation using times() static const double numTicksPerSec = (double)(sysconf(_SC_CLK_TCK)); Timer::Timer() @@ -52,5 +97,6 @@ double Timer::get_duration() numTicksPerSec; return intermediate - start_time; } +#endif } // namespace bliss