Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI release: activate windows builds #45

Merged
merged 26 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
692156b
ci release: activate windows builds
benbovy Sep 3, 2024
9d99ec0
try fix openssl not found on windows
benbovy Sep 3, 2024
4169579
cache openssl build and fix vcpkg dir not found?
benbovy Sep 3, 2024
eafbe95
disable windows x86 arch
benbovy Sep 3, 2024
2ceb155
openssl install dir was not right yet
benbovy Sep 3, 2024
8258d8a
change openssl vcpkg triplet
benbovy Sep 3, 2024
522b501
change triplet again (release, dynamic library)
benbovy Sep 3, 2024
01ed614
more log
benbovy Sep 3, 2024
4f01a10
wrong triplet
benbovy Sep 3, 2024
0eb26b8
trying to understand how vcpkg works
benbovy Sep 4, 2024
be60e33
debug prints
benbovy Sep 4, 2024
e9f49f7
next try figuring out vcpkg dir tree
benbovy Sep 4, 2024
2b9922d
install s2geometry openssl abseil with vcpkg
benbovy Sep 4, 2024
3de1470
Try forcing msvc toolchain on windows
benbovy Sep 4, 2024
32fb45b
find s2geography library (cmake prefix path)
benbovy Sep 4, 2024
7a8def4
fix cmake prefix path
benbovy Sep 4, 2024
f8e0089
don't know why cmake doesn't find s2geography
benbovy Sep 4, 2024
b8ff0d7
typo
benbovy Sep 4, 2024
c8a9702
weird char escape
benbovy Sep 4, 2024
a80053e
patch s2geography (add include dir for target)
benbovy Sep 5, 2024
0487fba
patch files were actually not found
benbovy Sep 5, 2024
ff6c3cc
windows weird path char escape again?
benbovy Sep 5, 2024
2c57c81
right patch path this time?
benbovy Sep 5, 2024
d46c1bf
repair wheel: missing path to vcpkg installed libs?
benbovy Sep 5, 2024
288ad60
nit header comment
benbovy Sep 5, 2024
a4abc55
clean-up
benbovy Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ jobs:
# - os: windows-2019
# arch: x86
# msvc_arch: x86
# - os: windows-2019
# arch: AMD64
# msvc_arch: x64
- os: windows-2019
arch: AMD64
msvc_arch: x64
- os: macos-13
arch: x86_64
cmake_osx_architectures: x86_64
Expand Down Expand Up @@ -82,6 +82,30 @@ jobs:
ls -all .
shell: bash

