Skip to content

Commit 8d5bd9d

Browse files
committed
WIP
1 parent 3f63b75 commit 8d5bd9d

File tree

3 files changed

+282
-0
lines changed

3 files changed

+282
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Deploy
2+
3+
on:
4+
5+
workflow_dispatch:
6+
7+
inputs:
8+
9+
version:
10+
description: 'pilotlight version'
11+
required: true
12+
default: '0.1.0'
13+
14+
deploy:
15+
description: 'Deploy (true will deploy to pypi)'
16+
required: true
17+
default: 'false'
18+
19+
deploytest:
20+
description: 'Deploy (true will deploy to test pypi)'
21+
required: true
22+
default: 'false'
23+
24+
jobs:
25+
26+
build-package:
27+
28+
runs-on: windows-2022
29+
strategy:
30+
matrix:
31+
python-version: [ 3.14 ]
32+
33+
steps:
34+
35+
- uses: actions/checkout@v4
36+
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Show Python build paths
43+
run: |
44+
python -c "import sys, sysconfig; print(sys.executable); print(sys.version)"
45+
python -c "import sysconfig; print('include=', sysconfig.get_paths()['include'])"
46+
python -c "import sysconfig; print('platinclude=', sysconfig.get_paths().get('platinclude'))"
47+
python -c "import sysconfig; print('EXT_SUFFIX=', sysconfig.get_config_var('EXT_SUFFIX'))"
48+
49+
- name: Install Dependencies
50+
run: |
51+
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.3.296.0/windows/VulkanSDK-1.3.296.0-Installer.exe" -OutFile VulkanSDK.exe
52+
# ./VulkanSDK.exe --help
53+
./VulkanSDK.exe --accept-licenses --default-answer --root D:/a/VulkanSDK --confirm-command install
54+
55+
- name: Retrieve submodules
56+
shell: cmd
57+
run: |
58+
59+
python -m pip install pl-build
60+
rem git submodule update --init --recursive ./dependencies/cpython
61+
cd ..
62+
git clone https://github.com/PilotLightTech/pilotlight
63+
cd pilotlight-python
64+
65+
- name: Build package
66+
shell: cmd
67+
run: |
68+
set VULKAN_SDK=D:/a/VulkanSDK
69+
cd %GITHUB_WORKSPACE%
70+
cd scripts
71+
python gen_build.py
72+
cd ../src
73+
build.bat -c deploy
74+
cd ..
75+
76+
- name: Install dependencies
77+
run: |
78+
python -m pip install --upgrade pip twine wheel setuptools
79+
80+
- name: Build Wheel
81+
shell: cmd
82+
run: |
83+
cd %GITHUB_WORKSPACE%
84+
python -m setup bdist_wheel --plat-name win_amd64 --dist-dir dist
85+
86+
- uses: actions/upload-artifact@v4
87+
with:
88+
name: pltools wheel
89+
path: |
90+
${{ github.workspace }}/dist/*.whl
91+
${{ github.workspace }}/dist/*.tar.gz
92+
retention-days: 1
93+
if-no-files-found: error
94+
95+
- name: PyPi Deployment
96+
shell: cmd
97+
if: ${{contains(github.event.inputs.deploy, 'true') && github.ref == 'refs/heads/master'}}
98+
run: |
99+
python -m pip install twine
100+
python -m twine upload dist/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} --skip-existing
101+
102+
- name: Test PyPi Deployment
103+
shell: cmd
104+
if: ${{contains(github.event.inputs.deploytest, 'true') && github.ref == 'refs/heads/master'}}
105+
run: |
106+
python -m pip install twine
107+
python -m twine upload --repository testpypi dist/* -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }} --skip-existing

scripts/gen_build.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,40 @@
108108

109109
pl.add_link_frameworks("Cocoa", "IOKit", "CoreFoundation")
110110

111+
with pl.configuration("deploy"):
112+
113+
pl.set_output_binary("glfw")
114+
115+
# win32
116+
with pl.platform("Windows"):
117+
with pl.compiler("msvc"):
118+
pl.add_include_directories("%VULKAN_SDK%\\Include")
119+
pl.add_definitions("UNICODE", "_UNICODE", "_CRT_SECURE_NO_WARNINGS", "_GLFW_VULKAN_STATIC", "_GLFW_WIN32")
120+
pl.add_compiler_flags("-nologo", "-std:c11", "-W3", "-wd5105", "-O2", "-MD", "-Zi", "-permissive")
121+
pl.add_linker_flags("-incremental:no", "-nologo")
122+
123+
# linux
124+
with pl.platform("Linux"):
125+
with pl.compiler("gcc"):
126+
pl.add_definitions("_GLFW_VULKAN_STATIC", "_GLFW_X11")
127+
pl.add_include_directories('$VULKAN_SDK/include', '/usr/include/vulkan', '/usr/include/vulkan')
128+
pl.add_dynamic_link_libraries("xcb", "X11", "X11-xcb", "xkbcommon", "pthread", "xcb-cursor", "vulkan")
129+
pl.add_link_directories('$VULKAN_SDK/lib')
130+
pl.add_compiler_flags("-fPIC", "-std=gnu99")
131+
pl.add_linker_flags("-ldl -lm")
132+
pl.add_source_files("../dependencies/glfw/src/posix_poll.c")
133+
134+
# apple
135+
with pl.platform("Darwin"):
136+
with pl.compiler("clang"):
137+
pl.add_definitions("_GLFW_VULKAN_STATIC", "_GLFW_COCOA")
138+
pl.add_include_directories('$VULKAN_SDK/include', '/usr/include/vulkan', '/usr/include/vulkan')
139+
pl.add_dynamic_link_libraries("spirv-cross-c-shared", "shaderc_shared", "vulkan")
140+
pl.add_link_directories('$VULKAN_SDK/lib', "/usr/local/lib")
141+
pl.add_compiler_flags("-std=c99", "-fmodules", "-ObjC", "-fPIC", "-Wno-deprecated-declarations")
142+
143+
pl.add_link_frameworks("Cocoa", "IOKit", "CoreFoundation")
144+
111145
#-----------------------------------------------------------------------------
112146
# [SECTION] examples
113147
#-----------------------------------------------------------------------------
@@ -150,6 +184,16 @@
150184
pl.add_static_link_libraries("ucrt", "user32", "Ole32")
151185
pl.add_compiler_flags("-std:c11", "-nologo")
152186

187+
with pl.configuration("deploy"):
188+
189+
# win32
190+
with pl.platform("Windows"):
191+
with pl.compiler("msvc"):
192+
pl.add_definitions("Py_PYTHON_H")
193+
pl.add_source_files("../../pilotlight/extensions/pl_platform_win32_ext.c")
194+
pl.add_static_link_libraries("ucrt", "user32", "Ole32")
195+
pl.add_compiler_flags("-std:c11", "-nologo")
196+
153197
with pl.target("pilotlight_python", pl.TargetType.EXECUTABLE, False):
154198

155199
pl.add_include_directories(
@@ -248,6 +292,31 @@
248292
"-permissive-", "-Od", "-MD", "-Zi")
249293
pl.set_post_target_build_step('@copy "%VULKAN_SDK%\\bin\\spirv-cross-c-shared.dll" "..\\pilotlight\\" >nul\n')
250294

295+
with pl.configuration("deploy"):
296+
297+
pl.set_output_binary("pilotlight")
298+
pl.set_output_directory("../pilotlight")
299+
300+
# win32
301+
with pl.platform("Windows"):
302+
with pl.compiler("msvc"):
303+
304+
pl.add_include_directories(
305+
"C:/hostedtoolcache/windows/Python/3.14.3/x64/Include"
306+
)
307+
308+
pl.add_definitions("PL_VULKAN_BACKEND")
309+
pl.add_include_directories("%VULKAN_SDK%\\Include")
310+
pl.set_output_binary_extension(".pyd")
311+
pl.add_static_link_libraries("shaderc_combined", "spirv-cross-c-shared", "vulkan-1", "glfw")
312+
pl.add_static_link_libraries("user32", "Shell32", "Ole32", "gdi32", "ucrt", "pl_platform_ext")
313+
pl.add_link_directories("C:/hostedtoolcache/windows/Python/3.14.3/x64/libs", '%VULKAN_SDK%\\Lib')
314+
pl.add_linker_flags("-noimplib", "-noexp", "-incremental:no", "-nodefaultlib:LIBCMT")
315+
pl.add_compiler_flags("-Zc:preprocessor", "-nologo", "-std:c11", "-W4", "-WX", "-wd4201",
316+
"-wd4100", "-wd4996", "-wd4505", "-wd4189", "-wd5105", "-wd4115",
317+
"-permissive-", "-Od", "-MD", "-Zi")
318+
pl.set_post_target_build_step('@copy "%VULKAN_SDK%\\bin\\spirv-cross-c-shared.dll" "..\\pilotlight\\" >nul\n')
319+
251320

252321
#-----------------------------------------------------------------------------
253322
# [SECTION] generate scripts

setup.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
from setuptools import setup, find_packages, Distribution
2+
from setuptools.command import build_py
3+
import distutils.cmd
4+
from codecs import open
5+
import os
6+
from os import path
7+
import textwrap
8+
import sys
9+
import shutil
10+
import subprocess
11+
12+
wip_version = "0.1.0"
13+
14+
def get_platform():
15+
16+
platforms = {
17+
'linux' : 'Linux',
18+
'linux1' : 'Linux',
19+
'linux2' : 'Linux',
20+
'darwin' : 'OS X',
21+
'win32' : 'Windows'
22+
}
23+
if sys.platform not in platforms:
24+
return sys.platform
25+
26+
return platforms[sys.platform]
27+
28+
class BinaryDistribution(Distribution):
29+
def has_ext_modules(var):
30+
return True
31+
32+
class DPGBuildCommand(distutils.cmd.Command):
33+
34+
description = 'DPG Build Command'
35+
user_options = []
36+
37+
def initialize_options(self):
38+
pass
39+
40+
def finalize_options(self):
41+
pass
42+
43+
def run(self):
44+
pass
45+
46+
class BuildPyCommand(build_py.build_py):
47+
def run(self):
48+
self.run_command('dpg_build')
49+
build_py.build_py.run(self)
50+
51+
def setup_package():
52+
53+
src_path = os.path.dirname(os.path.abspath(__file__))
54+
old_path = os.getcwd()
55+
os.chdir(src_path)
56+
sys.path.insert(0, src_path)
57+
58+
metadata = dict(
59+
name='pilotlight', # Required
60+
version=wip_version, # Required
61+
author="Jonathan Hoffstadt", # Optional
62+
author_email="jonathanhoffstadt@yahoo.com", # Optional
63+
description='Pilot Light', # Required
64+
# long_description=long_description, # Optional
65+
# long_description_content_type='text/markdown', # Optional
66+
# url='https://github.com/PilotLightTech/pilotlight-python', # Optional
67+
license = 'MIT',
68+
python_requires='>=3.14',
69+
classifiers=[
70+
'Development Status :: 5 - Production/Stable',
71+
'Intended Audience :: Education',
72+
'Intended Audience :: Developers',
73+
'Intended Audience :: Science/Research',
74+
'License :: OSI Approved :: MIT License',
75+
'Operating System :: Microsoft :: Windows :: Windows 10',
76+
'Programming Language :: Python :: 3.14',
77+
'Programming Language :: Python :: Implementation :: CPython',
78+
'Programming Language :: Python :: 3 :: Only',
79+
'Topic :: Software Development :: User Interfaces',
80+
'Topic :: Software Development :: Libraries :: Python Modules',
81+
],
82+
packages=['pilotlight'],
83+
package_data={},
84+
distclass=BinaryDistribution,
85+
cmdclass={
86+
'dpg_build': DPGBuildCommand,
87+
'build_py': BuildPyCommand,
88+
},
89+
)
90+
91+
if get_platform() == "Windows":
92+
metadata['package_data']['pilotlight'] = ["__init__.py", "pilotlight.pyd", "pilotlight.pyi", "pl_core.py", "pl_draw_ext.py", "pl_starter_ext.py", "pl_ui_ext.py", "pl_vfs_ext.py", "spirv-cross-c-shared.dll"]
93+
94+
if "--force" in sys.argv:
95+
sys.argv.remove('--force')
96+
97+
try:
98+
setup(**metadata)
99+
finally:
100+
del sys.path[0]
101+
os.chdir(old_path)
102+
return
103+
104+
if __name__ == '__main__':
105+
setup_package()
106+

0 commit comments

Comments
 (0)