Skip to content

Commit 4467fca

Browse files
committed
Add initial attempt to build cppyy on Windows
1 parent 29f2920 commit 4467fca

File tree

4 files changed

+126
-11
lines changed

4 files changed

+126
-11
lines changed

.github/actions/Build_and_Test_CppInterOp/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ runs:
9191
echo "CLING_BUILD_DIR=$env:CLING_BUILD_DIR"
9292
echo "CLING_BUILD_DIR=$env:CLING_BUILD_DIR" >> $env:GITHUB_ENV
9393
94-
$env:CPLUS_INCLUDE_PATH="$env:CLING_DIR\tools\cling\include;$env:CLING_BUILD_DIR\include;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include;"
94+
$env:CPLUS_INCLUDE_PATH="$env:CLING_DIR\tools\cling\include;$env:CLING_BUILD_DIR\include;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include"
9595
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH"
9696
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH" >> $env:GITHUB_ENV
9797
}
9898
else
9999
{
100-
$env:CPLUS_INCLUDE_PATH="$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include;"
100+
$env:CPLUS_INCLUDE_PATH="$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include"
101101
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH"
102102
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH" >> $env:GITHUB_ENV
103103
}
@@ -113,7 +113,7 @@ runs:
113113
# Build CppInterOp next to cling and llvm-project.
114114
mkdir build
115115
cd build
116-
$env:CPPINTEROP_BUILD_DIR="$env:PWD_DIR"
116+
$env:CPPINTEROP_BUILD_DIR=$PWD.Path
117117
echo "CPPINTEROP_BUILD_DIR=$env:CPPINTEROP_BUILD_DIR"
118118
echo "CPPINTEROP_BUILD_DIR=$env:CPPINTEROP_BUILD_DIR" >> $env:GITHUB_ENV
119119
if ( "${{ matrix.cling }}" -imatch "On" )

.github/actions/Build_and_Test_cppyy/action.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,100 @@ runs:
135135
tail -n1 test_xfailed.log
136136
echo "Return Code: ${RETCODE}"
137137
exit $RETCODE
138+
139+
- name: Build and Install cppyy-backend
140+
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
141+
shell: powershell
142+
run: |
143+
# Download cppyy-backend
144+
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git
145+
cd cppyy-backend
146+
mkdir $env:CPPINTEROP_DIR\lib
147+
mkdir build
148+
cd build
149+
# Install CppInterOp
150+
cd $env:CPPINTEROP_BUILD_DIR
151+
cmake --build . --target install --parallel ${{ env.ncpus }}
152+
cd ..\cppyy-backend\build\
153+
# Build and Install cppyy-backend
154+
$env:INCLUDE=$env:CPLUS_INCLUDE_PATH
155+
cmake -DCppInterOp_DIR=$env:CPPINTEROP_DIR ..
156+
cmake --build . --parallel ${{ env.ncpus }}
157+
cp libcppyy-backend.lib $env:CPPINTEROP_DIR\lib\
158+
cd ..
159+
160+
- name: Install CPyCppyy
161+
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
162+
shell: powershell
163+
run: |
164+
python -m venv .venv
165+
. .\.venv\Scripts\Activate.ps1
166+
# Install CPyCppyy
167+
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git
168+
mkdir CPyCppyy\build
169+
cd CPyCppyy\build
170+
cmake ..
171+
cmake --build . --parallel ${{ env.ncpus }}
172+
#
173+
env:CPYCPPYY_DIR = $PWD.Path
174+
cd ../..
175+
# We need CPYCPPYY_DIR later
176+
echo "CPYCPPYY_DIR=$env:CPYCPPYY_DIR" >> $env:GITHUB_ENV
177+
178+
- name: Install cppyy
179+
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
180+
shell: powershell
181+
run: |
182+
# source virtual environment
183+
. .\.venv\Scripts\Activate.ps1
184+
# Install cppyy
185+
git clone --depth=1 https://github.com/compiler-research/cppyy.git
186+
cd cppyy
187+
python -m pip install --upgrade . --no-deps
188+
cd ..
189+
190+
- name: Run cppyy
191+
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
192+
shell: powershell
193+
run: |
194+
# Run cppyy
195+
. .\.venv\Scripts\Activate.ps1
196+
$env:PYTHONPATH=$env:PYTHONPATH:$env:CPYCPPYY_DIR:$env:CB_PYTHON_DIR
197+
python -c "import cppyy"
198+
# We need PYTHONPATH later
199+
echo "PYTHONPATH=$env:PYTHONPATH" >> $GITHUB_ENV
200+
201+
- name: Run the tests
202+
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
203+
shell: powershell
204+
run: |
205+
# Run the tests
206+
. .\.venv\Scripts\Activate.ps1
207+
cd cppyy\test
208+
echo ::group::Prepare For Testing
209+
make all
210+
python -m pip install --upgrade pip
211+
python -m pip install pytest
212+
python -m pip install pytest-xdist
213+
python -m pip install numba
214+
echo ::endgroup::
215+
echo ::group::Run complete test suite
216+
$ErrorActionPreference = "Stop"
217+
python -m pytest -sv -ra 2>&1 | Tee-Object -FilePath complete_testrun.log
218+
$ErrorActionPreference = "Continue"
219+
echo ::group::Crashing Test Logs
220+
# See if we don't have a crash that went away
221+
# Comment out all xfails but the ones that have a run=False condition.
222+
find.exe . -name "*.py" -exec sed.exe -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \;
223+
python -m pytest -n 1 -m "xfail" --runxfail -sv -ra --max-worker-restart 512 2>&1 | Tee-Object -FilePath test_crashed.log
224+
$LASTEXITCODE = 0
225+
git checkout .
226+
echo ::endgroup::
227+
echo ::group::XFAIL Test Logs
228+
# Rewrite all xfails that have a run clause to skipif. This way we will
229+
# avoid conditionally crashing xfails
230+
find.exe . -name "*.py" -exec sed.exe -i -E 's/(^ *)@mark.xfail\(run=(.*)/\1@mark.skipif(condition=not \2/g' {} \;
231+
# See if we don't have an xfail that went away
232+
python -m pytest --runxfail -sv -ra | tee test_xfailed.log 2>&1 || true
233+
git checkout .
234+
echo ::endgroup::

