Skip to content

Commit fceb685

Browse files
committed
WIP
1 parent dd99da7 commit fceb685

File tree

10 files changed

+321
-15
lines changed

10 files changed

+321
-15
lines changed

.github/workflows/deploy.yml

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,73 @@ jobs:
155155
path: ${{ github.workspace }}/dist/*.whl
156156
overwrite: true
157157

158+
build-apple-wheels:
159+
160+
runs-on: macos-latest
161+
env:
162+
CXX: g++-10
163+
strategy:
164+
matrix:
165+
python-version: ["3.14"]
166+
167+
steps:
168+
169+
- name: Checkout
170+
uses: actions/checkout@v4
171+
172+
- name: Setup Python ${{ matrix.python-version }}
173+
uses: actions/setup-python@v5
174+
with:
175+
python-version: ${{ matrix.python-version }}
176+
177+
- name: Show Python build paths
178+
run: |
179+
python -c "import sys, sysconfig; print(sys.executable); print(sys.version)"
180+
python -c "import sysconfig; print('include=', sysconfig.get_paths()['include'])"
181+
python -c "import sysconfig; print('platinclude=', sysconfig.get_paths().get('platinclude'))"
182+
python -c "import sysconfig; print('EXT_SUFFIX=', sysconfig.get_config_var('EXT_SUFFIX'))"
183+
echo "PL_PYTHON_INCLUDES=$(python -c 'import sysconfig; print(sysconfig.get_paths()["include"])')" >> "$GITHUB_ENV"
184+
echo "PL_PYTHON_LIBS=$(python -c 'import sysconfig; print(sysconfig.get_paths()["libs"])')" >> "$GITHUB_ENV"
185+
186+
- name: Install Dependencies
187+
run: |
188+
curl https://sdk.lunarg.com/sdk/download/1.3.283.0/mac/vulkansdk-macos-1.3.283.0.dmg -o vk.dmg
189+
hdiutil attach vk.dmg
190+
sudo /Volumes/vulkansdk-macos-1.3.283.0/InstallVulkan.app/Contents/MacOS/InstallVulkan --root ~/VulkanSDK/1.3.283.0 --accept-licenses --default-answer --confirm-command install com.lunarg.vulkan.core com.lunarg.vulkan.usr com.lunarg.vulkan.sdl2 com.lunarg.vulkan.glm com.lunarg.vulkan.volk com.lunarg.vulkan.vma com.lunarg.vulkan.ios
191+
cd $GITHUB_WORKSPACE
192+
cd ..
193+
git clone https://github.com/PilotLightTech/pilotlight
194+
cd pilotlight-python
195+
python -m pip install pl-build
196+
197+
- name: Build Package
198+
run: |
199+
cd $GITHUB_WORKSPACE
200+
echo "$PL_PYTHON_INCLUDES"
201+
echo "$PL_PYTHON_LIBS"
202+
cd scripts
203+
python3 gen_build.py
204+
cd ../src
205+
chmod +x build.sh
206+
./build.sh -c deploy
207+
cd ..
208+
209+
- name: Build Wheel
210+
run: |
211+
cd $GITHUB_WORKSPACE
212+
python -m pip install --upgrade pip twine wheel setuptools
213+
python -m setup bdist_wheel --plat-name macosx_15_0_arm64 --dist-dir dist
214+
215+
- name: Upload Mac ${{ matrix.python-version }} Wheel
216+
uses: actions/upload-artifact@v4
217+
with:
218+
name: macbuild${{ matrix.python-version }}
219+
path: ${{ github.workspace }}/dist/*.whl
220+
overwrite: true
221+
158222
deploy-packages:
159223

160-
needs: [build-windows-wheels, build-linux-wheels]
224+
needs: [build-windows-wheels, build-linux-wheels, build-apple-wheels]
161225
runs-on: windows-2022
162226

163227
steps:
@@ -182,14 +246,14 @@ jobs:
182246
if: ${{contains(github.event.inputs.deploy, 'true') && github.ref == 'refs/heads/master'}}
183247
run: |
184248
python -m twine upload windowsbuild*/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} --skip-existing
185-
rem python -m twine upload apple10sbuild*/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} --skip-existing
249+
python -m twine upload macbuild*/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} --skip-existing
186250
python -m twine upload linuxbuild*/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} --skip-existing
187251
188252
- name: Test PyPi Deployment
189253
shell: cmd
190254
if: "contains(github.event.inputs.deploytest, 'true')"
191255
run: |
192256
dir
193-
python -m twine upload --repository testpypi windowsbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_PASSWORD }} --skip-existing
194-
python -m twine upload --repository testpypi apple10sbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_PASSWORD }} --skip-existing
195-
python -m twine upload --repository testpypi linuxbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_PASSWORD }} --skip-existing
257+
python -m twine upload --repository testpypi windowsbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }} --skip-existing
258+
python -m twine upload --repository testpypi macbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }} --skip-existing
259+
python -m twine upload --repository testpypi linuxbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }} --skip-existing

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pilotlight/pilotlight_d.pyd
1313
pilotlight/*.pdb
1414
pilotlight/*.dll
1515
pilotlight/*.so
16+
pilotlight/*.dSYM
1617

1718
# debug files
1819
src/*.pdb

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@
2121
"cwd": "${workspaceFolder}/out",
2222
"MIMode": "gdb",
2323
"miDebuggerPath": "/usr/bin/gdb"
24+
},
25+
{
26+
"name": "(MacOS) Launch",
27+
"type": "cppdbg",
28+
"targetArchitecture": "arm64",
29+
"program": "${workspaceFolder}/out/pilotlight_python",
30+
"externalConsole": false,
31+
"MIMode": "lldb",
32+
"request": "launch",
33+
"args": [],
34+
"stopAtEntry": false,
35+
"cwd": "${workspaceFolder}/out/",
36+
"environment": []
2437
}
2538
]
2639
}

scripts/build_python_for_mac.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cd ../dependencies/cpython
2+
mkdir -p build/debug
3+
cd build/debug
4+
../../configure --with-pydebug --enable-shared --prefix=$(pwd) LDFLAGS=-Wl,-rpath,$(pwd)
5+
make
6+
make install

scripts/gen_build.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@
152152
pl.add_compiler_flags("-fPIC")
153153
pl.add_linker_flags("-ldl -lm")
154154

155+
# mac os
156+
with pl.platform("Darwin"):
157+
with pl.compiler("clang"):
158+
pl.add_definitions("Py_PYTHON_H")
159+
pl.add_source_files("../../pilotlight/extensions/pl_platform_macos_ext.m")
160+
pl.add_compiler_flags("-fPIC")
161+
pl.add_linker_flags("-ldl -lm")
162+
155163
with pl.configuration("deploy"):
156164

157165
# win32
@@ -171,6 +179,14 @@
171179
pl.add_compiler_flags("-fPIC")
172180
pl.add_linker_flags("-ldl -lm")
173181

182+
# mac os
183+
with pl.platform("Darwin"):
184+
with pl.compiler("clang"):
185+
pl.add_definitions("Py_PYTHON_H")
186+
pl.add_source_files("../../pilotlight/extensions/pl_platform_macos_ext.m")
187+
pl.add_compiler_flags("-fPIC")
188+
pl.add_linker_flags("-ldl -lm")
189+
174190
#-----------------------------------------------------------------------------
175191
# [SECTION] examples
176192
#-----------------------------------------------------------------------------
@@ -212,6 +228,14 @@
212228
pl.add_link_directories("../dependencies/cpython/build/debug/")
213229
pl.add_compiler_flags("--debug -g")
214230
pl.add_dynamic_link_libraries("python3.14d")
231+
232+
# mac os
233+
with pl.platform("Darwin"):
234+
with pl.compiler("clang"):
235+
pl.add_definitions("PL_METAL_BACKEND")
236+
pl.add_link_directories("../dependencies/cpython/build/debug/")
237+
pl.add_compiler_flags("--debug -g")
238+
pl.add_dynamic_link_libraries("python3.14d")
215239

216240

217241
#-----------------------------------------------------------------------------
@@ -280,6 +304,21 @@
280304
pl.add_link_directories("../dependencies/cpython/build/debug/", '$VULKAN_SDK/lib')
281305
# pl.set_post_target_build_step('@copy "%VULKAN_SDK%\\bin\\spirv-cross-c-shared.dll" "..\\pilotlight\\" >nul\n')
282306

307+
# mac os
308+
with pl.platform("Darwin"):
309+
with pl.compiler("clang"):
310+
pl.add_definitions("PL_METAL_BACKEND")
311+
pl.set_output_binary("pilotlight")
312+
pl.set_output_binary_extension(".so")
313+
pl.add_compiler_flags("-fPIC", "--debug -g", "-std=c99", "-fmodules", "-ObjC", "-arch arm64")
314+
pl.add_linker_flags("-ldl -lm")
315+
pl.add_link_frameworks("Metal", "MetalKit", "Cocoa", "IOKit", "CoreVideo", "QuartzCore")
316+
pl.add_dynamic_link_libraries("shaderc_shared", "spirv-cross-c-shared")
317+
pl.add_static_link_libraries("glfwd", "pl_platform_ext")
318+
pl.add_link_directories("../dependencies/cpython/build/debug/", "/usr/local/lib")
319+
pl.add_compiler_flags("-Wno-deprecated-declarations")
320+
pl.add_dynamic_link_libraries("python3.14d")
321+
283322
with pl.configuration("deploy"):
284323

285324
pl.set_output_binary("pilotlight")
@@ -326,6 +365,23 @@
326365
pl.add_static_link_libraries("glfw", "pl_platform_ext")
327366
pl.add_link_directories('$VULKAN_SDK/lib')
328367

368+
# mac os
369+
with pl.platform("Darwin"):
370+
with pl.compiler("clang"):
371+
pl.add_definitions("PL_METAL_BACKEND")
372+
pl.add_include_directories("$PL_PYTHON_INCLUDES")
373+
pl.add_link_directories('$VULKAN_SD/Lib')
374+
pl.set_output_binary("pilotlight")
375+
pl.set_output_binary_extension(".so")
376+
pl.add_compiler_flags("-fPIC", "-std=c99", "-fmodules", "-ObjC", "-arch arm64")
377+
pl.add_linker_flags("-ldl -lm", "-undefined dynamic_lookup")
378+
pl.add_link_frameworks("Metal", "MetalKit", "Cocoa", "IOKit", "CoreVideo", "QuartzCore")
379+
pl.add_dynamic_link_libraries("shaderc_shared", "spirv-cross-c-shared")
380+
pl.add_static_link_libraries("glfw", "pl_platform_ext")
381+
pl.add_link_directories("/usr/local/lib")
382+
pl.add_compiler_flags("-Wno-deprecated-declarations")
383+
# pl.add_dynamic_link_libraries("python3.14")
384+
329385
#-----------------------------------------------------------------------------
330386
# [SECTION] generate scripts
331387
#-----------------------------------------------------------------------------

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import sys
66

7-
wip_version = "0.1.1"
7+
wip_version = "0.1.2"
88

99
def get_platform():
1010

@@ -41,16 +41,17 @@ def setup_package():
4141
# long_description_content_type='text/markdown', # Optional
4242
# url='https://github.com/PilotLightTech/pilotlight-python', # Optional
4343
license = 'MIT',
44-
python_requires='>=3.12',
44+
python_requires='>=3.13',
4545
classifiers=[
4646
'Development Status :: 3 - Alpha',
4747
'Intended Audience :: Education',
4848
'Intended Audience :: Developers',
4949
'Intended Audience :: Science/Research',
50+
'Operating System :: MacOS',
5051
'Operating System :: Microsoft :: Windows :: Windows 10',
5152
'Operating System :: POSIX',
5253
'Operating System :: Unix',
53-
'Programming Language :: Python :: 3.12',
54+
'Programming Language :: Python :: 3.13',
5455
'Programming Language :: Python :: 3.14',
5556
'Programming Language :: Python :: Implementation :: CPython',
5657
'Programming Language :: Python :: 3 :: Only',

src/build_linux.sh

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,13 @@ if [[ "$PL_CONFIG" == "deploy" ]]; then
215215

216216
# create output directory(s)
217217
mkdir -p "../out"
218+
mkdir -p "../pilotlight"
218219

219220
# create lock file(s)
220-
echo LOCKING > "../out/lock.tmp"
221+
echo LOCKING > "../pilotlight/lock.tmp"
221222

223+
rm -f ../pilotlight/pilotlight.so
224+
rm -f ../pilotlight/pilotlight_*.so
222225

223226
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ glfw | deploy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
224227

@@ -298,8 +301,37 @@ echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
298301

299302
# only build once check
300303
fi
304+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pilotlight | deploy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305+
306+
PL_RESULT=${BOLD}${GREEN}Successful.${NC}
307+
PL_DEFINES="-D_USE_MATH_DEFINES -DPL_VULKAN_BACKEND "
308+
PL_INCLUDE_DIRECTORIES="-I../src -I../../pilotlight/libs -I../../pilotlight/extensions -I../../pilotlight/src -I../../pilotlight/shaders -I../../pilotlight/dependencies/stb -I../../pilotlight/dependencies/cgltf -I../../pilotlight/dependencies/glfw/include/ -I../dependencies/cpython/ -I../dependencies/cpython/Include/ -I../dependencies/cpython/build/debug/ -I$PL_PYTHON_INCLUDES -I$VULKAN_SDK/include -I/usr/include/vulkan "
309+
PL_LINK_DIRECTORIES="-L../out -Wl,-rpath,../out -L../../pilotlight/out -Wl,-rpath,../../pilotlight/out -L$VULKAN_SDK/lib -Wl,-rpath,$VULKAN_SDK/lib "
310+
PL_COMPILER_FLAGS="-fPIC --debug -g "
311+
PL_LINKER_FLAGS="-ldl -lm "
312+
PL_STATIC_LINK_LIBRARIES="-l:glfw.a -l:pl_platform_ext.a "
313+
PL_DYNAMIC_LINK_LIBRARIES="-lshaderc_shared -lspirv-cross-c-shared -lvulkan "
314+
PL_SOURCES="pilotlight.c "
315+
316+
# run compiler (and linker)
317+
echo
318+
echo ${YELLOW}Step: pilotlight${NC}
319+
echo ${YELLOW}~~~~~~~~~~~~~~~~~~~${NC}
320+
echo ${CYAN}Compiling and Linking...${NC}
321+
gcc -shared $PL_SOURCES $PL_INCLUDE_DIRECTORIES $PL_DEFINES $PL_COMPILER_FLAGS $PL_INCLUDE_DIRECTORIES $PL_LINK_DIRECTORIES $PL_STATIC_LINK_LIBRARIES $PL_DYNAMIC_LINK_LIBRARIES $PL_LINKER_FLAGS -o "./../pilotlight/pilotlight.so"
322+
323+
# check build status
324+
if [ $? -ne 0 ]
325+
then
326+
PL_RESULT=${BOLD}${RED}Failed.${NC}
327+
fi
328+
329+
# print results
330+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
331+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
332+
301333
# delete lock file(s)
302-
rm -f ../out/lock.tmp
334+
rm -f ../pilotlight/lock.tmp
303335

304336
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305337
# end of deploy

0 commit comments

Comments
 (0)