-
Notifications
You must be signed in to change notification settings - Fork 26
233 lines (193 loc) · 9.36 KB
/
win.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Windows CI (Build from source dependencies)
on:
# Trigger the workflow on push on the master branch, or for any pull request
push:
branches:
- master
pull_request:
jobs:
build-and-test-win10:
name: >-
(Windows) (${{ matrix.PYTHON_VERSION }}) (${{ matrix.BUILD_TYPE }})
Build the dependencies. Build the project and run the unit tests.
runs-on: windows-2022
defaults:
run:
shell: pwsh
env:
GENERATOR: "Visual Studio 17 2022"
CXX_FLAGS: "/DEIGEN_MPL2_ONLY /d2ReducedOptimizeHugeFunctions /fp:contract /arch:AVX2"
strategy:
matrix:
PYTHON_VERSION: ['3.10', '3.11', '3.12']
BUILD_TYPE: ['Release']
include:
- PYTHON_VERSION: '3.12'
BUILD_TYPE: 'Debug'
#####################################################################################
steps:
- name: Configure Pagefile
uses: al-cheb/configure-pagefile-action@v1.4
with:
disk-root: "C:"
- name: Create workspace on secondary drive (C:) that has more space
run: |
New-Item -ItemType Directory -Force -Path C:\workspace
New-Item -ItemType Junction -Force -Value C:\workspace -Path "${env:GITHUB_WORKSPACE}/workspace"
- name: Configure Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.PYTHON_VERSION }}
- name: Checkout jiminy
uses: actions/checkout@v4
with:
path: 'workspace'
#####################################################################################
- name: Setup minimal build environment
run: |
git config --global advice.detachedHead false
python -m pip install setuptools wheel "pip>=20.3"
python -m pip install pefile machomachomangler
- name: Install pre-compiled binaries for additional gym-jiminy dependencies
if: matrix.PYTHON_VERSION != '3.13'
run: |
python -m pip install "torch" -f https://download.pytorch.org/whl/torch
python -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0"
- name: Install latest numpy version at build-time for run-time binary compatibility
run: |
python -m pip install --upgrade "numpy>=1.24"
- name: Build jiminy dependencies
run: |
${env:BUILD_TYPE} = "${{ matrix.BUILD_TYPE }}"
& "./workspace/build_tools/build_install_deps_windows.ps1"
#####################################################################################
- name: Configure and build jiminy
# FIXME: CMake exits with non-zero code if an error occurred in 'execute_process'.
# Indeed, such errors are expected to occur if some gym_jiminy add-on cannot be
# installed because of missing pre-compiled dependency on Pypi.
continue-on-error: true
run: |
$ErrorActionPreference = "Stop"
Set-PSDebug -Trace 1
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/'
$InstallDir = "$RootDir/install"
if (Test-Path env:Boost_ROOT) {
Remove-Item env:Boost_ROOT
}
if (-not (Test-Path -PathType Container $RootDir/build)) {
New-Item -ItemType "directory" -Force -Path "$RootDir/build"
}
Set-Location -Path $RootDir/build
cmake "$RootDir" -Wdev -G "${env:GENERATOR}" -DCMAKE_GENERATOR_PLATFORM=x64 `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" `
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" `
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_VERBOSE_MAKEFILE=ON `
-DBOOST_ROOT="$InstallDir" -DBoost_INCLUDE_DIR="$InstallDir/include" `
-DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE `
-DBoost_USE_STATIC_LIBS=ON -DPYTHON_REQUIRED_VERSION="${{ matrix.PYTHON_VERSION }}" `
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON `
-DINSTALL_GYM_JIMINY=${{ ((matrix.PYTHON_VERSION == '3.13') && 'OFF') || 'ON' }} `
-DCMAKE_CXX_FLAGS="${env:CXX_FLAGS} $(
) -DBOOST_ALL_NO_LIB -DBOOST_LIB_DIAGNOSTIC -DBOOST_CORE_USE_GENERIC_CMATH $(
) -DEIGENPY_STATIC -DURDFDOM_STATIC -DHPP_FCL_STATIC -DPINOCCHIO_STATIC"
cmake --build . --target ALL_BUILD --config "${{ matrix.BUILD_TYPE }}" --parallel 4
if (-not (Test-Path -PathType Container "$RootDir/build/pypi/jiminy_py/src/jiminy_py")) {
New-Item -ItemType "directory" -Force -Path "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core"
}
Copy-Item -Force -Recurse -Path "$InstallDir/lib/site-packages/*" `
-Destination "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core"
${env:Path} += ";$InstallDir/lib"
cmake --build . --target INSTALL --config "${{ matrix.BUILD_TYPE }}"
#####################################################################################
- name: Generating the Python Pip wheels
run: |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/'
$InstallDir = "$RootDir/install"
${env:Path} += ";$InstallDir/lib"
# Generate stubs
# FIXME: stubgen does not work with Numpy 2.X
# (see https://github.com/python/mypy/issues/17396)
python -m pip install "numpy<2.0"
stubgen -p jiminy_py -o $RootDir/build/pypi/jiminy_py/src
python "$RootDir/build_tools/stubgen.py" `
-o $RootDir/build/stubs --ignore-invalid=all jiminy_py
Copy-Item -Force -Path "$RootDir/build/stubs/jiminy_py-stubs/core/__init__.pyi" `
-Destination "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core/core.pyi"
# Generate wheels
Set-Location -Path "$RootDir/build"
cmake . -DCOMPONENT=pypi -P ./cmake_install.cmake
# Bundle non-standard dependencies with the wheels
Remove-Item -Recurse -Path "$RootDir/build/pypi" -Include *.tar.gz
Get-ChildItem -Recurse -Path "$RootDir/build/pypi/dist/jiminy_py" -Filter *.whl |
Foreach-Object {
$wheel_path = ($_.FullName)
python "$RootDir/build_tools/wheel_repair_win.py" "$wheel_path" -d "$InstallDir/lib" -w "$RootDir/build/wheelhouse"
}
Get-ChildItem -Path "$RootDir/build/wheelhouse" -Filter *.whl |
Foreach-Object {
$wheel_path = ($_.FullName)
python -m pip install --force-reinstall --no-deps $wheel_path
}
- name: Upload the wheel for Windows of jiminy_py
if: matrix.BUILD_TYPE != 'Debug'
uses: actions/upload-artifact@v4
with:
name: wheelhouse-${{ matrix.PYTHON_VERSION }}
path: 'workspace/build/wheelhouse'
#####################################################################################
- name: Build extension module
run: |
$ErrorActionPreference = "Stop"
Set-PSDebug -Trace 1
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/'
$InstallDir = "$RootDir/install"
& "$InstallDir/bin/jiminy_double_pendulum.exe"
mkdir -p "$RootDir/core/examples/external_project/build"
cd "$RootDir/core/examples/external_project/build"
$JIMINY_LIB_DIR = (python -c "import os, jiminy_py ; print(os.path.dirname(jiminy_py.get_libraries()))")
echo $JIMINY_LIB_DIR
${env:Path} += ";$JIMINY_LIB_DIR"
cmake "$RootDir/core/examples/external_project/" -G "${env:GENERATOR}" -DCMAKE_GENERATOR_PLATFORM=x64 `
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" `
-DPYTHON_REQUIRED_VERSION="${{ matrix.PYTHON_VERSION }}" `
-DCMAKE_CXX_FLAGS="${env:CXX_FLAGS}"
cmake --build . --target INSTALL --config "${{ matrix.BUILD_TYPE }}"
& "$InstallDir/bin/pip_double_pendulum.exe"
- name: Running unit tests for jiminy
run: |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/'
ctest --output-on-failure --test-dir "${RootDir}/build/core/unit"
python -m unittest discover -s "${RootDir}/python/jiminy_py/unit_py" -v
- name: Run unit tests for gym jiminy base module
run: |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/'
if ("${{ matrix.BUILD_TYPE }}" -eq "Debug") {
${env:JIMINY_BUILD_DEBUG} = 1
}
python -m unittest discover -s "$RootDir/python/gym_jiminy/unit_py" -v
- name: Run examples for gym jiminy add-on modules
if: matrix.BUILD_TYPE != 'Debug'
run: |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/'
Set-Location -Path "$RootDir/python/gym_jiminy/examples/rllib"
python acrobot_ppo.py
#########################################################################################
publish-pypi-win10:
name: (Windows) Publish on PyPi the wheel for Windows of jiminy_py
runs-on: ubuntu-24.04
permissions:
id-token: write
needs: build-and-test-win10
if: github.repository == 'duburcqa/jiminy' && github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Download the wheels previously generated
uses: actions/download-artifact@v4
with:
pattern: wheelhouse-*
merge-multiple: true
path: wheelhouse
- name: Publish on PyPi the wheels
uses: pypa/gh-action-pypi-publish@v1.10.3
with:
packages-dir: wheelhouse
verify-metadata: false