Skip to content

Commit b3623c0

Browse files
committed
WIP
1 parent 8320f5a commit b3623c0

12 files changed

Lines changed: 1212 additions & 49 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 108 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on:
2323

2424
jobs:
2525

26-
build-package:
26+
build-windows-wheels:
2727

2828
runs-on: windows-2022
2929
strategy:
@@ -74,25 +74,120 @@ jobs:
7474
cd %GITHUB_WORKSPACE%
7575
python -m setup bdist_wheel --plat-name win_amd64 --dist-dir dist
7676
77-
- uses: actions/upload-artifact@v4
77+
- name: Upload Windows ${{ matrix.python-version }} Wheel
78+
uses: actions/upload-artifact@v4
7879
with:
79-
name: pltools wheel
80-
path: |
81-
${{ github.workspace }}/dist/*.whl
82-
${{ github.workspace }}/dist/*.tar.gz
83-
retention-days: 1
84-
if-no-files-found: error
80+
name: windowsbuild${{ matrix.python-version }}
81+
path: ${{ github.workspace }}/dist/*.whl
82+
overwrite: true
83+
84+
build-linux-wheels:
85+
86+
runs-on: ubuntu-22.04
87+
env:
88+
CXX: g++-10
89+
strategy:
90+
matrix:
91+
python-version: ["3.14"]
92+
93+
steps:
94+
95+
- name: Checkout
96+
uses: actions/checkout@v4
97+
98+
- name: Setup Python ${{ matrix.python-version }}
99+
uses: actions/setup-python@v5
100+
with:
101+
python-version: ${{ matrix.python-version }}
102+
103+
- name: Show Python build paths
104+
run: |
105+
python -c "import sys, sysconfig; print(sys.executable); print(sys.version)"
106+
python -c "import sysconfig; print('include=', sysconfig.get_paths()['include'])"
107+
python -c "import sysconfig; print('platinclude=', sysconfig.get_paths().get('platinclude'))"
108+
python -c "import sysconfig; print('EXT_SUFFIX=', sysconfig.get_config_var('EXT_SUFFIX'))"
109+
110+
- name: Install Dependencies
111+
run: |
112+
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
113+
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.4.309-jammy.list https://packages.lunarg.com/vulkan/1.4.309/lunarg-vulkan-1.4.309-jammy.list
114+
sudo apt update
115+
sudo apt install vulkan-sdk
116+
sudo apt install libx11-dev
117+
sudo apt install libxkbcommon-x11-dev
118+
sudo apt install libx11-xcb-dev
119+
sudo apt install libxcb-xfixes0-dev
120+
sudo apt install libxcb-cursor-dev
121+
sudo apt install libxcb-cursor0
122+
sudo apt install libxcb-keysyms1-dev
123+
sudo apt install libxcursor-dev
124+
sudo apt install libxrandr-dev
125+
sudo apt install libxinerama-dev
126+
sudo apt install libgl-dev
127+
sudo apt install libxi-dev
128+
cd $GITHUB_WORKSPACE
129+
cd ..
130+
git clone https://github.com/PilotLightTech/pilotlight
131+
cd pilotlight-python
132+
133+
- name: Build Package
134+
run: |
135+
cd $GITHUB_WORKSPACE
136+
cd scripts
137+
python3 gen_build.py
138+
cd ../src
139+
chmod +x build.sh
140+
./build.sh -c deploy
141+
cd ..
142+
143+
- name: Build Wheel
144+
run: |
145+
cd $GITHUB_WORKSPACE
146+
python -m pip install --upgrade pip twine wheel setuptools
147+
python -m setup bdist_wheel --plat-name manylinux1_x86_64 --dist-dir dist
148+
149+
- name: Upload Linux ${{ matrix.python-version }} Wheel
150+
uses: actions/upload-artifact@v4
151+
with:
152+
name: linuxbuild${{ matrix.python-version }}
153+
path: ${{ github.workspace }}/dist/*.whl
154+
overwrite: true
155+
156+
deploy-packages:
157+
158+
needs: [build-windows-wheels, build-linux-wheels]
159+
runs-on: windows-2022
160+
161+
steps:
162+
163+
- name: Checkout
164+
uses: actions/checkout@v4
165+
166+
- name: Set up Python 3.9
167+
uses: actions/setup-python@v5
168+
with:
169+
python-version: 3.9
170+
171+
- name: Install Dependencies
172+
run: |
173+
python -m pip install --upgrade pip setuptools wheel twine
174+
175+
- name: Download artifacts
176+
uses: actions/download-artifact@v4
85177

86178
- name: PyPi Deployment
87179
shell: cmd
88180
if: ${{contains(github.event.inputs.deploy, 'true') && github.ref == 'refs/heads/master'}}
89181
run: |
90-
python -m pip install twine
91-
python -m twine upload dist/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} --skip-existing
182+
python -m twine upload windowsbuild*/* -u __token__ -p ${{ secrets.PYPI_PASSWORD }} --skip-existing
183+
python -m twine upload apple10sbuild*/* -u __token__ -p ${{ secrets.PYPI_PASSWORD }} --skip-existing
184+
python -m twine upload linuxbuild*/* -u __token__ -p ${{ secrets.PYPI_PASSWORD }} --skip-existing
92185
93186
- name: Test PyPi Deployment
94187
shell: cmd
95-
if: ${{contains(github.event.inputs.deploytest, 'true') && github.ref == 'refs/heads/master'}}
188+
if: "contains(github.event.inputs.deploytest, 'true')"
96189
run: |
97-
python -m pip install twine
98-
python -m twine upload --repository testpypi dist/* -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }} --skip-existing
190+
dir
191+
python -m twine upload --repository testpypi windowsbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_PASSWORD }} --skip-existing
192+
python -m twine upload --repository testpypi apple10sbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_PASSWORD }} --skip-existing
193+
python -m twine upload --repository testpypi linuxbuild*/* -u __token__ -p ${{ secrets.TEST_PYPI_PASSWORD }} --skip-existing

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pilotlight/pilotlight.pyd
1212
pilotlight/pilotlight_d.pyd
1313
pilotlight/*.pdb
1414
pilotlight/*.dll
15+
pilotlight/*.so
1516

1617
# debug files
1718
src/*.pdb

.vscode/launch.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "0.2.0",
33
"configurations": [
4-
{
4+
{
55
"name": "(Windows) Launch",
66
"type": "cppvsdbg",
77
"program": "${workspaceFolder}/out/pilotlight_python.exe",
@@ -11,6 +11,16 @@
1111
"stopAtEntry": false,
1212
"cwd": "${workspaceFolder}/out/",
1313
"environment": []
14+
},
15+
{
16+
"name": "(Linux) Launch",
17+
"type": "cppdbg",
18+
"request": "launch",
19+
"program": "${workspaceFolder}/out/pilotlight_python",
20+
"args": [],
21+
"cwd": "${workspaceFolder}/out",
22+
"MIMode": "gdb",
23+
"miDebuggerPath": "/usr/bin/gdb"
1424
}
1525
]
1626
}

pilotlight/pilotlight.so

4.88 MB
Binary file not shown.

sandbox/main.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <stdio.h>
99
#include <stdlib.h>
1010

11+
#define PL_ARRAYSIZE(X) ((int)(sizeof(X) / sizeof(*(X))))
12+
1113
//-----------------------------------------------------------------------------
1214
// [SECTION] forward declarations
1315
//-----------------------------------------------------------------------------
@@ -24,8 +26,8 @@ int main()
2426
// add our custom module
2527
// PyImport_AppendInittab("pilotlight.pilotlight", &PyInit_pilotlight);
2628

27-
Py_NoSiteFlag = 1; // this must be set to 1
28-
Py_DontWriteBytecodeFlag = 1;
29+
// Py_NoSiteFlag = 1; // this must be set to 1
30+
// Py_DontWriteBytecodeFlag = 1;
2931

3032
if(pl_init_python() != 0)
3133
return -1;
@@ -92,13 +94,20 @@ pl_init_python()
9294
}
9395

9496
char* const acModulePaths[] = {
97+
#ifdef _WIN32
9598
"../dependencies/cpython/PCbuild/amd64",
99+
100+
101+
#elif defined(__APPLE__)
102+
#else // linux
103+
// "../dependencies/cpython/build/debug/build/lib.linux-x86_64-3.14/",
104+
#endif
96105
"../dependencies/cpython/Lib",
97106
"..",
98107
"../sandbox"
99108
};
100109

101-
if (PyInitConfig_SetStrList(config, "module_search_paths", 4, acModulePaths) < 0) {
110+
if (PyInitConfig_SetStrList(config, "module_search_paths", PL_ARRAYSIZE(acModulePaths), acModulePaths) < 0) {
102111
goto error;
103112
}
104113

scripts/build_python_for_linux.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Allow user to set number of jobs when compiling
5+
while getopts 'j:' OPTION; do
6+
case "$OPTION" in
7+
j)
8+
jobs="-j $OPTARG"
9+
;;
10+
?)
11+
exit 1
12+
;;
13+
esac
14+
shift $(($OPTIND - 1))
15+
done
16+
17+
cd $(dirname $0) # Make sure we start in the Scripts directory
18+
cd ../dependencies/cpython
19+
20+
# Run `./BuildPythonForLinux.sh clean` to clean up the build directory
21+
if [ "$1" = "clean" ]; then
22+
rm -r build
23+
exit 0
24+
fi
25+
26+
# Default is to do a debug build
27+
target="debug"
28+
configure_args="--with-pydebug --enable-shared"
29+
30+
# Build in build/ so cpython's .gitignore hides the build output
31+
mkdir -p "build/$target"
32+
cd "build/$target"
33+
34+
# Reconfiguring is time-consuming. Skip if it's already been done
35+
if [ ! -f Makefile ]; then
36+
/bin/bash ../../configure $configure_args
37+
fi
38+
39+
make $jobs

scripts/build_python_for_win32.bat

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
rem get current this batch file directory
44
set dir=%~dp0
55

6-
:Run
7-
if "%~1"=="--ci" goto Release
8-
9-
:Debug
106
rem clean up previous build
117
echo Cleaning previous python builds
128
call "%dir%..\dependencies\cpython\PCbuild\build.bat" -c Debug -p x64 -t CleanAll
@@ -15,13 +11,4 @@ rem build python
1511
echo Building python in Debug and Release for x64
1612
call "%dir%..\dependencies\cpython\PCbuild\build.bat" -c Debug -p x64 -t Build
1713

18-
:Release
19-
rem clean up previous build
20-
echo Cleaning previous python builds
21-
call "%dir%..\dependencies\cpython\PCbuild\build.bat" -p x64 -t CleanAll
22-
23-
rem build python
24-
echo Building python in Debug and Release for x64
25-
call "%dir%..\dependencies\cpython\PCbuild\build.bat" -p x64 -t Build
26-
2714
pause

0 commit comments

Comments
 (0)