# for some reason mingw is selected by cmake within cibuildwheel before_all
- name: Prepare compiler environment for Windows
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Cache vcpkg install directory (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: "c:\\vcpkg\\installed"
key: vcpkg-${{ runner.os }}

- name: Install abseil openssl and s2geometry (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
vcpkg install s2geometry:x64-windows --x-install-root=$VCPKG_INSTALLATION_ROOT/installed
vcpkg list
ls /c/vcpkg/installed
ls /c/vcpkg/installed/x64-windows
ls /c/vcpkg/installed/x64-windows/bin

- name: Build wheels
uses: pypa/[email protected]
env:
Expand All @@ -107,16 +131,18 @@ jobs:
CMAKE_OSX_ARCHITECTURES='${{ matrix.cmake_osx_architectures }}'
CIBW_ENVIRONMENT_WINDOWS:
DEPENDENCIES_DIR='${{ runner.temp }}\3rd-party'
CMAKE_PREFIX_PATH='c:\vcpkg\installed\x64-windows;${{ runner.temp }}\3rd-party\dist'
ABSL_VERSION=${{ env.ABSL_VERSION }}
S2GEOMETRY_VERSION=${{ env.S2GEOMETRY_VERSION }}
S2GEOGRAPHY_VERSION=${{ env.S2GEOGRAPHY_VERSION }}
CXX_STANDARD=${{ env.CXX_STANDARD }}
PROJECT_DIR='${{ runner.workspace }}\spherely'
CIBW_BEFORE_ALL: ./ci/install_3rdparty.sh
CIBW_BEFORE_ALL_WINDOWS: ci\install_3rdparty.cmd
# CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel
CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel
CIBW_REPAIR_WHEEL_COMMAND_LINUX: 'LD_LIBRARY_PATH=/host${{ runner.temp }}/3rd-party/dist/lib64 auditwheel repair -w {dest_dir} {wheel}'
CIBW_REPAIR_WHEEL_COMMAND_MACOS: 'DYLD_LIBRARY_PATH=${{ runner.temp }}/3rd-party/dist/lib delocate-wheel --require-archs=${{ matrix.arch }} -w {dest_dir} -v {wheel}'
# CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair --add-path ${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}\bin -w {dest_dir} {wheel}
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: 'delvewheel repair --add-path ${{ runner.temp }}\3rd-party\dist\bin --add-path c:\vcpkg\installed\x64-windows\bin -w {dest_dir} {wheel}'
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest {project}/tests

Expand Down
112 changes: 112 additions & 0 deletions ci/install_3rdparty.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
:: Build and install absl, s2 and s2geography on posix systems.
benbovy marked this conversation as resolved.
Show resolved Hide resolved
::
:: This script requires environment variables to be set
:: - DEPENDENCIES_DIR=/path/to/cached/prefix -- to build or use as cache
:: - ABSL_VERSION
:: - S2GEOMETRY_VERSION
:: - S2GEOGRAPHY_VERSION
:: - CXX_STANDARD
::
:: This script assumes that library sources have been downloaded or copied in
:: DEPENDENCIES_DIR (e.g., %DEPENDENCIES_DIR%/absl-src-%ABSL_VERSION%).

set SRC_DIR=%DEPENDENCIES_DIR%\src
set BUILD_DIR=%DEPENDENCIES_DIR%\build
set INSTALL_DIR=%DEPENDENCIES_DIR%\dist

if exist %INSTALL_DIR%\include\s2geography (
echo Using cached install directory %INSTALL_DIR%
exit /B 0
)

mkdir %SRC_DIR%
mkdir %BUILD_DIR%
mkdir %INSTALL_DIR%

rem set ABSL_SRC_DIR=%DEPENDENCIES_DIR%\absl-src-%ABSL_VERSION%
rem set S2GEOMETRY_SRC_DIR=%DEPENDENCIES_DIR%\s2geometry-src-%S2GEOMETRY_VERSION%
set S2GEOGRAPHY_SRC_DIR=%DEPENDENCIES_DIR%\s2geography-src-%S2GEOGRAPHY_VERSION%

rem set ABSL_BUILD_DIR=%BUILD_DIR%\absl-src-%ABSL_VERSION%
rem set S2GEOMETRY_BUILD_DIR=%BUILD_DIR%\s2geometry-src-%S2GEOMETRY_VERSION%
set S2GEOGRAPHY_BUILD_DIR=%BUILD_DIR%\s2geography-src-%S2GEOGRAPHY_VERSION%

echo %CMAKE_PREFIX_PATH%

echo "----- Installing cmake"
pip install ninja cmake

rem echo "----- Downloading, building and installing absl-%ABSL_VERSION%"

rem cd %DEPENDENCIES_DIR%
rem curl -o absl.tar.gz -L https://github.com/abseil/abseil-cpp/archive/refs/tags/%ABSL_VERSION%.tar.gz
rem tar -xf absl.tar.gz -C %SRC_DIR%

rem cmake -GNinja ^
rem -S %SRC_DIR%/abseil-cpp-%ABSL_VERSION% ^
rem -B %ABSL_BUILD_DIR% ^
rem -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^
rem -DCMAKE_POSITION_INDEPENDENT_CODE=ON ^
rem -DCMAKE_CXX_STANDARD=%CXX_STANDARD% ^
rem -DCMAKE_BUILD_TYPE=Release ^
rem -DABSL_ENABLE_INSTALL=ON

rem IF %ERRORLEVEL% NEQ 0 exit /B 1
rem cmake --build %ABSL_BUILD_DIR%
rem IF %ERRORLEVEL% NEQ 0 exit /B 2
rem cmake --install %ABSL_BUILD_DIR%

rem echo "----- Downloading, building and installing s2geometry-%S2GEOMETRY_VERSION%"

rem echo %OPENSSL_ROOT_DIR%

rem cd %DEPENDENCIES_DIR%
rem curl -o s2geometry.tar.gz -L https://github.com/google/s2geometry/archive/refs/tags/v%S2GEOMETRY_VERSION%.tar.gz
rem tar -xf s2geometry.tar.gz -C %SRC_DIR%

rem cmake -GNinja ^
rem -S %SRC_DIR%/s2geometry-%S2GEOMETRY_VERSION% ^
rem -B %S2GEOMETRY_BUILD_DIR% ^
rem -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^
rem -DOPENSSL_ROOT_DIR=%OPENSSL_ROOT_DIR% ^
rem -DBUILD_TESTS=OFF ^
rem -DBUILD_EXAMPLES=OFF ^
rem -UGOOGLETEST_ROOT ^
rem -DCMAKE_CXX_STANDARD=%CXX_STANDARD% ^
rem -DCMAKE_BUILD_TYPE=Release ^
rem -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE ^
rem -DBUILD_SHARED_LIBS=ON

rem IF %ERRORLEVEL% NEQ 0 exit /B 3
rem cmake --build %S2GEOMETRY_BUILD_DIR%
rem IF %ERRORLEVEL% NEQ 0 exit /B 4
rem cmake --install %S2GEOMETRY_BUILD_DIR%

echo "----- Downloading, building and installing s2geography-%S2GEOGRAPHY_VERSION%"

cd %DEPENDENCIES_DIR%
curl -o s2geography.tar.gz -L https://github.com/paleolimbot/s2geography/archive/refs/tags/%S2GEOGRAPHY_VERSION%.tar.gz
tar -xf s2geography.tar.gz -C %SRC_DIR%

rem TODO: remove when fixed in s2geography
cd %SRC_DIR%/s2geography-%S2GEOGRAPHY_VERSION%
patch -i %PROJECT_DIR%\ci\s2geography-add-openssl-as-requirement.patch
patch -i %PROJECT_DIR%\ci\s2geography-add-include-dir.patch

cmake -GNinja ^
-S %SRC_DIR%/s2geography-%S2GEOGRAPHY_VERSION% ^
-B %S2GEOGRAPHY_BUILD_DIR% ^
-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^
-DOPENSSL_ROOT_DIR=%OPENSSL_ROOT_DIR% ^
-DS2GEOGRAPHY_BUILD_TESTS=OFF ^
-DS2GEOGRAPHY_S2_SOURCE=AUTO ^
-DS2GEOGRAPHY_BUILD_EXAMPLES=OFF ^
-DCMAKE_CXX_STANDARD=%CXX_STANDARD% ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE ^
-DBUILD_SHARED_LIBS=ON

IF %ERRORLEVEL% NEQ 0 exit /B 5
cmake --build %S2GEOGRAPHY_BUILD_DIR%
IF %ERRORLEVEL% NEQ 0 exit /B 6
cmake --install %S2GEOGRAPHY_BUILD_DIR%
2 changes: 2 additions & 0 deletions ci/install_3rdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ build_install_dependencies(){
cd $SRC_DIR/s2geography-$S2GEOGRAPHY_VERSION
if [ "$(uname)" == "Darwin" ]; then
patch -p1 < $PROJECT_DIR/ci/s2geography-add-openssl-as-requirement.patch
patch -p1 < $PROJECT_DIR/ci/s2geography-add-include-dir.patch
else
patch -p1 < /project/ci/s2geography-add-openssl-as-requirement.patch
patch -p1 < /project/ci/s2geography-add-include-dir.patch
fi

cmake -S $SRC_DIR/s2geography-$S2GEOGRAPHY_VERSION -B $S2GEOGRAPHY_BUILD_DIR \
Expand Down
15 changes: 15 additions & 0 deletions ci/s2geography-add-include-dir.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d0d5e56..a520a1f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -212,6 +212,10 @@ add_library(s2geography
set_target_properties(s2geography PROPERTIES
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS})

+target_include_directories(s2geography PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
+ $<INSTALL_INTERFACE:include>)
+
target_compile_definitions(
s2geography
PUBLIC
Loading