Skip to content

Commit b09eabb

Browse files
Merge pull request #91 from miloserdova-l/feature/win32-wheel
Windows 32bit wheel
2 parents 89ef0ce + 89a39b4 commit b09eabb

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

.github/workflows/wheels.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ jobs:
9191

9292

9393
build_wheel_windows:
94-
name: Build wheel on Windows 64bit
94+
name: Build wheel on Windows ${{ matrix.arch }}
9595
needs: build
9696
runs-on: windows-2019
9797
strategy:
9898
fail-fast: false
99+
matrix:
100+
arch: [x64, x86]
99101
steps:
100102
- uses: actions/checkout@v2
101103
with:
@@ -107,29 +109,35 @@ jobs:
107109
uses: actions/setup-python@v2
108110
with:
109111
python-version: 3.6
112+
architecture: ${{ matrix.arch }}
110113

111114
- name: Setup Python 3.7
112115
uses: actions/setup-python@v2
113116
with:
114117
python-version: 3.7
118+
architecture: ${{ matrix.arch }}
115119

116120
- name: Setup Python 3.8
117121
uses: actions/setup-python@v2
118122
with:
119123
python-version: 3.8
124+
architecture: ${{ matrix.arch }}
120125

121126
- name: Setup Python 3.9
122127
uses: actions/setup-python@v2
123128
with:
124129
python-version: 3.9
130+
architecture: ${{ matrix.arch }}
125131

126132
- name: Setup Python 3.10
127133
uses: actions/setup-python@v2
128134
with:
129135
python-version: '3.10'
136+
architecture: ${{ matrix.arch }}
130137

131138
- name: Build wheel
132-
run: .\scripts\build-wheels-windows.cmd
139+
run: .\scripts\build-wheels-windows.cmd ${{ matrix.arch }}
140+
133141
- uses: actions/upload-artifact@v2
134142
with:
135143
path: .\dist
@@ -143,16 +151,24 @@ jobs:
143151
strategy:
144152
fail-fast: false
145153
matrix:
146-
os: [macos-latest, ubuntu-latest, windows-latest]
154+
os: [macos-latest, ubuntu-latest, windows-latest, windows-2019]
147155
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
148156
steps:
149157
- name: Checkout
150158
uses: actions/checkout@v2
151159

152160
- name: Setup Python ${{ matrix.python }}
161+
if: ${{ matrix.os != 'windows-2019' }}
162+
uses: actions/setup-python@v2
163+
with:
164+
python-version: ${{ matrix.python }}
165+
166+
- name: Setup Python ${{ matrix.python }}
167+
if: ${{ matrix.os == 'windows-2019' }}
153168
uses: actions/setup-python@v2
154169
with:
155170
python-version: ${{ matrix.python }}
171+
architecture: x86
156172

157173
- name: Download artifacts
158174
uses: actions/download-artifact@v2
@@ -172,10 +188,24 @@ jobs:
172188
run: |
173189
python -m pip install .\artifact\$(dir artifact -Name | findstr mrob-.*-win_amd64.whl) numpy pytest
174190
175-
- name: "Python unit tests"
191+
- name: Install mrob & numpy on Windows 32bit
192+
if: ${{ matrix.os == 'windows-2019' }}
193+
run: |
194+
python -m pip install .\artifact\$(dir artifact -Name | findstr mrob-.*-win32.whl) numpy
195+
196+
- name: Python unit tests
197+
if: ${{ matrix.os != 'windows-2019' }}
176198
run: |
177199
python -m pytest mrobpy
178200
201+
- name: Python unit tests
202+
if: ${{ matrix.os == 'windows-2019' }}
203+
run: |
204+
$files = Get-ChildItem -Path python_examples -Include *.py
205+
foreach ($f in $files){
206+
python $f.FullName || EXIT /B !ERRORLEVEL!
207+
}
208+
179209
180210
publish_pypi:
181211
name: Publish macOS wheel to PyPI

scripts/build-wheels-windows.cmd

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525

2626
SETLOCAL EnableDelayedExpansion
2727

28+
If "%~1"=="x64" (
29+
SET plat="x64" || EXIT /B !ERRORLEVEL!
30+
) else (
31+
If "%~1"=="x86" (
32+
SET plat="Win32" || EXIT /B !ERRORLEVEL!
33+
) else (
34+
echo Illegal argument: the argument must be set to x64 or x86
35+
EXIT /B 1
36+
)
37+
)
38+
2839
:: Early check for build tools
2940
cmake --version || EXIT /B !ERRORLEVEL!
3041

@@ -36,7 +47,7 @@ mkdir .\mrob || popd && EXIT /B !ERRORLEVEL!
3647
copy .\__init__.py .\mrob\__init__.py || popd && EXIT /B !ERRORLEVEL!
3748

3849

39-
for /D %%P in (C:\hostedtoolcache\windows\Python\3*) do CALL :build %%P\x64\python.exe || popd && EXIT /B !ERRORLEVEL!
50+
for /D %%P in (C:\hostedtoolcache\windows\Python\3*) do CALL :build %plat% %%P\%~1\python.exe || popd && EXIT /B !ERRORLEVEL!
4051

4152
python -m pip install --user -q build || popd && EXIT /B !ERRORLEVEL!
4253
python -m build --wheel --outdir dist . || popd && EXIT /B !ERRORLEVEL!
@@ -45,6 +56,6 @@ popd
4556
EXIT /B 0
4657

4758
:build
48-
cmake -S . -B build -G "Visual Studio 16 2019" -A "x64" -DPYTHON_EXECUTABLE:FILEPATH=%~1 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=%cd%\mrob -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=%cd%\mrob || EXIT /B !ERRORLEVEL!
59+
cmake -S . -B build -G "Visual Studio 16 2019" -A "%~1" -DPYTHON_EXECUTABLE:FILEPATH=%~2 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=%cd%\mrob -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=%cd%\mrob || EXIT /B !ERRORLEVEL!
4960
cmake --build build --config Release -j %NUMBER_OF_PROCESSORS% || EXIT /B !ERRORLEVEL!
5061
EXIT /B 0

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
try:
2828
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
29-
import platform, os
29+
import platform, os, ctypes
3030

3131
class bdist_wheel(_bdist_wheel):
3232

@@ -46,7 +46,10 @@ def get_tag(self):
4646
version = os.getenv('MACOSX_DEPLOYMENT_TARGET').replace('.', '_')
4747
plat = name + "_" + version + "_" + arch
4848
elif platform.system() == "Windows":
49-
plat = "win_" + platform.machine().lower()
49+
if ctypes.sizeof(ctypes.c_voidp) * 8 > 32:
50+
plat = "win_" + platform.machine().lower()
51+
else:
52+
plat = "win32"
5053
return python, abi, plat
5154

5255
except ImportError:

0 commit comments

Comments
 (0)