Skip to content

Commit

Permalink
explicitly include googletest in PEP517 wheel build
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Nov 14, 2024
1 parent ab525c0 commit 641de45
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
- released
workflow_dispatch:

env:
GOOGLETEST_VERSION: "1.15.2"

jobs:
cmake:
strategy:
Expand Down Expand Up @@ -54,12 +57,19 @@ jobs:
with:
cmake-build-args: "-DCMAKE_CXX_STANDARD=17 -DABSL_PROPAGATE_CXX_STD=ON -DABSL_ENABLE_INSTALL=ON -DBUILD_TESTING=off -DCMAKE_POSITION_INDEPENDENT_CODE=ON"
abseil-version: "20240722.0"
- name: retrieve googletest v${{ env.GOOGLETEST_VERSION }}
run: |
wget https://github.com/google/googletest/releases/download/v${{ env.GOOGLETEST_VERSION }}/googletest-${{ env.GOOGLETEST_VERSION }}.tar.gz
tar -xzvf googletest-${{ env.GOOGLETEST_VERSION }}.tar.gz
echo GOOGLETEST_ROOT=${{ runner.temp }}/googletest-${{ env.GOOGLETEST_VERSION }} >> $GITHUB_ENV
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ matrix.python-version }}
- run: pip install build
- run: python -m build
env:
SETUPTOOLS_CMAKE_OPTIONS: "-DGOOGLETEST_ROOT=${{ runner.temp }}/googletest-${{ env.GOOGLETEST_VERSION }} -DGOOGLETEST_VERSION=${{ env.GOOGLETEST_VERSION }}"
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: s2geometry-py${{ matrix.python-version }}-${{ runner.os }}-${{ runner.arch }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- run: pip install .
env:
SETUPTOOLS_CMAKE_OPTIONS: "-DGOOGLETEST_ROOT=${{ runner.temp }}/googletest-${{ env.GOOGLETEST_VERSION }} -DGOOGLETEST_VERSION=${{ env.GOOGLETEST_VERSION }}"
- run: pip install pytest
- run: pytest

21 changes: 12 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
import sys
from pathlib import Path

import cmake_build_extension
import setuptools


SETUPTOOLS_CMAKE_OPTIONS = os.environ.get("SETUPTOOLS_CMAKE_OPTIONS", "")

setuptools.setup(
ext_modules=[
cmake_build_extension.CMakeExtension(
Expand All @@ -16,15 +19,15 @@
# (it could be a subfolder)
source_dir=str(Path(__file__).parent.absolute()),
cmake_configure_options=[
# This option points CMake to the right Python interpreter, and helps
# the logic of FindPython3.cmake to find the active version
f"-DPython3_ROOT_DIR={Path(sys.prefix)}",
'-DCALL_FROM_SETUP_PY:BOOL=ON',
'-DBUILD_SHARED_LIBS:BOOL=OFF',
'-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
'-DWITH_PYTHON=ON',
'-DBUILD_TESTS=OFF'
]
# This option points CMake to the right Python interpreter, and helps
# the logic of FindPython3.cmake to find the active version
f"-DPython3_ROOT_DIR={Path(sys.prefix)}",
"-DCALL_FROM_SETUP_PY:BOOL=ON",
"-DBUILD_SHARED_LIBS:BOOL=OFF",
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
"-DWITH_PYTHON=ON",
*SETUPTOOLS_CMAKE_OPTIONS.split(),
],
)
],
cmdclass=dict(
Expand Down

0 comments on commit 641de45

Please sign in to comment.