Skip to content

Commit

Permalink
Try another tack for windows scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsg committed Jul 9, 2024
1 parent d762b56 commit 0fb517a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .kokoro/presubmit.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cd ..
call git config --global --add safe.directory C:/tmpfs/src/github/python-crc32c
call git submodule update --recursive || goto :error

@echo "Build Wheel"
@echo "Build Wheels"
call scripts\windows\build.bat || goto :error

@echo "Run Tests"
Expand Down
29 changes: 10 additions & 19 deletions scripts/windows/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ set CMAKE_GENERATOR="Visual Studio 17 2022"
set CONFIGURATION=RelWithDebInfo
set CRC32C_INSTALL_PREFIX=%cd%\build\%CONFIGURATION%

@rem Path to cmake, env var to make it easier to point to a specific version
set cmake=cmake

@rem Iterate through supported Python versions.
@rem Unfortunately pyenv for Windows has an out-of-date versions list, and
@rem choco won't install multiple versions at the same time. As a
@rem workaround, we will fully uninstall and reinstall Python every iteration.
FOR %%P IN (3.8.19, 3.9.19, 3.10.14, 3.11.9, 3.12.4) DO (

echo "Uninstalling existing Python"
choco uninstall python
@rem Unfortunately pyenv for Windows has an out-of-date versions list. Choco's
@rem installer seems to have some problems with installing multiple versions at
@rem once, but it can be coaxed to try anyways with --force.
FOR %%P IN (3.8.10, 3.9.13, 3.10.11, 3.11.9, 3.12.4) DO (

echo "Installing Python version %%P"
choco install python --version=%%P -y
choco install python --version=%%P -y --force --no-progress

echo "Installing cmake for Python %%P"
py -%%P -m pip install cmake
Expand All @@ -55,9 +49,9 @@ FOR %%P IN (3.8.19, 3.9.19, 3.10.14, 3.11.9, 3.12.4) DO (

echo "Running cmake with Generator: %CMAKE_GENERATOR%, Platform: x64, Install Prefix: %CRC32C_INSTALL_PREFIX%"

%cmake% -G %CMAKE_GENERATOR% -A x64 -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=yes -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0 -DCMAKE_INSTALL_PREFIX:PATH=%CRC32C_INSTALL_PREFIX% ..
cmake -G %CMAKE_GENERATOR% -A x64 -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=yes -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0 -DCMAKE_INSTALL_PREFIX:PATH=%CRC32C_INSTALL_PREFIX% ..

%cmake% --build . --config "%CONFIGURATION%" --target install
cmake --build . --config "%CONFIGURATION%" --target install

dir %CRC32C_INSTALL_PREFIX% /b /s
popd
Expand All @@ -66,14 +60,11 @@ FOR %%P IN (3.8.19, 3.9.19, 3.10.14, 3.11.9, 3.12.4) DO (
echo "Copying Binary to root: %CRC32C_INSTALL_PREFIX%\bin\crc32c.dll"
copy %CRC32C_INSTALL_PREFIX%\bin\crc32c.dll .

py -%%P-%%V -m pip install --upgrade pip setuptools wheel
py -%%P -m pip install --upgrade pip setuptools wheel
echo "Building C extension"
py -%%P-%%V setup.py build_ext -v --include-dirs=%CRC32C_INSTALL_PREFIX%\include --library-dirs=%CRC32C_INSTALL_PREFIX%\lib
py -%%P setup.py build_ext -v --include-dirs=%CRC32C_INSTALL_PREFIX%\include --library-dirs=%CRC32C_INSTALL_PREFIX%\lib
echo "Building Wheel"
py -%%P-%%V -m pip wheel . --wheel-dir wheels/

echo "Running tests for Python %%P"
call %~dp0\test.bat %%P
py -%%P -m pip wheel . --wheel-dir wheels/
)

echo "Windows build has completed successfully"
Expand Down
16 changes: 6 additions & 10 deletions scripts/windows/test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
@rem This test file runs for one Python version at a time, and is intended to
@rem be called from within the build loop.

set PYTHON_VERSION=%1
if "%PYTHON_VERSION%"=="" (
echo "Python version was not provided, using Python 3.10"
set PYTHON_VERSION=3.10
)
FOR %%P IN (3.8.10, 3.9.13, 3.10.11, 3.11.9, 3.12.4) DO (
py -%%P -m pip install --no-index --find-links=wheels google-crc32c --force-reinstall

py -%PYTHON_VERSION% -m pip install --no-index --find-links=wheels google-crc32c --force-reinstall
py -%%P ./scripts/check_crc32c_extension.py

py -%PYTHON_VERSION% ./scripts/check_crc32c_extension.py

py -%PYTHON_VERSION% -m pip install pytest
py -%PYTHON_VERSION% -m pytest tests
py -%%P -m pip install pytest
py -%%P -m pytest tests
)

0 comments on commit 0fb517a

Please sign in to comment.