.github/workflows/Windows-arm.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,19 @@ jobs:
233233
fail-fast: false
234234
matrix:
235235
include:
236-
- name: win11-msvc-clang-repl-20
236+
- name: win11-msvc-clang-repl-20-cppyy
237237
os: windows-11-arm
238238
compiler: msvc
239239
clang-runtime: '20'
240240
cling: Off
241-
cppyy: Off
242-
- name: win11-msvc-clang18-cling
241+
cppyy: On
242+
- name: win11-msvc-clang18-cling-cppyy
243243
os: windows-11-arm
244244
compiler: msvc
245245
clang-runtime: '18'
246246
cling: On
247247
cling-version: '1.2'
248-
cppyy: Off
248+
cppyy: On
249249

250250
steps:
251251
- uses: actions/checkout@v4
@@ -291,6 +291,13 @@ jobs:
291291
$env:ncpus=$([Environment]::ProcessorCount)
292292
echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV
293293
294+
- name: Install deps on Windows
295+
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
296+
run: |
297+
choco install findutils
298+
choco install gnuwin32-coreutils.install
299+
$env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH"
300+
294301
- name: Setup compiler on Windows
295302
run: |
296303
if ( "${{ matrix.compiler }}" -imatch "clang" )
@@ -324,6 +331,8 @@ jobs:
324331

325332
- uses: ./.github/actions/Build_and_Test_CppInterOp
326333

334+
- uses: ./.github/actions/Build_and_Test_cppyy
335+
327336
- name: Setup tmate session
328337
if: ${{ failure() && runner.debug }}
329338
uses: mxschmitt/action-tmate@v3

.github/workflows/Windows.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,19 @@ jobs:
233233
fail-fast: false
234234
matrix:
235235
include:
236-
- name: win2025-msvc-clang-repl-20
236+
- name: win2025-msvc-clang-repl-20-cppyy
237237
os: windows-2025
238238
compiler: msvc
239239
clang-runtime: '20'
240240
cling: Off
241-
cppyy: Off
242-
- name: win2025-msvc-clang18-cling
241+
cppyy: On
242+
- name: win2025-msvc-clang18-cling-cppyy
243243
os: windows-2025
244244
compiler: msvc
245245
clang-runtime: '18'
246246
cling: On
247247
cling-version: '1.2'
248-
cppyy: Off
248+
cppyy: On
249249

250250
steps:
251251
- uses: actions/checkout@v4
@@ -291,6 +291,13 @@ jobs:
291291
$env:ncpus=$([Environment]::ProcessorCount)
292292
echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV
293293
294+
- name: Install deps on Windows
295+
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
296+
run: |
297+
choco install findutils
298+
choco install gnuwin32-coreutils.install
299+
$env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH"
300+
294301
- name: Setup compiler on Windows
295302
run: |
296303
if ( "${{ matrix.compiler }}" -imatch "clang" )
@@ -324,6 +331,8 @@ jobs:
324331

325332
- uses: ./.github/actions/Build_and_Test_CppInterOp
326333

334+
- uses: ./.github/actions/Build_and_Test_cppyy
335+
327336
- name: Setup tmate session
328337
if: ${{ failure() && runner.debug }}
329338
uses: mxschmitt/action-tmate@v3

0 commit comments

Comments
 (0)