From 9e6af7e423494e548d88f1cd90799383d486e31c Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 21 Jan 2025 17:04:40 +1100 Subject: [PATCH 01/72] Add a workflow to test MacOS builds on x86_64 and arm64 --- .github/workflows/macos_wheel_test.yaml | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/macos_wheel_test.yaml diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml new file mode 100644 index 00000000..e6fead58 --- /dev/null +++ b/.github/workflows/macos_wheel_test.yaml @@ -0,0 +1,46 @@ +name: WheelDeployTest + +on: + push + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + env: + CIBW_BUILD_VERBOSITY: 3 + CIBW_BUILD: cp312-* + #CIBW_TEST_COMMAND: python3 -m doctest -v lavavu/lavavu.py + #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} + CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include + CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y --nogpgcheck libtiff-devel + CIBW_BEFORE_BUILD_MACOS: brew install ffmpeg + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + strategy: + matrix: + # MacOS 13 runner is x86_64, 14 is arm64 + # (https://cibuildwheel.pypa.io/en/stable/faq/#how) + os: [macos-13, macos-14] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.8' + + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel==2.22.0 + + - name: Build wheels + run: | + python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + From 273d363d2e11df068ba1d0c13d76bce6f4df16e6 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 21 Jan 2025 20:41:12 +1100 Subject: [PATCH 02/72] Try setting MACOSX_DEPLOYMENT_TARGET --- .github/workflows/macos_wheel_test.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index e6fead58..15f7aa85 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -34,6 +34,10 @@ jobs: run: | python -m pip install cibuildwheel==2.22.0 + # https://github.com/pypa/cibuildwheel/issues/563 + - name: Set macOS deployment target + run: echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV + - name: Build wheels run: | python -m cibuildwheel --output-dir wheelhouse From 7fc55780005679d3ffc621f9a3e5508753e2646e Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 12:33:28 +1100 Subject: [PATCH 03/72] See if we can fix av libs not found on mac arm builds --- .github/workflows/macos_wheel_test.yaml | 6 ++++-- setup.py | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 15f7aa85..2c999098 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -9,7 +9,8 @@ jobs: runs-on: ${{ matrix.os }} env: CIBW_BUILD_VERBOSITY: 3 - CIBW_BUILD: cp312-* + CIBW_BUILD: cp311-* cp312-* + #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* #CIBW_TEST_COMMAND: python3 -m doctest -v lavavu/lavavu.py #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include @@ -20,7 +21,8 @@ jobs: matrix: # MacOS 13 runner is x86_64, 14 is arm64 # (https://cibuildwheel.pypa.io/en/stable/faq/#how) - os: [macos-13, macos-14] + #os: [macos-13, macos-14] + os: [macos-14] steps: - uses: actions/checkout@v4 diff --git a/setup.py b/setup.py index b1cc8ae7..ce70f1ed 100644 --- a/setup.py +++ b/setup.py @@ -412,6 +412,15 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]): #Runtime library dirs doesn't work on mac, so set rpath manually for l in lib_dirs: ldflags.append('-Wl,-rpath,'+l) + #On silicon, homebrew has moved and libs can't be found + if platform.processor() == 'arm': + os.system('ls -l /opt/homebrew') + os.system('ls -l /opt/homebrew/lib') + os.system('ls -l /opt/homebrew/include') + os.system('pkg-config --libs libavcodec') + + lib_dirs += ['/opt/homebrew/lib'] + inc_dirs += ['/opt/homebrew/include'] #Other posix libs libs += ['dl', 'pthread', 'm'] From 330e545f71fefc598d0583f9bd71785238653c1d Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 12:58:30 +1100 Subject: [PATCH 04/72] Try a hack --- .github/workflows/macos_wheel_test.yaml | 9 +++++++-- setup.py | 9 ++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 2c999098..4ac9b418 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -9,13 +9,14 @@ jobs: runs-on: ${{ matrix.os }} env: CIBW_BUILD_VERBOSITY: 3 - CIBW_BUILD: cp311-* cp312-* + CIBW_BUILD: cp312-* + #CIBW_BUILD: cp311-* cp312-* #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* #CIBW_TEST_COMMAND: python3 -m doctest -v lavavu/lavavu.py #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y --nogpgcheck libtiff-devel - CIBW_BEFORE_BUILD_MACOS: brew install ffmpeg + CIBW_BEFORE_BUILD_MACOS: brew install ffmpeg && ln -s /opt/homebrew/lib /usr/local/lib && ln -s /opt/homebrew/include /usr/local/include CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 strategy: matrix: @@ -40,6 +41,10 @@ jobs: - name: Set macOS deployment target run: echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV + - name: Checks + run: | + pkg-config --cflags --libs libavcodec + - name: Build wheels run: | python -m cibuildwheel --output-dir wheelhouse diff --git a/setup.py b/setup.py index ce70f1ed..98dc917d 100644 --- a/setup.py +++ b/setup.py @@ -414,13 +414,8 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]): ldflags.append('-Wl,-rpath,'+l) #On silicon, homebrew has moved and libs can't be found if platform.processor() == 'arm': - os.system('ls -l /opt/homebrew') - os.system('ls -l /opt/homebrew/lib') - os.system('ls -l /opt/homebrew/include') - os.system('pkg-config --libs libavcodec') - - lib_dirs += ['/opt/homebrew/lib'] - inc_dirs += ['/opt/homebrew/include'] + lib_dirs += ['/opt/homebrew/lib'] + inc_dirs += ['/opt/homebrew/include'] #Other posix libs libs += ['dl', 'pthread', 'm'] From 93b055c9b5f240e57802c1086fdf262bdf791cc7 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 13:05:22 +1100 Subject: [PATCH 05/72] Remove this --- .github/workflows/macos_wheel_test.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 4ac9b418..6fb87e4d 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -41,10 +41,6 @@ jobs: - name: Set macOS deployment target run: echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV - - name: Checks - run: | - pkg-config --cflags --libs libavcodec - - name: Build wheels run: | python -m cibuildwheel --output-dir wheelhouse From ef93d8cf5feba4ac70bf806d3033e2e28622bac4 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 13:09:14 +1100 Subject: [PATCH 06/72] Try with sudo --- .github/workflows/macos_wheel_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 6fb87e4d..4f77aad8 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -16,7 +16,7 @@ jobs: #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y --nogpgcheck libtiff-devel - CIBW_BEFORE_BUILD_MACOS: brew install ffmpeg && ln -s /opt/homebrew/lib /usr/local/lib && ln -s /opt/homebrew/include /usr/local/include + CIBW_BEFORE_BUILD_MACOS: brew install ffmpeg && sudo ln -s /opt/homebrew/lib /usr/local/lib && sudo ln -s /opt/homebrew/include /usr/local/include CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 strategy: matrix: From 1c9b0c97037978a82105525899523ac230574bad Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 16:03:41 +1100 Subject: [PATCH 07/72] Try running tests with MacOS builds --- .github/workflows/macos_wheel_test.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 4f77aad8..d5435545 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -18,6 +18,13 @@ jobs: CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y --nogpgcheck libtiff-devel CIBW_BEFORE_BUILD_MACOS: brew install ffmpeg && sudo ln -s /opt/homebrew/lib /usr/local/lib && sudo ln -s /opt/homebrew/include /usr/local/include CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_TEST_COMMAND: > + git clone --depth 1 https://github.com/lavavu/Testing && + cd Testing && + export LV_ECHO_FAIL=1 && + export LV_ARGS="-v" && + python runall.py + strategy: matrix: # MacOS 13 runner is x86_64, 14 is arm64 From be88e2f561d76839a74ce1e0a980a48deb04f801 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 16:43:52 +1100 Subject: [PATCH 08/72] Use moderngl for tests --- .github/workflows/macos_wheel_test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index d5435545..dc493342 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -19,8 +19,10 @@ jobs: CIBW_BEFORE_BUILD_MACOS: brew install ffmpeg && sudo ln -s /opt/homebrew/lib /usr/local/lib && sudo ln -s /opt/homebrew/include /usr/local/include CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND: > + pip install moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && + export LV_CONTEXT=moderngl && export LV_ECHO_FAIL=1 && export LV_ARGS="-v" && python runall.py From a75033be3e2b55290f58c83d0d3d097529fe16ff Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 18:27:02 +1100 Subject: [PATCH 09/72] Remove webgl defines Future WebGL support will be via emscripten only --- lavavu/shaders/default.frag | 6 ------ lavavu/shaders/default.vert | 5 +---- lavavu/shaders/fontShader.frag | 5 ----- lavavu/shaders/lineShader.frag | 4 ---- lavavu/shaders/lineShader.vert | 2 -- lavavu/shaders/pointShader.frag | 5 ----- lavavu/shaders/pointShader.vert | 4 ---- lavavu/shaders/triShader.frag | 17 ----------------- lavavu/shaders/triShader.vert | 4 ---- 9 files changed, 1 insertion(+), 51 deletions(-) diff --git a/lavavu/shaders/default.frag b/lavavu/shaders/default.frag index f73a5e5e..d17e61e3 100644 --- a/lavavu/shaders/default.frag +++ b/lavavu/shaders/default.frag @@ -1,20 +1,14 @@ in vec4 vColour; -#ifdef WEBGL -#define outColour gl_FragColor -#else flat in vec4 vFlatColour; uniform bool uFlat; out vec4 outColour; -#endif void main(void) { -#ifndef WEBGL if (uFlat) outColour = vFlatColour; else -#endif outColour = vColour; } diff --git a/lavavu/shaders/default.vert b/lavavu/shaders/default.vert index 421c99f2..c7607d12 100644 --- a/lavavu/shaders/default.vert +++ b/lavavu/shaders/default.vert @@ -3,15 +3,12 @@ in vec4 aVertexColour; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; out vec4 vColour; -#ifndef WEBGL flat out vec4 vFlatColour; -#endif + void main(void) { gl_Position = uPMatrix * uMVMatrix * aVertexPosition; vColour = aVertexColour; -#ifndef WEBGL vFlatColour = aVertexColour; -#endif } diff --git a/lavavu/shaders/fontShader.frag b/lavavu/shaders/fontShader.frag index 5c92b2da..209d37dd 100644 --- a/lavavu/shaders/fontShader.frag +++ b/lavavu/shaders/fontShader.frag @@ -4,12 +4,7 @@ in vec2 vTexCoord; uniform bool uTextured; uniform sampler2D uTexture; -#ifdef WEBGL -#define outColour gl_FragColor -#define texture(a,b) texture2D(a,b) -#else out vec4 outColour; -#endif void main(void) { diff --git a/lavavu/shaders/lineShader.frag b/lavavu/shaders/lineShader.frag index 8b7dcf1e..9ac71ad6 100644 --- a/lavavu/shaders/lineShader.frag +++ b/lavavu/shaders/lineShader.frag @@ -9,11 +9,7 @@ uniform vec3 uClipMin; uniform vec3 uClipMax; uniform bool uOpaque; -#ifdef WEBGL -#define outColour gl_FragColor -#else out vec4 outColour; -#endif void main(void) { diff --git a/lavavu/shaders/lineShader.vert b/lavavu/shaders/lineShader.vert index 9979f2b5..15b73ca3 100644 --- a/lavavu/shaders/lineShader.vert +++ b/lavavu/shaders/lineShader.vert @@ -3,9 +3,7 @@ in vec4 aVertexColour; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; -#ifndef WEBGL uniform int uPointDist; // Scale by distance -#endif uniform vec4 uColour; uniform float uOpacity; diff --git a/lavavu/shaders/pointShader.frag b/lavavu/shaders/pointShader.frag index 406723b3..353bf871 100644 --- a/lavavu/shaders/pointShader.frag +++ b/lavavu/shaders/pointShader.frag @@ -20,12 +20,7 @@ in float vPointSize; in vec3 vPosEye; in float vPointType; -#ifdef WEBGL -#define outColour gl_FragColor -#define texture(a,b) texture2D(a,b) -#else out vec4 outColour; -#endif void calcColour(vec3 colour, float alpha) { diff --git a/lavavu/shaders/pointShader.vert b/lavavu/shaders/pointShader.vert index cc532016..75d6504f 100644 --- a/lavavu/shaders/pointShader.vert +++ b/lavavu/shaders/pointShader.vert @@ -7,11 +7,7 @@ uniform mat4 uPMatrix; out vec4 vColour; -#ifdef WEBGL -const int uPointDist = 1; // Scale by distance -#else uniform int uPointDist; // Scale by distance -#endif in float aSize; in float aPointType; diff --git a/lavavu/shaders/triShader.frag b/lavavu/shaders/triShader.frag index 8833f36d..b57cde42 100644 --- a/lavavu/shaders/triShader.frag +++ b/lavavu/shaders/triShader.frag @@ -22,25 +22,10 @@ uniform vec3 uClipMax; uniform bool uOpaque; uniform vec4 uLight; -#ifdef WEBGL -#define outColour gl_FragColor -#define texture(a,b) texture2D(a,b) - -//Before OpenGL 3+ we need our own isnan function -bool isnan3(vec3 val) -{ - if (!(val.x < 0.0 || 0.0 < val.x || val.x == 0.0)) return true; - if (!(val.y < 0.0 || 0.0 < val.y || val.y == 0.0)) return true; - if (!(val.z < 0.0 || 0.0 < val.z || val.z == 0.0)) return true; - return false; -} - -#else #define isnan3(v) any(isnan(v)) flat in vec4 vFlatColour; uniform bool uFlat; out vec4 outColour; -#endif uniform bool uCalcNormal; @@ -69,10 +54,8 @@ void main(void) if (any(lessThan(vVertex, uClipMin)) || any(greaterThan(vVertex, uClipMax))) discard; vec4 fColour = vColour; -#ifndef WEBGL if (uFlat) fColour = vFlatColour; -#endif float alpha = fColour.a; if (uTextured && vTexCoord.x > -1.0) //Null texcoord (-1,-1) { diff --git a/lavavu/shaders/triShader.vert b/lavavu/shaders/triShader.vert index 8f792ce7..4bdcf9e9 100644 --- a/lavavu/shaders/triShader.vert +++ b/lavavu/shaders/triShader.vert @@ -2,9 +2,7 @@ in vec3 aVertexPosition; in vec3 aVertexNormal; in vec4 aVertexColour; in vec2 aVertexTexCoord; -#ifndef WEBGL flat out vec4 vFlatColour; -#endif uniform mat4 uMVMatrix; uniform mat4 uPMatrix; @@ -34,9 +32,7 @@ void main(void) vColour = aVertexColour; vTexCoord = aVertexTexCoord; -#ifndef WEBGL vFlatColour = vColour; -#endif vVertex = aVertexPosition; //Head light, lightPos=(0,0,0) - vPosEye From 219d79f50b71fedc31e9367df6ef26f1e686d3fb Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 18:56:11 +1100 Subject: [PATCH 10/72] Fix default shader, make inline shaders match default.frag/vert --- lavavu/shaders/default.vert | 3 +++ src/Shaders.cpp | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lavavu/shaders/default.vert b/lavavu/shaders/default.vert index c7607d12..950c3e4c 100644 --- a/lavavu/shaders/default.vert +++ b/lavavu/shaders/default.vert @@ -1,14 +1,17 @@ in vec4 aVertexPosition; in vec4 aVertexColour; +in vec2 aVertexTexCoord; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; out vec4 vColour; +out vec2 vTexCoord; flat out vec4 vFlatColour; void main(void) { gl_Position = uPMatrix * uMVMatrix * aVertexPosition; vColour = aVertexColour; + vTexCoord = aVertexTexCoord; vFlatColour = aVertexColour; } diff --git a/src/Shaders.cpp b/src/Shaders.cpp index c132c979..fd0bb4e1 100644 --- a/src/Shaders.cpp +++ b/src/Shaders.cpp @@ -9,20 +9,30 @@ uniform mat4 uMVMatrix; uniform mat4 uPMatrix; out vec4 vColour; out vec2 vTexCoord; +flat out vec4 vFlatColour; + void main(void) { gl_Position = uPMatrix * uMVMatrix * aVertexPosition; vColour = aVertexColour; vTexCoord = aVertexTexCoord; + vFlatColour = aVertexColour; } )"; const char *fragmentShader = R"( in vec4 vColour; -in vec2 vTexCoord; + +flat in vec4 vFlatColour; +uniform bool uFlat; +out vec4 outColour; + void main(void) { - gl_FragColor = vColour; + if (uFlat) + outColour = vFlatColour; + else + outColour = vColour; } )"; From 59788ac88bd2acc576c565c337087cb98ab93898 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 19:10:09 +1100 Subject: [PATCH 11/72] Missed volumeShader when removing WEBGL features --- lavavu/shaders/volumeShader.frag | 63 -------------------------------- 1 file changed, 63 deletions(-) diff --git a/lavavu/shaders/volumeShader.frag b/lavavu/shaders/volumeShader.frag index 4b94a4e1..139004c9 100644 --- a/lavavu/shaders/volumeShader.frag +++ b/lavavu/shaders/volumeShader.frag @@ -6,17 +6,10 @@ * https://www.gnu.org/licenses/lgpl.html * (volume shader from sharevol https://github.com/OKaluza/sharevol) */ -#ifdef WEBGL -uniform sampler2D uVolume; -#define NO_DEPTH_WRITE -#define outColour gl_FragColor -#define texture(a,b) texture2D(a,b) -#else //Included dynamically before compile in WebGL mode... const int maxSamples = 2048; uniform sampler3D uVolume; out vec4 outColour; -#endif const float depthT = 0.99; //Transmissivity threshold below which depth write applied @@ -63,63 +56,7 @@ vec3 bbMax; float interpolate_tricubic_fast(vec3 coord); #endif -#ifdef WEBGL - -vec2 islices = vec2(1.0 / slices.x, 1.0 / slices.y); -float maxslice = slices.x * slices.y - 1.0; -//Clamp to a bit before halfway for the edge voxels -vec2 cmin = vec2(0.55/(slices.x*slices.y), 0.55/(slices.x*slices.y)); -vec2 cmax = vec2(1.0, 1.0) - cmin; - -float sample(vec3 pos) -{ - //Get z slice index and position between two slices - float Z = pos.z * maxslice; - float slice = floor(Z); //Index of first slice - Z = fract(Z); - //Edge case at z min (possible with tricubic filtering) - if (int(slice) < 0) - { - slice = 0.0; - Z = 0.0; - } - //Edge case at z max - else if (int(slice) > int(maxslice)-1) - { - slice = maxslice-1.0; - Z = 1.0; - } - //Only start interpolation with next Z slice 1/3 from edges at first & last z slice - //(this approximates how 3d texture volume is sampled at edges with linear filtering - // due to edge sample being included in weighted average twice) - // - min z slice - else if (int(slice) == 0) - { - Z = max(0.0, (Z-0.33) * 1.5); - } - // - max z slice - else if (int(slice) == int(maxslice)-1) - { - Z = min(1.0, Z*1.5); - } - - //X & Y coords of sample scaled to slice size - //(Clamp range at borders to prevent bleeding between tiles due to linear filtering) - vec2 sampleOffset = clamp(pos.xy, cmin, cmax) * islices; - //Offsets in 2D texture of given slice indices - //(add offsets to scaled position within slice to get sample positions) - float A = slice * islices.x; - float B = (slice+1.0) * islices.x; - vec2 z1offset = vec2(fract(A), floor(A) / slices.y) + sampleOffset; - vec2 z2offset = vec2(fract(B), floor(B) / slices.y) + sampleOffset; - - //Interpolate the final value by position between slices [0,1] - return mix(texture2D(uVolume, z1offset).x, texture2D(uVolume, z2offset).x, Z); -} - -#else #define sample(pos) (texture(uVolume, pos).x) -#endif float tex3D(vec3 pos) { From c3016d588a4874b89a78274e6abc390e541a9651 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Wed, 22 Jan 2025 22:48:00 +1100 Subject: [PATCH 12/72] Add some debug messages --- src/Geometry.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Geometry.cpp b/src/Geometry.cpp index 305674c0..947cbae6 100644 --- a/src/Geometry.cpp +++ b/src/Geometry.cpp @@ -1204,6 +1204,7 @@ Shader_Ptr Geometry::getShader(DrawingObject* draw) { //Init from property json shaders = draw->properties["shaders"]; + debug_print("Loading shaders from property, length %u\n", shaders.size()); if (shaders.size() == 1) { std::string f = shaders[0]; @@ -1222,6 +1223,10 @@ Shader_Ptr Geometry::getShader(DrawingObject* draw) std::string f = shaders[2]; draw->shader = std::make_shared(v, g, f); } + else + { + debug_print("Invalid shaders property1\n"); + } //Get uniforms/attribs draw->shader->loadUniforms(); @@ -1237,6 +1242,7 @@ Shader_Ptr Geometry::getShader(DrawingObject* draw) Shader_Ptr Geometry::getShader(lucGeometryType type) { //Get the base type for default shader + debug_print("Getting default shader for %d\n", (int)type); lucGeometryType btype; switch (type) { From ce2f2c4f5b6384010bea1cdc06126ac659eafd5b Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 10:40:51 +1100 Subject: [PATCH 13/72] Use standalone unless using moderngl_window --- lavavu/lavavu.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index de938455..22b30a8b 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -2327,8 +2327,9 @@ def _open(self): if platform.system() == 'Linux': self.ctx = moderngl.create_context(standalone=True, require=330, backend='egl') else: - self.ctx = moderngl.create_standalone_context(require=330) - #print(self.ctx.info) + standalone = not self.use_moderngl_window + self.ctx = moderngl.create_standalone_context(standalone=standalone, require=330) + print(self.ctx.info) _LavaVuWrapper._ctx = self.ctx if self.use_moderngl_window and self.ctx: From c293089b335aae913863adee0a255b3ca6ac8d13 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 10:41:01 +1100 Subject: [PATCH 14/72] Debug - print shaders --- src/Geometry.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Geometry.cpp b/src/Geometry.cpp index 947cbae6..51a6ff7b 100644 --- a/src/Geometry.cpp +++ b/src/Geometry.cpp @@ -1204,7 +1204,6 @@ Shader_Ptr Geometry::getShader(DrawingObject* draw) { //Init from property json shaders = draw->properties["shaders"]; - debug_print("Loading shaders from property, length %u\n", shaders.size()); if (shaders.size() == 1) { std::string f = shaders[0]; @@ -1214,6 +1213,7 @@ Shader_Ptr Geometry::getShader(DrawingObject* draw) { std::string v = shaders[0]; std::string f = shaders[1]; + std::cout << "\n----------\nVERTEX SHADER\n----------\n" << v << "\n----------\nnFRAGMENT SHADER\n----------\n" << f << std::endl; draw->shader = std::make_shared(v, f); } else if (shaders.size() == 3) @@ -1223,10 +1223,6 @@ Shader_Ptr Geometry::getShader(DrawingObject* draw) std::string f = shaders[2]; draw->shader = std::make_shared(v, g, f); } - else - { - debug_print("Invalid shaders property1\n"); - } //Get uniforms/attribs draw->shader->loadUniforms(); @@ -1242,7 +1238,6 @@ Shader_Ptr Geometry::getShader(DrawingObject* draw) Shader_Ptr Geometry::getShader(lucGeometryType type) { //Get the base type for default shader - debug_print("Getting default shader for %d\n", (int)type); lucGeometryType btype; switch (type) { From f8f6f5604b6ff0ffbd526eef31403b566de6624e Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 10:48:04 +1100 Subject: [PATCH 15/72] Fix this --- lavavu/lavavu.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 22b30a8b..7ce01556 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -2327,8 +2327,7 @@ def _open(self): if platform.system() == 'Linux': self.ctx = moderngl.create_context(standalone=True, require=330, backend='egl') else: - standalone = not self.use_moderngl_window - self.ctx = moderngl.create_standalone_context(standalone=standalone, require=330) + self.ctx = moderngl.create_context(standalone=True, require=330) print(self.ctx.info) _LavaVuWrapper._ctx = self.ctx From 8f96ffabb4c47471bf3dadd841cd55bf3b829b30 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 10:52:47 +1100 Subject: [PATCH 16/72] Remove print --- lavavu/lavavu.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 7ce01556..22c48d49 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -2328,7 +2328,6 @@ def _open(self): self.ctx = moderngl.create_context(standalone=True, require=330, backend='egl') else: self.ctx = moderngl.create_context(standalone=True, require=330) - print(self.ctx.info) _LavaVuWrapper._ctx = self.ctx if self.use_moderngl_window and self.ctx: From 7dc1791820e22c6336b65a0c29a6da0c5b31f9cc Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 11:20:39 +1100 Subject: [PATCH 17/72] More debugging --- lavavu/lavavu.py | 3 +++ src/Geometry.cpp | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 22c48d49..e532b3a0 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -2330,7 +2330,10 @@ def _open(self): self.ctx = moderngl.create_context(standalone=True, require=330) _LavaVuWrapper._ctx = self.ctx + sys.stderr.write(self.ctx.info) + if self.use_moderngl_window and self.ctx: + sys.stderr.write("USE MODERNGL WINDOW") # Activate the context moderngl_window.activate_context(ctx=self.ctx) diff --git a/src/Geometry.cpp b/src/Geometry.cpp index 51a6ff7b..305674c0 100644 --- a/src/Geometry.cpp +++ b/src/Geometry.cpp @@ -1213,7 +1213,6 @@ Shader_Ptr Geometry::getShader(DrawingObject* draw) { std::string v = shaders[0]; std::string f = shaders[1]; - std::cout << "\n----------\nVERTEX SHADER\n----------\n" << v << "\n----------\nnFRAGMENT SHADER\n----------\n" << f << std::endl; draw->shader = std::make_shared(v, f); } else if (shaders.size() == 3) From 76f8d1354dfd37cedd252b4e6a37a10f0679a75b Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 11:34:15 +1100 Subject: [PATCH 18/72] Fix stderr print --- lavavu/lavavu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index e532b3a0..154b21c5 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -2330,7 +2330,7 @@ def _open(self): self.ctx = moderngl.create_context(standalone=True, require=330) _LavaVuWrapper._ctx = self.ctx - sys.stderr.write(self.ctx.info) + sys.stderr.write(str(self.ctx.info)) if self.use_moderngl_window and self.ctx: sys.stderr.write("USE MODERNGL WINDOW") From 659d339f63db88894c1f8d970e983701106cfb0b Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 11:55:31 +1100 Subject: [PATCH 19/72] Remove --- lavavu/lavavu.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 154b21c5..22c48d49 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -2330,10 +2330,7 @@ def _open(self): self.ctx = moderngl.create_context(standalone=True, require=330) _LavaVuWrapper._ctx = self.ctx - sys.stderr.write(str(self.ctx.info)) - if self.use_moderngl_window and self.ctx: - sys.stderr.write("USE MODERNGL WINDOW") # Activate the context moderngl_window.activate_context(ctx=self.ctx) From bc47967e45ac735dca8ccdf4ce441c8d3ff896ea Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 18:13:08 +1100 Subject: [PATCH 20/72] Try all python versions and MacOS x86 + ARM --- .github/workflows/macos_wheel_test.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index dc493342..f90ece7f 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -9,9 +9,9 @@ jobs: runs-on: ${{ matrix.os }} env: CIBW_BUILD_VERBOSITY: 3 - CIBW_BUILD: cp312-* + #CIBW_BUILD: cp312-* #CIBW_BUILD: cp311-* cp312-* - #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* + CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* #CIBW_TEST_COMMAND: python3 -m doctest -v lavavu/lavavu.py #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include @@ -31,8 +31,7 @@ jobs: matrix: # MacOS 13 runner is x86_64, 14 is arm64 # (https://cibuildwheel.pypa.io/en/stable/faq/#how) - #os: [macos-13, macos-14] - os: [macos-14] + os: [macos-13, macos-14] steps: - uses: actions/checkout@v4 From 86ac2d82a9258de0508cb0503601ee70e788edfb Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Thu, 23 Jan 2025 22:57:35 +1100 Subject: [PATCH 21/72] Try BEFORE_ALL instead of BEFORE_BUILD to avoid brew error Only need to install ffmpeg once --- .github/workflows/macos_wheel_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index f90ece7f..9f9e322c 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -16,7 +16,7 @@ jobs: #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y --nogpgcheck libtiff-devel - CIBW_BEFORE_BUILD_MACOS: brew install ffmpeg && sudo ln -s /opt/homebrew/lib /usr/local/lib && sudo ln -s /opt/homebrew/include /usr/local/include + CIBW_BEFORE_ALL_MACOS: brew install ffmpeg && sudo ln -s /opt/homebrew/lib /usr/local/lib && sudo ln -s /opt/homebrew/include /usr/local/include CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND: > pip install moderngl && From f008a0e21b21c63da36593ebadde57e8ee89919a Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 10:56:10 +1100 Subject: [PATCH 22/72] Clean up multiline commands --- .github/workflows/macos_wheel_test.yaml | 33 +++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 9f9e322c..8159d123 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -15,17 +15,30 @@ jobs: #CIBW_TEST_COMMAND: python3 -m doctest -v lavavu/lavavu.py #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include - CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y --nogpgcheck libtiff-devel - CIBW_BEFORE_ALL_MACOS: brew install ffmpeg && sudo ln -s /opt/homebrew/lib /usr/local/lib && sudo ln -s /opt/homebrew/include /usr/local/include + CIBW_BEFORE_ALL_LINUX: > + cd ~ && + curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && + unzip -o ffmpeg-mini.zip && + dnf install -y --nogpgcheck libtiff-devel + CIBW_BEFORE_ALL_MACOS: > + brew install ffmpeg && + sudo ln -s /opt/homebrew/lib /usr/local/lib && + sudo ln -s /opt/homebrew/include /usr/local/include CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_TEST_COMMAND: > - pip install moderngl && - git clone --depth 1 https://github.com/lavavu/Testing && - cd Testing && - export LV_CONTEXT=moderngl && - export LV_ECHO_FAIL=1 && - export LV_ARGS="-v" && - python runall.py + CIBW_TEST_COMMAND_LINUX: > + git clone --depth 1 https://github.com/lavavu/Testing && + cd Testing && + export LV_ECHO_FAIL=1 && + export LV_ARGS="-v" && + python runall.py + CIBW_TEST_COMMAND_MACOS: > + pip install moderngl && + git clone --depth 1 https://github.com/lavavu/Testing && + cd Testing && + export LV_CONTEXT=moderngl && + export LV_ECHO_FAIL=1 && + export LV_ARGS="-v" && + python runall.py strategy: matrix: From 2ff62c56b27b8ed89376243757576c3d03911831 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 10:56:27 +1100 Subject: [PATCH 23/72] Just use default python for cibuildwheel host --- .github/workflows/macos_wheel_test.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 8159d123..56c7d103 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -51,8 +51,6 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 - with: - python-version: '3.8' - name: Install cibuildwheel run: | From 73751c1514bc9eb42488d791934aef759460f528 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 10:59:17 +1100 Subject: [PATCH 24/72] Try macports instead of homebrew for ffmpeg --- .github/workflows/macos_wheel_test.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 56c7d103..9622c3c1 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -9,10 +9,8 @@ jobs: runs-on: ${{ matrix.os }} env: CIBW_BUILD_VERBOSITY: 3 - #CIBW_BUILD: cp312-* - #CIBW_BUILD: cp311-* cp312-* - CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* - #CIBW_TEST_COMMAND: python3 -m doctest -v lavavu/lavavu.py + CIBW_BUILD: cp312-* cp313-* + #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include CIBW_BEFORE_ALL_LINUX: > @@ -21,9 +19,11 @@ jobs: unzip -o ffmpeg-mini.zip && dnf install -y --nogpgcheck libtiff-devel CIBW_BEFORE_ALL_MACOS: > - brew install ffmpeg && - sudo ln -s /opt/homebrew/lib /usr/local/lib && - sudo ln -s /opt/homebrew/include /usr/local/include + sudo port install ffmpeg + #CIBW_BEFORE_ALL_MACOS: > + # brew install ffmpeg && + # sudo ln -s /opt/homebrew/lib /usr/local/lib && + # sudo ln -s /opt/homebrew/include /usr/local/include CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND_LINUX: > git clone --depth 1 https://github.com/lavavu/Testing && @@ -53,12 +53,12 @@ jobs: uses: actions/setup-python@v5 - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.22.0 + run: python -m pip install cibuildwheel==2.22.0 # https://github.com/pypa/cibuildwheel/issues/563 - - name: Set macOS deployment target - run: echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV + #- name: Set macOS deployment target + # if: runner.os == 'macOS' + # run: echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV - name: Build wheels run: | From 13cac06f1b28231a998241aa30f31f5eafc7ba40 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 11:15:11 +1100 Subject: [PATCH 25/72] Install macports? --- .github/workflows/macos_wheel_test.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 9622c3c1..93958bbe 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -55,6 +55,10 @@ jobs: - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.22.0 + - uses: melusina-org/setup-macports@v1 + if: runner.os == 'macOS' + run: port version + # https://github.com/pypa/cibuildwheel/issues/563 #- name: Set macOS deployment target # if: runner.os == 'macOS' From 082d2bf86380526969b4e3c87d5e9581c152d725 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 11:15:44 +1100 Subject: [PATCH 26/72] Try this --- .github/workflows/macos_wheel_test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 93958bbe..1083b0b6 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -57,7 +57,6 @@ jobs: - uses: melusina-org/setup-macports@v1 if: runner.os == 'macOS' - run: port version # https://github.com/pypa/cibuildwheel/issues/563 #- name: Set macOS deployment target From 95aa6905afb5d130083024cfecd3feb9baa0deaf Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 11:40:59 +1100 Subject: [PATCH 27/72] Switch cibuildwheel python version, test on mac x86 only for now --- .github/workflows/macos_wheel_test.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 1083b0b6..56d4f638 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -44,13 +44,16 @@ jobs: matrix: # MacOS 13 runner is x86_64, 14 is arm64 # (https://cibuildwheel.pypa.io/en/stable/faq/#how) - os: [macos-13, macos-14] + os: [macos-13] + #os: [macos-13, macos-14] steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 + with: + python-version: '3.12' - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.22.0 From 5720ccee0390704c22d021e1ddc3439bd5d382e2 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 16:24:33 +1100 Subject: [PATCH 28/72] Remove ffmpeg from builds, add option for minimal dependencies --- .github/workflows/macos_wheel_test.yaml | 28 +++------------ setup.py | 48 +++++++++++++------------ 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 56d4f638..4641e09c 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -11,27 +11,12 @@ jobs: CIBW_BUILD_VERBOSITY: 3 CIBW_BUILD: cp312-* cp313-* #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* - #CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} - CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include - CIBW_BEFORE_ALL_LINUX: > - cd ~ && - curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && - unzip -o ffmpeg-mini.zip && - dnf install -y --nogpgcheck libtiff-devel - CIBW_BEFORE_ALL_MACOS: > - sudo port install ffmpeg - #CIBW_BEFORE_ALL_MACOS: > - # brew install ffmpeg && - # sudo ln -s /opt/homebrew/lib /usr/local/lib && - # sudo ln -s /opt/homebrew/include /usr/local/include + CIBW_ENVIRONMENT: > + LV_LIB_DIRS=${HOME}/lib + LV_INC_DIRS=${HOME}/include + LV_MIN_DEPS=1 CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_TEST_COMMAND_LINUX: > - git clone --depth 1 https://github.com/lavavu/Testing && - cd Testing && - export LV_ECHO_FAIL=1 && - export LV_ARGS="-v" && - python runall.py - CIBW_TEST_COMMAND_MACOS: > + CIBW_TEST_COMMAND: > pip install moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && @@ -58,9 +43,6 @@ jobs: - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.22.0 - - uses: melusina-org/setup-macports@v1 - if: runner.os == 'macOS' - # https://github.com/pypa/cibuildwheel/issues/563 #- name: Set macOS deployment target # if: runner.os == 'macOS' diff --git a/setup.py b/setup.py index 98dc917d..37bc4633 100644 --- a/setup.py +++ b/setup.py @@ -344,30 +344,34 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]): extra_objects = [sqlite3] # Optional external libraries - check if installed - if find_library('png') and check_libraries(['png', 'z'], ['png.h', 'zlib.h']): - defines += [('HAVE_LIBPNG', 1), ('USE_ZLIB', '1')] - libs += ['png', 'z'] - else: + if 'LV_MIN_DEPS' in os.environ: srcs += ['src/png/lodepng.cpp'] - if find_library('z') and check_libraries(['z'], ['zlib.h']): - defines += [('USE_ZLIB', '1')] - libs += ['z'] + srcs += ['src/miniz/miniz.c'] + else: + if find_library('png') and check_libraries(['png', 'z'], ['png.h', 'zlib.h']): + defines += [('HAVE_LIBPNG', 1), ('USE_ZLIB', '1')] + libs += ['png', 'z'] else: - srcs += ['src/miniz/miniz.c'] - - if find_library('tiff') and check_libraries(['tiff'], ['tiffio.h']): - defines += [('HAVE_LIBTIFF', 1)] - libs += ['tiff'] - - if (find_library('avcodec') and find_library('avformat') and find_library('avutil') - and check_libraries(['avcodec', 'avformat', 'avutil'], - ['libavformat/avformat.h', 'libavcodec/avcodec.h', 'libavutil/mathematics.h', - 'libavutil/imgutils.h'])): - defines += [('HAVE_LIBAVCODEC', 1)] - libs += ['avcodec', 'avformat', 'avutil'] - if find_library('swscale') and check_libraries(['swscale'], ['libswscale/swscale.h']): - defines += [('HAVE_SWSCALE', 1)] - libs += ['swscale'] + srcs += ['src/png/lodepng.cpp'] + if find_library('z') and check_libraries(['z'], ['zlib.h']): + defines += [('USE_ZLIB', '1')] + libs += ['z'] + else: + srcs += ['src/miniz/miniz.c'] + + if find_library('tiff') and check_libraries(['tiff'], ['tiffio.h']): + defines += [('HAVE_LIBTIFF', 1)] + libs += ['tiff'] + + if (find_library('avcodec') and find_library('avformat') and find_library('avutil') + and check_libraries(['avcodec', 'avformat', 'avutil'], + ['libavformat/avformat.h', 'libavcodec/avcodec.h', 'libavutil/mathematics.h', + 'libavutil/imgutils.h'])): + defines += [('HAVE_LIBAVCODEC', 1)] + libs += ['avcodec', 'avformat', 'avutil'] + if find_library('swscale') and check_libraries(['swscale'], ['libswscale/swscale.h']): + defines += [('HAVE_SWSCALE', 1)] + libs += ['swscale'] if P == 'Linux': #Linux GLFW, X11, EGL or OSMesa From 48f17024f623c7a0a8e7e614759b331485923e1c Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 16:39:48 +1100 Subject: [PATCH 29/72] Reduce build_verbosity, re-enable macos arm --- .github/workflows/macos_wheel_test.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 4641e09c..71fd3293 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -8,7 +8,7 @@ jobs: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} env: - CIBW_BUILD_VERBOSITY: 3 + CIBW_BUILD_VERBOSITY: 1 #3 CIBW_BUILD: cp312-* cp313-* #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* CIBW_ENVIRONMENT: > @@ -29,8 +29,7 @@ jobs: matrix: # MacOS 13 runner is x86_64, 14 is arm64 # (https://cibuildwheel.pypa.io/en/stable/faq/#how) - os: [macos-13] - #os: [macos-13, macos-14] + os: [macos-13, macos-14] steps: - uses: actions/checkout@v4 From 72ae9a3dc5eb84d3fa3b4c356b2ccd28c6985c3b Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 16:40:06 +1100 Subject: [PATCH 30/72] Add numpy requirement for python 3.13 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 03bd11b6..cfb787ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,7 @@ requires = [ "numpy==2.0.0; python_version=='3.10'", "numpy==2.0.0; python_version=='3.11'", "numpy==2.0.0; python_version=='3.12'", + "numpy==2.1.0; python_version=='3.13'", ] [project.entry-points."gui_scripts"] From f6fc2e0d144c4e845102a28f97e2ac279e69ff72 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 17:19:22 +1100 Subject: [PATCH 31/72] Use PyAV for ffmpeg/libavcodec support This will allow leaving out ffmpeg support and all the headaches building wheels with these dependencies, still needs work on options passing and quality testing --- lavavu/lavavu.py | 164 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 111 insertions(+), 53 deletions(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 22c48d49..029c6541 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -75,6 +75,11 @@ except (ImportError) as e: moderngl_window = None +try: + import av +except (ImportError) as e: + av = None + #import swig module import LavaVuPython version = LavaVuPython.version @@ -3824,6 +3829,9 @@ def render(self): Render a new frame, explicit display update """ self.app.render() + #Video recording? + if self.recording: + self.recording.frame() def init(self): """ @@ -4131,7 +4139,7 @@ def exec_webgl(self, code, ID=None): from IPython.display import display,HTML,Javascript display(Javascript(js + code)) - def video(self, filename="", fps=30, quality=1, resolution=(0,0), **kwargs): + def video(self, filename="", resolution=(0,0), fps=30, quality=0, encoder="h264", player=None, options={}, **kwargs): """ Record and show the generated video inline within an ipython notebook. @@ -4148,25 +4156,36 @@ def video(self, filename="", fps=30, quality=1, resolution=(0,0), **kwargs): ---------- filename : str Name of the file to save, if not provided a default will be used + resolution : list or tuple + Video resolution in pixels [x,y] fps : int Frames to output per second of video quality : int - Encoding quality, 1=low(default), 2=medium, 3=high, higher quality reduces + Encoding quality, 1=low, 2=medium, 3=high, higher quality reduces encoding artifacts at cost of larger file size - resolution : list or tuple - Video resolution in pixels [x,y] + If omitted will use default settings, can fine tune settings in kwargs + encoder : str + Name of encoder to use, eg: "h264" (default), "mpeg" + player : dict + Args to pass to the player when the video is finished, eg: + {"width" : 800, "height", 400, "params": "controls autoplay"} + options : dict + Args to pass to the encoder, eg: see + https://trac.ffmpeg.org/wiki/Encode/H.264 **kwargs : - Any additional keyword args will be passed to lavavu.player() + Any additional keyword args will also be passed as options to the encoder Returns ------- recorder : Video(object) Context manager object that controls the video recording """ - return Video(self, filename, resolution, fps, quality, **kwargs) + return Video(self, filename, resolution, fps, quality, encoder, player, options, **kwargs) def video_steps(self, filename="", start=0, end=0, fps=10, quality=1, resolution=(0,0), **kwargs): """ + TODO: Fix to use pyAV + Record a video of the model by looping through all time steps Shows the generated video inline within an ipython notebook. @@ -5391,6 +5410,8 @@ class Video(object): """ The Video class provides an interface to record animations + This now uses pyav avoiding the need to build LavaVu with ffmpeg support + Example ------- @@ -5402,7 +5423,7 @@ class Video(object): ... lv.rotate('y', 10) # doctest: +SKIP ... lv.render() # doctest: +SKIP """ - def __init__(self, viewer=None, filename="", resolution=(0,0), framerate=30, quality=1, **kwargs): + def __init__(self, viewer=None, filename="", resolution=(0,0), framerate=30, quality=0, encoder="h264", player=None, options={}, **kwargs): """ Record and show the generated video inline within an ipython notebook. @@ -5422,79 +5443,111 @@ def __init__(self, viewer=None, filename="", resolution=(0,0), framerate=30, qua fps : int Frames to output per second of video quality : int - Encoding quality, 1=low(default), 2=medium, 3=high, higher quality reduces + Encoding quality, 1=low, 2=medium, 3=high, higher quality reduces encoding artifacts at cost of larger file size + If omitted will use default settings, can fine tune settings in kwargs resolution : list or tuple Video resolution in pixels [x,y] + encoder : str + Name of encoder to use, eg: "h264" (default), "mpeg" + player : dict + Args to pass to the player when the video is finished, eg: + {"width" : 800, "height", 400, "params": "controls autoplay"} + options : dict + Args to pass to the encoder, eg: see + https://trac.ffmpeg.org/wiki/Encode/H.264 **kwargs : - Any additional keyword args will be passed to lavavu.player() + Any additional keyword args will also be passed as options to the encoder """ + if av is None: + print("Video output not supported without pyAV - pip install pyav") + return self.resolution = resolution + if self.resolution[0] == 0: + self.resolution = viewer.width + if self.resolution[1] == 0: + self.resolution = viewer.height self.framerate = framerate self.quality = quality self.viewer = viewer self.filename = filename - self.kwargs = kwargs - if not viewer: - self.encoder = LavaVuPython.VideoEncoder(filename, framerate, quality); - else: - self.encoder = None + if len(self.filename) == 0: + self.filename = "lavavu.mp4" + self.player = player + if self.player is None: + #Default player is half output resolution + self.player = {"width": self.resolution[0] // 2, "height": self.resolution[1] // 2} + self.encoder = encoder + self.options = options + #Also include extra args + options.update(kwargs) + self.container = None def start(self): """ Start recording, all rendered frames will be added to the video """ - if self.encoder: - if self.resolution[0] <= 0: self.resolution[0] = 1280 - if self.resolution[1] <= 0: self.resolution[1] = 720 - self.encoder.open(self.resolution[0], self.resolution[1]) - else: - self.filename = self.viewer.app.encodeVideo(self.filename, self.framerate, self.quality, self.resolution[0], self.resolution[1]) - #Clear existing image frames - if os.path.isdir(self.filename): - for f in glob.glob(self.filename + "/frame_*.jpg"): - os.remove(f) + #https://trac.ffmpeg.org/wiki/Encode/H.264 + #options={'b:a': '192000'}, 'maxrate': '192000', 'minrate': '192000'} + #The range of the CRF scale is 0–51, where 0 is lossless (for 8 bit only, for 10 bit use -qp 0), 23 is the default, and 51 is worst quality possible + #Compression level, lower = high quality + #See also: https://github.com/PyAV-Org/PyAV/blob/main/tests/test_encode.py + if self.quality == 1: + self.options['qmin'] = '8' + self.options['qmax'] = '41' + self.options['crf'] = '40' + elif self.quality == 2: + self.options['qmin'] = '2' + self.options['qmax'] = '31' + self.options['crf'] = '23' + elif self.quality == 3: + self.options['qmin'] = '1' + self.options['qmax'] = '4' + self.options['crf'] = '10' + + print(self.options) + self.container = av.open(self.filename, mode="w") + self.stream = self.container.add_stream(self.encoder, rate=self.framerate, options=self.options) + self.stream.width = self.resolution[0] + self.stream.height = self.resolution[1] + self.stream.pix_fmt = "yuv420p" + self.viewer.recording = self + + def frame(self): + """ + Write a frame, called when viewer.render() is called + while a recording is in progress + """ + img = self.viewer.rawimage(resolution=self.resolution, channels=3) + frame = av.VideoFrame.from_ndarray(img.data, format="rgb24") + for packet in self.stream.encode(frame): + self.container.mux(packet) def pause(self): """ Pause/resume recording, no rendered frames will be added to the video while paused """ - if self.encoder: - self.encoder.render = not self.encoder.render + if self.viewer.recording: + self.viewer.recording = None else: - self.viewer.app.pauseVideo() + self.viewer.recording = self def stop(self): """ Stop recording, final frames will be written and file closed, ready to play. No further frames will be added to the video """ - if self.encoder: - self.encoder.close() - self.filename = self.encoder.filename - else: - self.viewer.app.encodeVideo() - #Check if encoded video is a directory (not built with video encoding support) - #if so attempt to encode with ffmpeg - if os.path.isdir(self.filename): - log = "" - ffmpeg_exe = 'ffmpeg' - try: - outfn = '{0}.mp4'.format(self.filename) - cmd = ffmpeg_exe + ' -r {1} -i "{0}/frame_%05d.jpg" -c:v libx264 -vf fps={1} -movflags +faststart -pix_fmt yuv420p -y "{2}"'.format(self.filename, self.framerate, outfn) - log += "No built in video encoding, attempting to build movie from frames with ffmpeg:\n" - log += cmd - - import subprocess - #os.system(cmd) - subprocess.check_call(cmd, shell=True) - self.filename = outfn - except (Exception) as e: - print("Video encoding failed: ", str(e), "\nlog:\n", log) + # Flush stream + for packet in self.stream.encode(): + self.container.mux(packet) + # Close the file + self.container.close() + self.container = None + self.stream = None def write(self, image): """ - Add a frame to the video (when writing custom video frames rather than rendering them within lavavu) + Add a frame to the video Parameters ---------- @@ -5502,7 +5555,7 @@ def write(self, image): Pass a list or numpy uint8 array of rgba values or an Image object values are loaded as 8 bit unsigned integer values """ - if self.encoder: + if self.container: if isinstance(image, Image): image = image.data else: @@ -5510,13 +5563,18 @@ def write(self, image): if image.size == self.resolution[0] * self.resolution[1] * 4: image = image.reshape(self.resolution[0], self.resolution[1], 4) image = image[::,::,:3] #Remove alpha channel - self.encoder.copyframe(image.ravel()) + #self.encoder.copyframe(image.ravel()) + + frame = av.VideoFrame.from_ndarray(image, format="rgb24") + for packet in self.stream.encode(frame): + self.container.mux(packet) def play(self): """ Show the video in an inline player if in an interative notebook """ - player(self.filename, **self.kwargs) + print(self.player) + player(self.filename, **self.player) def __enter__(self): self.start() From 53c87d8ca286a8ef688bdd5be75385d00014ee8e Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 17:19:50 +1100 Subject: [PATCH 32/72] Clean up some multiline yaml --- .github/workflows/osmesa_deploy.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/osmesa_deploy.yaml b/.github/workflows/osmesa_deploy.yaml index 148d4850..963a41f7 100644 --- a/.github/workflows/osmesa_deploy.yaml +++ b/.github/workflows/osmesa_deploy.yaml @@ -16,8 +16,18 @@ jobs: CIBW_BUILD_VERBOSITY: 3 CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* - CIBW_ENVIRONMENT: LV_PACKAGE=lavavu-osmesa LV_OSMESA=1 LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include - CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} && sed -i 's/name = "lavavu"/name = "lavavu-osmesa"/g' {package}/pyproject.toml + CIBW_ENVIRONMENT: > + LV_PACKAGE=lavavu-osmesa + LV_OSMESA=1 + LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib + LV_INC_DIRS=${HOME}/include + CIBW_BEFORE_BUILD_LINUX: > + cd ~ && + curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && + unzip -o ffmpeg-mini.zip && + rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && + dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} && + sed -i 's/name = "lavavu"/name = "lavavu-osmesa"/g' {package}/pyproject.toml CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 strategy: matrix: From a4673fe3bdb0ecbd74fb2576841e21f33f89a646 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 17:20:11 +1100 Subject: [PATCH 33/72] Try building for all python versions again --- .github/workflows/macos_wheel_test.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 71fd3293..6396cd4e 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -9,8 +9,7 @@ jobs: runs-on: ${{ matrix.os }} env: CIBW_BUILD_VERBOSITY: 1 #3 - CIBW_BUILD: cp312-* cp313-* - #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* + CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* CIBW_ENVIRONMENT: > LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include From 01db8f85c79066faf504da24efdbd27eb827f378 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 24 Jan 2025 18:49:00 +1100 Subject: [PATCH 34/72] Set this var or render() will fail when no recording active --- lavavu/lavavu.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 029c6541..2fda15a1 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -2743,6 +2743,7 @@ def __init__(self, *args, resolution=None, binpath=None, context=None, port=8080 self._thread = None self._collections = {} self.validate = True #Property validation flag + self.recording = None #Exit handler to clean up threads #(__del__ does not always seem to get called on termination) From 86068c23002c64fa49fa063751783bce544a1ec4 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 31 Jan 2025 15:24:52 +1100 Subject: [PATCH 35/72] PyAV encoder setup improvements and fixes --- lavavu/lavavu.py | 68 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 2fda15a1..6e8fe332 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -5411,7 +5411,7 @@ class Video(object): """ The Video class provides an interface to record animations - This now uses pyav avoiding the need to build LavaVu with ffmpeg support + This now uses pyAV avoiding the need to build LavaVu with ffmpeg support Example ------- @@ -5461,7 +5461,7 @@ def __init__(self, viewer=None, filename="", resolution=(0,0), framerate=30, qua Any additional keyword args will also be passed as options to the encoder """ if av is None: - print("Video output not supported without pyAV - pip install pyav") + raise(ImportError("Video output not supported without pyAV - pip install av")) return self.resolution = resolution if self.resolution[0] == 0: @@ -5489,31 +5489,61 @@ def start(self): Start recording, all rendered frames will be added to the video """ #https://trac.ffmpeg.org/wiki/Encode/H.264 - #options={'b:a': '192000'}, 'maxrate': '192000', 'minrate': '192000'} - #The range of the CRF scale is 0–51, where 0 is lossless (for 8 bit only, for 10 bit use -qp 0), 23 is the default, and 51 is worst quality possible + # The range of the CRF scale is 0–51, where 0 is lossless (for 8 bit only, for 10 bit use -qp 0), + # 23 is the default, and 51 is worst quality possible #Compression level, lower = high quality #See also: https://github.com/PyAV-Org/PyAV/blob/main/tests/test_encode.py - if self.quality == 1: - self.options['qmin'] = '8' - self.options['qmax'] = '41' - self.options['crf'] = '40' - elif self.quality == 2: - self.options['qmin'] = '2' - self.options['qmax'] = '31' - self.options['crf'] = '23' - elif self.quality == 3: - self.options['qmin'] = '1' - self.options['qmax'] = '4' - self.options['crf'] = '10' - - print(self.options) + options = {} + if self.encoder == 'h264' or self.encoder == 'libx265': + #Only have default options for h264/265 for now + if self.quality == 1: + options['qmin'] = '30' #'20' #'8' + options['qmax'] = '35' #'41' + options['crf'] = '30' #'40' + elif self.quality == 2: + options['qmin'] = '25' #'2' + options['qmax'] = '30' #'31' + options['crf'] = '20' #'23' + elif self.quality == 3: + options['qmin'] = '20' #'1' + options['qmax'] = '25' #'4' + options['crf'] = '10' #'10' + + #Default preset, tune for h264 + options["preset"] = 'veryfast' #'veryfast' 'medium' 'slow' + options["tune"] = 'animation' #'film' + + #Settings from our original c++ encoder + #self.options['i_quant_factor'] = '0.71' + #self.options['qcompress'] = '0.6' + #self.options['max_qdiff'] = '4' + #self.options['refs'] = '3' + + #Merge user options, allowing override of above settings + options.update(self.options) + + #print(options) self.container = av.open(self.filename, mode="w") - self.stream = self.container.add_stream(self.encoder, rate=self.framerate, options=self.options) + self.stream = self.container.add_stream(self.encoder, rate=self.framerate, options=options) self.stream.width = self.resolution[0] self.stream.height = self.resolution[1] self.stream.pix_fmt = "yuv420p" self.viewer.recording = self + stream = self.stream + #print(stream) + #print(stream.codec) + #print(stream.codec_context) + #print(stream.profiles) + #print(stream.profile) + #print(stream.options) + #Need to set profile here or it isn't applied + #(Default to main) + stream.profile = 'Main' #Baseline / High + cc = stream.codec_context + #print(cc.options) + #print(cc.profile) + def frame(self): """ Write a frame, called when viewer.render() is called From f9dbd5f670ab66be02c37342aebdf3875384032e Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 31 Jan 2025 15:58:15 +1100 Subject: [PATCH 36/72] Update workflows, remove ffmpeg from wheel builds --- .github/workflows/macos_wheel_test.yaml | 3 +- .github/workflows/osmesa_deploy.yaml | 8 +++-- .github/workflows/wheel_deploy.yaml | 48 ++++++++++++------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml index 6396cd4e..da5f3bb6 100644 --- a/.github/workflows/macos_wheel_test.yaml +++ b/.github/workflows/macos_wheel_test.yaml @@ -1,7 +1,8 @@ name: WheelDeployTest on: - push + workflow_dispatch: + #push jobs: build_wheels: diff --git a/.github/workflows/osmesa_deploy.yaml b/.github/workflows/osmesa_deploy.yaml index 963a41f7..e406633d 100644 --- a/.github/workflows/osmesa_deploy.yaml +++ b/.github/workflows/osmesa_deploy.yaml @@ -4,9 +4,11 @@ on: workflow_dispatch: #push # Runs when a (published) GitHub Release is created - release: - types: - - published + # THIS IS DISABLED FOR NOW - IN FUTURE WILL PROVIDE LINUX EGL MESA VERSION WHICH + # SHOULD ALLOW OFFSCREEN SOFTWARE RENDERING VIA EGL, WHILST STILL SUPPORTING OTHER EGL CONTEXTS + #release: + # types: + # - published jobs: build_wheels: diff --git a/.github/workflows/wheel_deploy.yaml b/.github/workflows/wheel_deploy.yaml index b7a84c87..f6ebdc78 100644 --- a/.github/workflows/wheel_deploy.yaml +++ b/.github/workflows/wheel_deploy.yaml @@ -12,17 +12,28 @@ jobs: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} env: - CIBW_BUILD_VERBOSITY: 3 + CIBW_BUILD_VERBOSITY: 1 #3 CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 - CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* - #CIBW_TEST_COMMAND: python3 -m doctest -v lavavu/lavavu.py - CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} - CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include - CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y --nogpgcheck libtiff-devel + CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* + CIBW_ENVIRONMENT: > + LV_LIB_DIRS=${HOME}/lib + LV_INC_DIRS=${HOME}/include + LV_MIN_DEPS=1 CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_TEST_COMMAND: > + pip install moderngl && + git clone --depth 1 https://github.com/lavavu/Testing && + cd Testing && + export LV_CONTEXT=moderngl && + export LV_ECHO_FAIL=1 && + export LV_ARGS="-v" && + python runall.py + strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + # MacOS 13 runner is x86_64, 14 is arm64 + # (https://cibuildwheel.pypa.io/en/stable/faq/#how) + os: [ubuntu-latest, windows-latest, macos-13, macos-14] steps: - uses: actions/checkout@v4 @@ -30,15 +41,10 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.12' - - name: Setup ffmpeg (macOS only) - if: runner.os == 'macOS' - run: brew install ffmpeg@4 - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.21.2 + run: python -m pip install cibuildwheel==2.22.0 - name: Build wheels run: | @@ -58,7 +64,7 @@ jobs: - uses: actions/setup-python@v5 name: Install Python with: - python-version: '3.8' + python-version: '3.12' - name: Build sdist run: python setup.py sdist @@ -101,7 +107,7 @@ jobs: matrix: #os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ${{ matrix.os }} steps: - name: Set up Python @@ -116,14 +122,4 @@ jobs: run: python -c "import sys; print(sys.version)" - name: Install wheel run: python -m pip install --only-binary=lavavu lavavu - #- name: Run headless test (linux only) - #env: - # LV_ECHO_FAIL: "1" - # LV_ARGS: "-v" - #This needs to run with xvfb - #uses: GabrielBB/xvfb-action@v1 - #if: runner.os == 'Linux' - #with: - # working-directory: ./Testing - # run: python runall.py From 85f8d9f24a42bf0ed1cbc69b0b8c7813213b8f2e Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 31 Jan 2025 16:22:42 +1100 Subject: [PATCH 37/72] Add EGL test wheel build --- .github/workflows/egl_deploy.yaml | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/egl_deploy.yaml diff --git a/.github/workflows/egl_deploy.yaml b/.github/workflows/egl_deploy.yaml new file mode 100644 index 00000000..33f84df0 --- /dev/null +++ b/.github/workflows/egl_deploy.yaml @@ -0,0 +1,51 @@ +name: OSMesa + +on: + workflow_dispatch: + push + +jobs: + build_wheels: + name: Build lavavu-osmesa wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + env: + CIBW_BUILD_VERBOSITY: 3 + CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 + #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* + CIBW_BUILD: cp312-* + CIBW_ENVIRONMENT: > + LV_PACKAGE=lavavu-egl + LV_EGL=1 + LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib + LV_INC_DIRS=${HOME}/include + CIBW_BEFORE_BUILD_LINUX: > + cd ~ && + dnf install -y libtiff-devel mesa-libEGL-devel && echo {package} && + sed -i 's/name = "lavavu"/name = "lavavu-egl"/g' {package}/pyproject.toml + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + strategy: + matrix: + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel==2.22.0 + + - name: Build wheels + run: | + python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + From 99cba9d98d00003b0069011eb8cd3771b67f4cd1 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Fri, 31 Jan 2025 16:24:46 +1100 Subject: [PATCH 38/72] Fix --- .github/workflows/egl_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/egl_deploy.yaml b/.github/workflows/egl_deploy.yaml index 33f84df0..9e9274ab 100644 --- a/.github/workflows/egl_deploy.yaml +++ b/.github/workflows/egl_deploy.yaml @@ -2,7 +2,7 @@ name: OSMesa on: workflow_dispatch: - push + push: jobs: build_wheels: From 859f4b630a09f894f0306c7ccd21207a34b91116 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 12:16:23 +1100 Subject: [PATCH 39/72] Test new multiple build wheel for Linux --- .../workflows/{egl_deploy.yaml => new_deploy.yaml} | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) rename .github/workflows/{egl_deploy.yaml => new_deploy.yaml} (74%) diff --git a/.github/workflows/egl_deploy.yaml b/.github/workflows/new_deploy.yaml similarity index 74% rename from .github/workflows/egl_deploy.yaml rename to .github/workflows/new_deploy.yaml index 9e9274ab..a81377ce 100644 --- a/.github/workflows/egl_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -1,4 +1,4 @@ -name: OSMesa +name: Multi-build on: workflow_dispatch: @@ -6,22 +6,19 @@ on: jobs: build_wheels: - name: Build lavavu-osmesa wheels on ${{ matrix.os }} + name: Build lavavu wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} env: CIBW_BUILD_VERBOSITY: 3 - CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 + CIBW_SKIP: *-musllinux_* *-manylinux_i686 #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* CIBW_BUILD: cp312-* CIBW_ENVIRONMENT: > - LV_PACKAGE=lavavu-egl - LV_EGL=1 LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include CIBW_BEFORE_BUILD_LINUX: > - cd ~ && - dnf install -y libtiff-devel mesa-libEGL-devel && echo {package} && - sed -i 's/name = "lavavu"/name = "lavavu-egl"/g' {package}/pyproject.toml + rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && + dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} && CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 strategy: matrix: From 1e3c564f35f8fe664f3792fda3560c32d8786268 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 12:16:43 +1100 Subject: [PATCH 40/72] Setup osmesa submodule when building swig files --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index ad46c22e..159fdb26 100644 --- a/Makefile +++ b/Makefile @@ -171,6 +171,7 @@ $(OPATH)/compiler_flags: force | paths paths: @mkdir -p $(OPATH) @mkdir -p $(PREFIX) + @mkdir -p $(PREFIX)/osmesa @mkdir -p $(HTMLPATH) @mkdir -p $(PREFIX)/shaders @@ -256,6 +257,7 @@ endif .PHONY: swig swig : $(INC) src/LavaVuPython.i | paths swig -v -Wextra -python -py3 -ignoremissing -O -c++ -DSWIG_DO_NOT_WRAP -outdir $(PREFIX) src/LavaVuPython.i + cd $(PREFIX)/osmesa; ln -sf ../LavaVuPython.py; touch __init__.py $(SWIGLIB) : $(LIBRARY) $(SWIGOBJ) -rm -f $(PREFIX)/_LavaVuPython.* From 8f89a0f2c7ddc628b8e990463ea67105cc007c1e Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 12:17:45 +1100 Subject: [PATCH 41/72] Modified setup.py to build multiple modules on Linux Self-contained OSMesa module included in the wheel for fallback --- setup.py | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/setup.py b/setup.py index 37bc4633..a52b725c 100644 --- a/setup.py +++ b/setup.py @@ -252,6 +252,7 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]): ldflags = [] rt_lib_dirs = [] extra_objects = [] + extensions = [] try: import numpy except: @@ -375,18 +376,38 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]): if P == 'Linux': #Linux GLFW, X11, EGL or OSMesa - #To force EGL or OSMesa, set LV_EGL=1 or LV_OSMESA=1 - if ("LV_EGL" in os.environ and find_library('OpenGL') and find_library('EGL') - and check_libraries(['OpenGL', 'EGL'], ['GL/gl.h', 'EGL/egl.h'])): + #EGL and OSMesa are built as optional extra modules + ''' + if find_library('OpenGL') and find_library('EGL') and check_libraries(['OpenGL', 'EGL'], ['GL/gl.h', 'EGL/egl.h']): #EGL for offscreen OpenGL without X11/GLX - works only with NVidia currently - defines += [('HAVE_EGL', '1')] - libs += ['OpenGL', 'EGL'] - elif ("LV_OSMESA" in os.environ and find_library('OSMesa') - and check_libraries(['OSMesa'], ['GL/osmesa.h'])): - #OSMesa for software rendered offscreen OpenGL - defines += [('HAVE_OSMESA', '1')] - libs += ['OSMesa'] - elif ("LV_GLFW" in os.environ and find_library('glfw') + ex = Extension('lavavu.egl._LavaVuPython', + define_macros = defines + [('HAVE_EGL', '1')], + include_dirs = inc_dirs, + libraries = libs + ['OpenGL', 'EGL'], + library_dirs = lib_dirs, + runtime_library_dirs = rt_lib_dirs, + extra_compile_args = cflags, + extra_link_args = ldflags, + extra_objects=extra_objects, + sources = srcs) + extensions.append(ex) + '''; + if find_library('OSMesa') and check_libraries(['OSMesa'], ['GL/osmesa.h']): + #OSMesa for software rendered offscreen OpenGL, build as additional extension + ex = Extension('lavavu.osmesa._LavaVuPython', + define_macros = defines + [('HAVE_OSMESA', '1')], + include_dirs = inc_dirs, + libraries = libs + ['OSMesa'], + library_dirs = lib_dirs, + runtime_library_dirs = rt_lib_dirs, + extra_compile_args = cflags, + extra_link_args = ldflags, + extra_objects=extra_objects, + sources = srcs) + extensions.append(ex) + + #Main extension - use X11 or GLFW + if ("LV_GLFW" in os.environ and find_library('glfw') and check_libraries(['glfw'], ['GLFW/glfw3.h'])): #Use GLFW defines += [('HAVE_GLFW', '1')] @@ -434,6 +455,7 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]): extra_link_args = ldflags, extra_objects=extra_objects, sources = srcs) + extensions.append(lv) #Binary package data for wheels #Package_data works for wheels(binary) only - so add everything we need for the wheels here @@ -449,7 +471,7 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]): setup(name = dist_name, version = version, - ext_modules = [lv] + ext_modules = extensions ) From 07e2909602c9b8d5b5dd55dab93fa39db1008840 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 12:21:51 +1100 Subject: [PATCH 42/72] Detect supported viewer type on loading, or use LV_CONTEXT OSMesa build available, force use with LV_CONTEXT=osmesa If LV_CONTEXT set to a specific context, always use that - Default (X11) viewer used when DISPLAY is set - Next, will try moderngl EGL, which uses GPU if available for headless accelerated rendering - Finally use the OSMesa module for CPU rendering without external software or hardware dependencies Context in use can be checked with Viewer.context --- lavavu/lavavu.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 6e8fe332..c725ab28 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -52,6 +52,7 @@ import weakref import asyncio import quaternion as quat +import platform if sys.version_info[0] < 3: print("Python 3 required. LavaVu no longer supports Python 2.7.") @@ -81,7 +82,28 @@ av = None #import swig module -import LavaVuPython +if platform.system() == 'Linux': + #Default context requires DISPLAY set for X11 + context = os.environ.get("LV_CONTEXT", "default") + if context != 'default' or not 'DISPLAY' in os.environ or len(os.environ['DISPLAY'].strip()) == 0: + if context != 'osmesa': + try: + #Try EGL via moderngl, will use headless GPU if available + testctx = moderngl.create_context(standalone=True, require=330, backend='egl') + os.environ['LV_CONTEXT'] = context = 'moderngl' + except: + os.environ['LV_CONTEXT'] = context = 'osmesa' + + if context == 'osmesa': + #OSMesa fallback, CPU only, multicore + from lavavu.osmesa import LavaVuPython + +#Default module if none already loaded +try: + LavaVuPython +except: + import LavaVuPython + version = LavaVuPython.version server_ports = [] @@ -2328,7 +2350,6 @@ def _open(self): if _LavaVuWrapper._ctx: self.ctx = _LavaVuWrapper._ctx else: - import platform if platform.system() == 'Linux': self.ctx = moderngl.create_context(standalone=True, require=330, backend='egl') else: @@ -2708,7 +2729,7 @@ class Viewer(dict): """ - def __init__(self, *args, resolution=None, binpath=None, context=None, port=8080, threads=False, **kwargs): + def __init__(self, *args, resolution=None, binpath=None, context="default", port=8080, threads=False, **kwargs): """ Create and init viewer instance @@ -2724,6 +2745,7 @@ def __init__(self, *args, resolution=None, binpath=None, context=None, port=8080 context : str OpenGL context type, *"default"* will create a context and window based on available configurations. *"provided"* specifies a user provided context, set this if you have already created and activated the context. + *"osmesa"* if built with the osmesa module, will use the self-contained software renderer to render without a window or GPU, needs to be set in LV_CONTEXT to work *"moderngl"* creates a context in python using the moderngl module (experimental). *"moderngl."* creates a context and a window in python using the moderngl module (experimental) specify class after separator, eg: moderngl.headless, moderngl.pyglet, moderngl.pyqt5. port : int @@ -2744,6 +2766,7 @@ def __init__(self, *args, resolution=None, binpath=None, context=None, port=8080 self._collections = {} self.validate = True #Property validation flag self.recording = None + self.context = os.environ.get('LV_CONTEXT', context) #Exit handler to clean up threads #(__del__ does not always seem to get called on termination) From 02cba888462eb7cc6f2026d36a2854f0db93ffd6 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 12:26:31 +1100 Subject: [PATCH 43/72] Tweak workflow --- .github/workflows/new_deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index a81377ce..d5693fec 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -9,8 +9,8 @@ jobs: name: Build lavavu wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} env: - CIBW_BUILD_VERBOSITY: 3 - CIBW_SKIP: *-musllinux_* *-manylinux_i686 + CIBW_BUILD_VERBOSITY: 1 #3 + CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* CIBW_BUILD: cp312-* CIBW_ENVIRONMENT: > From e644f1bd01f937c86afd16806278598876a1fbfb Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 12:29:30 +1100 Subject: [PATCH 44/72] Remove hanging && --- .github/workflows/new_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index d5693fec..12d339d6 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -18,7 +18,7 @@ jobs: LV_INC_DIRS=${HOME}/include CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && - dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} && + dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 strategy: matrix: From d733cca2f4b36b40c7a5dd039b443a779d4890d4 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 13:12:27 +1100 Subject: [PATCH 45/72] Need these files checked in ...generated by "make swig" --- lavavu/osmesa/LavaVuPython.py | 1 + lavavu/osmesa/__init__.py | 0 2 files changed, 1 insertion(+) create mode 120000 lavavu/osmesa/LavaVuPython.py create mode 100644 lavavu/osmesa/__init__.py diff --git a/lavavu/osmesa/LavaVuPython.py b/lavavu/osmesa/LavaVuPython.py new file mode 120000 index 00000000..693e226d --- /dev/null +++ b/lavavu/osmesa/LavaVuPython.py @@ -0,0 +1 @@ +../LavaVuPython.py \ No newline at end of file diff --git a/lavavu/osmesa/__init__.py b/lavavu/osmesa/__init__.py new file mode 100644 index 00000000..e69de29b From 76f1636a78c7658d3d68a119ce32e863be3217be Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 13:42:01 +1100 Subject: [PATCH 46/72] Bug fix for moderngl context fallback --- lavavu/lavavu.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index c725ab28..31befe2e 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -90,9 +90,9 @@ try: #Try EGL via moderngl, will use headless GPU if available testctx = moderngl.create_context(standalone=True, require=330, backend='egl') - os.environ['LV_CONTEXT'] = context = 'moderngl' - except: - os.environ['LV_CONTEXT'] = context = 'osmesa' + context = 'moderngl' + except Exception as e: + context = 'osmesa' if context == 'osmesa': #OSMesa fallback, CPU only, multicore @@ -104,6 +104,8 @@ except: import LavaVuPython +os.environ['LV_CONTEXT'] = context + version = LavaVuPython.version server_ports = [] @@ -2354,6 +2356,7 @@ def _open(self): self.ctx = moderngl.create_context(standalone=True, require=330, backend='egl') else: self.ctx = moderngl.create_context(standalone=True, require=330) + #print(self.ctx.info) _LavaVuWrapper._ctx = self.ctx if self.use_moderngl_window and self.ctx: @@ -2807,7 +2810,7 @@ def exitfn(vref): if not binpath: binpath = os.path.abspath(os.path.dirname(__file__)) try: - self.app = _LavaVuWrapper(threads, self.args(*args, **kwargs), resolution, binpath, context) + self.app = _LavaVuWrapper(threads, self.args(*args, **kwargs), resolution, binpath, self.context) except (RuntimeError) as e: print("LavaVu Init error: " + str(e)) pass From c95a5da29c522ae783ee47d97569bd36eb1457d1 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 13:43:03 +1100 Subject: [PATCH 47/72] Update deployments to use multi-build wheel and run tests --- .github/workflows/new_deploy.yaml | 4 ++-- .github/workflows/wheel_deploy.yaml | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 12d339d6..adffdf80 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -16,6 +16,7 @@ jobs: CIBW_ENVIRONMENT: > LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include + LV_MIN_DEPS=1 CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} @@ -33,8 +34,7 @@ jobs: python-version: '3.12' - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.22.0 + run: python -m pip install cibuildwheel==2.22.0 - name: Build wheels run: | diff --git a/.github/workflows/wheel_deploy.yaml b/.github/workflows/wheel_deploy.yaml index f6ebdc78..3da46460 100644 --- a/.github/workflows/wheel_deploy.yaml +++ b/.github/workflows/wheel_deploy.yaml @@ -16,9 +16,12 @@ jobs: CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* CIBW_ENVIRONMENT: > - LV_LIB_DIRS=${HOME}/lib + LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include LV_MIN_DEPS=1 + CIBW_BEFORE_BUILD_LINUX: > + rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && + dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND: > pip install moderngl && @@ -106,7 +109,7 @@ jobs: strategy: matrix: #os: [ubuntu-latest, macos-latest, windows-latest] - os: [ubuntu-latest] + os: [ubuntu-latest, macos-13, macos-14] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ${{ matrix.os }} steps: @@ -122,4 +125,13 @@ jobs: run: python -c "import sys; print(sys.version)" - name: Install wheel run: python -m pip install --only-binary=lavavu lavavu + - name: Run tests + run: > + pip install moderngl && + git clone --depth 1 https://github.com/lavavu/Testing && + cd Testing && + export LV_CONTEXT=moderngl && + export LV_ECHO_FAIL=1 && + export LV_ARGS="-v" && + python runall.py From 7e9389e7432ceb0ce8fd3280912905ccdb8b73c0 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 14:03:18 +1100 Subject: [PATCH 48/72] Fix env var checks, treat empty string as missing or default --- lavavu/lavavu.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index 31befe2e..a3a4b398 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -84,8 +84,10 @@ #import swig module if platform.system() == 'Linux': #Default context requires DISPLAY set for X11 - context = os.environ.get("LV_CONTEXT", "default") - if context != 'default' or not 'DISPLAY' in os.environ or len(os.environ['DISPLAY'].strip()) == 0: + context = os.environ.get("LV_CONTEXT", "").strip() + display = os.environ.get("DISPLAY", "").strip() + if len(context) == 0: context = 'default' + if context != 'default' or len(display) == 0: if context != 'osmesa': try: #Try EGL via moderngl, will use headless GPU if available From 5f15ab50bb1656e98d928c8dbca75a66694e684d Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 14:05:12 +1100 Subject: [PATCH 49/72] Test full set of wheel builds --- .github/workflows/new_deploy.yaml | 39 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index adffdf80..3fc6f5e2 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -6,24 +6,34 @@ on: jobs: build_wheels: - name: Build lavavu wheels on ${{ matrix.os }} + name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} env: CIBW_BUILD_VERBOSITY: 1 #3 CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 - #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* - CIBW_BUILD: cp312-* + CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* CIBW_ENVIRONMENT: > - LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib + LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include LV_MIN_DEPS=1 CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_TEST_COMMAND: > + pip install moderngl && + git clone --depth 1 https://github.com/lavavu/Testing && + cd Testing && + export LV_CONTEXT=moderngl && + export LV_ECHO_FAIL=1 && + export LV_ARGS="-v" && + python runall.py + strategy: matrix: - os: [ubuntu-latest] + # MacOS 13 runner is x86_64, 14 is arm64 + # (https://cibuildwheel.pypa.io/en/stable/faq/#how) + os: [ubuntu-latest, windows-latest, macos-13, macos-14] steps: - uses: actions/checkout@v4 @@ -45,4 +55,23 @@ jobs: name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: '3.12' + + - name: Build sdist + run: python setup.py sdist + + - uses: actions/upload-artifact@v4 + with: + name: sdist-${{ strategy.job-index }} + path: dist/*.tar.gz + From 76e45b3d2cd9e212251058275b2d34a18628bcfb Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 14:17:39 +1100 Subject: [PATCH 50/72] Bug fix --- lavavu/lavavu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index a3a4b398..dc4a220c 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -82,9 +82,9 @@ av = None #import swig module +context = os.environ.get("LV_CONTEXT", "").strip() if platform.system() == 'Linux': #Default context requires DISPLAY set for X11 - context = os.environ.get("LV_CONTEXT", "").strip() display = os.environ.get("DISPLAY", "").strip() if len(context) == 0: context = 'default' if context != 'default' or len(display) == 0: From 9bff2b024f2b01a5cf61ffcd2ff54baaeb27dc51 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 14:42:36 +1100 Subject: [PATCH 51/72] Try python 3.8 for sdist fail --- .github/workflows/new_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 3fc6f5e2..1598dcef 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -64,7 +64,7 @@ jobs: - uses: actions/setup-python@v5 name: Install Python with: - python-version: '3.12' + python-version: '3.8' - name: Build sdist run: python setup.py sdist From d2c857a3aa092421cfdb4872b69dcbea753b8b52 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:01:11 +1100 Subject: [PATCH 52/72] Add build to build deps --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index cfb787ff..1573ff18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,7 @@ lavavu = ['font.bin', 'dict.json', 'shaders/*', 'html/*', '*.dll'] build-backend = "setuptools.build_meta" requires = [ "wheel", + "build", "setuptools>=61.2", "packaging", "numpy==1.13.3; python_version=='3.6'", From 015e01cbc05020df0d7dd777d88757ce1a2c88a3 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:02:28 +1100 Subject: [PATCH 53/72] See if we can use modern way to build sdist --- .github/workflows/new_deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 1598dcef..60b64c7b 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -64,10 +64,10 @@ jobs: - uses: actions/setup-python@v5 name: Install Python with: - python-version: '3.8' + python-version: '3.12' - name: Build sdist - run: python setup.py sdist + run: python -m build . --sdist - uses: actions/upload-artifact@v4 with: From 15e5b84781b09119d84364c83130ed6f04e3df04 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:03:02 +1100 Subject: [PATCH 54/72] Tweak tests to run on windows (doctest only) Will exit in test runner before running image tests --- .github/workflows/new_deploy.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 60b64c7b..9373b2b8 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -16,6 +16,9 @@ jobs: LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include LV_MIN_DEPS=1 + LV_CONTEXT=moderngl + LV_ECHO_FAIL=1 + LV_ARGS="-v" CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} @@ -24,9 +27,6 @@ jobs: pip install moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && - export LV_CONTEXT=moderngl && - export LV_ECHO_FAIL=1 && - export LV_ARGS="-v" && python runall.py strategy: From 1f77af0e7943f27a4fbeab4c69a5e3e87ac2f0f6 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:10:41 +1100 Subject: [PATCH 55/72] Install build deps --- .github/workflows/new_deploy.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 9373b2b8..67e653ee 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -66,6 +66,9 @@ jobs: with: python-version: '3.12' + - name: Install build + run: python -m pip install setuptools build + - name: Build sdist run: python -m build . --sdist From 2f1a4da741b57c537551ae39a72291a0144df069 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:10:50 +1100 Subject: [PATCH 56/72] Missing numpy on windows, try this --- .github/workflows/new_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 67e653ee..9fe0e98b 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -24,7 +24,7 @@ jobs: dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND: > - pip install moderngl && + pip install moderngl numpy && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && python runall.py From 498684954d5b17c0dd1289af877d6f7d5c0aaf83 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:16:51 +1100 Subject: [PATCH 57/72] Skip sqlite3 build for sdist --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a52b725c..cf343aa7 100644 --- a/setup.py +++ b/setup.py @@ -336,7 +336,11 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]): #Build sqlite3 #Don't compile when just running 'setup.py egg_info' sqlite3 = 'build/src/sqlite3/sqlite3.o' - if len(sys.argv) < 2 or sys.argv[1] == 'egg_info' or os.path.exists(sqlite3): + if (len(sys.argv) < 2 or + sys.argv[1] == 'egg_info' or + sys.argv[1] == 'sdist' or + os.path.exists(sqlite3) + ): pass else: #sqlite3 = build_sqlite3(sqlite3_path) From efed2c483e4f8e754dccc2f37355559085ba7def Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:19:27 +1100 Subject: [PATCH 58/72] Still getting no module named numpy on windows --- .github/workflows/new_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 9fe0e98b..fd319584 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -24,7 +24,7 @@ jobs: dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND: > - pip install moderngl numpy && + python -m pip install --user moderngl numpy && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && python runall.py From a795d1af25493b6d39356b82ef6f6c50d2d9e55b Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:26:34 +1100 Subject: [PATCH 59/72] Numpy still broken on windows, too bad Simply don't care enough about windows build to fix this now --- .github/workflows/new_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index fd319584..9139cfbf 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -24,7 +24,7 @@ jobs: dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND: > - python -m pip install --user moderngl numpy && + python -m pip install moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && python runall.py From a54bb0f3b9a7d35eb0e7798aca3aedf1cc784dfe Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 15:44:58 +1100 Subject: [PATCH 60/72] Fix this import, fails in doctest --- lavavu/lavavu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lavavu/lavavu.py b/lavavu/lavavu.py index dc4a220c..00952f01 100644 --- a/lavavu/lavavu.py +++ b/lavavu/lavavu.py @@ -98,7 +98,7 @@ if context == 'osmesa': #OSMesa fallback, CPU only, multicore - from lavavu.osmesa import LavaVuPython + from osmesa import LavaVuPython #Default module if none already loaded try: From ed78f2db157f45dfb34ed6cedd65d45fc6069342 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 16:21:06 +1100 Subject: [PATCH 61/72] Remove test/old workflows, move deploy changes to wheel_deploy --- .github/workflows/macos_wheel_test.yaml | 59 ----------- .github/workflows/new_deploy.yaml | 2 +- .github/workflows/osmesa_deploy.yaml | 128 ------------------------ .github/workflows/wheel_deploy.yaml | 13 ++- 4 files changed, 9 insertions(+), 193 deletions(-) delete mode 100644 .github/workflows/macos_wheel_test.yaml delete mode 100644 .github/workflows/osmesa_deploy.yaml diff --git a/.github/workflows/macos_wheel_test.yaml b/.github/workflows/macos_wheel_test.yaml deleted file mode 100644 index da5f3bb6..00000000 --- a/.github/workflows/macos_wheel_test.yaml +++ /dev/null @@ -1,59 +0,0 @@ -name: WheelDeployTest - -on: - workflow_dispatch: - #push - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - env: - CIBW_BUILD_VERBOSITY: 1 #3 - CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* - CIBW_ENVIRONMENT: > - LV_LIB_DIRS=${HOME}/lib - LV_INC_DIRS=${HOME}/include - LV_MIN_DEPS=1 - CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_TEST_COMMAND: > - pip install moderngl && - git clone --depth 1 https://github.com/lavavu/Testing && - cd Testing && - export LV_CONTEXT=moderngl && - export LV_ECHO_FAIL=1 && - export LV_ARGS="-v" && - python runall.py - - strategy: - matrix: - # MacOS 13 runner is x86_64, 14 is arm64 - # (https://cibuildwheel.pypa.io/en/stable/faq/#how) - os: [macos-13, macos-14] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.22.0 - - # https://github.com/pypa/cibuildwheel/issues/563 - #- name: Set macOS deployment target - # if: runner.os == 'macOS' - # run: echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV - - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse - - - uses: actions/upload-artifact@v4 - with: - name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} - path: ./wheelhouse/*.whl - - diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 9139cfbf..d7e51441 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -2,7 +2,7 @@ name: Multi-build on: workflow_dispatch: - push: + #push: jobs: build_wheels: diff --git a/.github/workflows/osmesa_deploy.yaml b/.github/workflows/osmesa_deploy.yaml deleted file mode 100644 index e406633d..00000000 --- a/.github/workflows/osmesa_deploy.yaml +++ /dev/null @@ -1,128 +0,0 @@ -name: OSMesa - -on: - workflow_dispatch: - #push - # Runs when a (published) GitHub Release is created - # THIS IS DISABLED FOR NOW - IN FUTURE WILL PROVIDE LINUX EGL MESA VERSION WHICH - # SHOULD ALLOW OFFSCREEN SOFTWARE RENDERING VIA EGL, WHILST STILL SUPPORTING OTHER EGL CONTEXTS - #release: - # types: - # - published - -jobs: - build_wheels: - name: Build lavavu-osmesa wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - env: - CIBW_BUILD_VERBOSITY: 3 - CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 - CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* - CIBW_ENVIRONMENT: > - LV_PACKAGE=lavavu-osmesa - LV_OSMESA=1 - LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib - LV_INC_DIRS=${HOME}/include - CIBW_BEFORE_BUILD_LINUX: > - cd ~ && - curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && - unzip -o ffmpeg-mini.zip && - rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && - dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} && - sed -i 's/name = "lavavu"/name = "lavavu-osmesa"/g' {package}/pyproject.toml - CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - strategy: - matrix: - os: [ubuntu-latest] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.21.2 - - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse - - - uses: actions/upload-artifact@v4 - with: - name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} - path: ./wheelhouse/*.whl - - upload_pypi: - needs: [build_wheels] - name: Upload release to PyPI - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/lavavu-osmesa - permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing - steps: - - name: Retrieve wheels - uses: actions/download-artifact@v4 - with: - pattern: cibw-wheels* - path: dist - merge-multiple: true - - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - #Uncomment to use testing repo - #with: - # repository-url: https://test.pypi.org/legacy/ - - deploy_docker: - needs: [upload_pypi] #Requires lavavu-osmesa package to be uploaded - name: Build and push Docker image to GitHub Packages - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: Add SHORT_SHA env property with commit short sha - run: echo "SHORT_SHA=`git rev-parse --short HEAD`" >> $GITHUB_ENV - - - name: Docker meta - id: meta - uses: docker/metadata-action@v3 - with: - # list of Docker images to use as base name for tags - images: | - ghcr.io/lavavu/lavavu - # generate Docker tags based on the following events/attributes - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Push to GitHub Packages - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: | - ghcr.io/lavavu/lavavu:latest - ${{ steps.meta.outputs.tags }} - diff --git a/.github/workflows/wheel_deploy.yaml b/.github/workflows/wheel_deploy.yaml index 3da46460..a90773f8 100644 --- a/.github/workflows/wheel_deploy.yaml +++ b/.github/workflows/wheel_deploy.yaml @@ -19,17 +19,17 @@ jobs: LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include LV_MIN_DEPS=1 + LV_CONTEXT=moderngl + LV_ECHO_FAIL=1 + LV_ARGS="-v" CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND: > - pip install moderngl && + python -m pip install moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && - export LV_CONTEXT=moderngl && - export LV_ECHO_FAIL=1 && - export LV_ARGS="-v" && python runall.py strategy: @@ -69,8 +69,11 @@ jobs: with: python-version: '3.12' + - name: Install build + run: python -m pip install setuptools build + - name: Build sdist - run: python setup.py sdist + run: python -m build . --sdist - uses: actions/upload-artifact@v4 with: From e4a5ad6a0aef4059be131361d562cf2d9244b3fe Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 18:21:56 +1100 Subject: [PATCH 62/72] Linux tests freeze on image output, try the osmesa context --- .github/workflows/new_deploy.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index d7e51441..e0b1aee1 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -2,7 +2,7 @@ name: Multi-build on: workflow_dispatch: - #push: + push: jobs: build_wheels: @@ -16,9 +16,12 @@ jobs: LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include LV_MIN_DEPS=1 - LV_CONTEXT=moderngl LV_ECHO_FAIL=1 LV_ARGS="-v" + CIBW_ENVIRONMENT_LINUX: > + LV_CONTEXT=osmesa + CIBW_ENVIRONMENT_MACOS: > + LV_CONTEXT=moderngl CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} From 0fcec87e106be0da49e5e7ce5f227492a6c1604e Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 18:42:05 +1100 Subject: [PATCH 63/72] Seems os specific env excludes default env --- .github/workflows/new_deploy.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index e0b1aee1..4acc019a 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -18,16 +18,14 @@ jobs: LV_MIN_DEPS=1 LV_ECHO_FAIL=1 LV_ARGS="-v" - CIBW_ENVIRONMENT_LINUX: > - LV_CONTEXT=osmesa - CIBW_ENVIRONMENT_MACOS: > LV_CONTEXT=moderngl + CIBW_BEFORE_BUILD_MACOS: > + python -m pip install moderngl CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_TEST_COMMAND: > - python -m pip install moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && python runall.py From 9a5c4ea8a3071b2f16d2458e3d70c58f4e053134 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 19:49:03 +1100 Subject: [PATCH 64/72] Try this way --- .github/workflows/new_deploy.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 4acc019a..6211d537 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -18,17 +18,21 @@ jobs: LV_MIN_DEPS=1 LV_ECHO_FAIL=1 LV_ARGS="-v" - LV_CONTEXT=moderngl - CIBW_BEFORE_BUILD_MACOS: > - python -m pip install moderngl CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_TEST_COMMAND: > + CIBW_TEST_COMMAND_MAXOS: > + python -m pip install moderngl && + export LV_CONTEXT=moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && python runall.py + CIBW_TEST_COMMAND_LINUX: > + export LV_CONTEXT=osmesa && + git clone --depth 1 https://github.com/lavavu/Testing && + cd Testing && + python runall.p strategy: matrix: From 482690320d7bd2168e401c792c9fb2790697cb0a Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 19:58:42 +1100 Subject: [PATCH 65/72] Seriously? --- .github/workflows/new_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 6211d537..93d0d213 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -32,7 +32,7 @@ jobs: export LV_CONTEXT=osmesa && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && - python runall.p + python runall.py strategy: matrix: From cf29e95c81d9d50914a405202fcec705bb3a3264 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 20:13:10 +1100 Subject: [PATCH 66/72] Disable test and just build 3.8 wheel so cna download nd test --- .github/workflows/new_deploy.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 93d0d213..0320075b 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -11,7 +11,8 @@ jobs: env: CIBW_BUILD_VERBOSITY: 1 #3 CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 - CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* + CIBW_BUILD: cp38-* + #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* CIBW_ENVIRONMENT: > LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include @@ -22,17 +23,17 @@ jobs: rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_TEST_COMMAND_MAXOS: > + CIBW_TEST_COMMAND_MACOS: > python -m pip install moderngl && export LV_CONTEXT=moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && python runall.py - CIBW_TEST_COMMAND_LINUX: > - export LV_CONTEXT=osmesa && - git clone --depth 1 https://github.com/lavavu/Testing && - cd Testing && - python runall.py + #CIBW_TEST_COMMAND_LINUX: > + # export LV_CONTEXT=osmesa && + # git clone --depth 1 https://github.com/lavavu/Testing && + # cd Testing && + # python runall.py strategy: matrix: From ce7ce1a20dab179554a2bfe895862ff738addb10 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 20:49:17 +1100 Subject: [PATCH 67/72] Update wheel_deploy --- .github/workflows/wheel_deploy.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheel_deploy.yaml b/.github/workflows/wheel_deploy.yaml index a90773f8..7abf5a9d 100644 --- a/.github/workflows/wheel_deploy.yaml +++ b/.github/workflows/wheel_deploy.yaml @@ -19,18 +19,23 @@ jobs: LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include LV_MIN_DEPS=1 - LV_CONTEXT=moderngl LV_ECHO_FAIL=1 LV_ARGS="-v" CIBW_BEFORE_BUILD_LINUX: > rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux && dnf install -y libtiff-devel mesa-libOSMesa-devel && echo {package} CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_TEST_COMMAND: > + CIBW_TEST_COMMAND_MACOS: > python -m pip install moderngl && + export LV_CONTEXT=moderngl && git clone --depth 1 https://github.com/lavavu/Testing && cd Testing && python runall.py + #CIBW_TEST_COMMAND_LINUX: > + # export LV_CONTEXT=osmesa && + # git clone --depth 1 https://github.com/lavavu/Testing && + # cd Testing && + # python runall.py strategy: matrix: From 3a79ff4678f91babac352b12ec0fb8436865eea2 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 20:49:44 +1100 Subject: [PATCH 68/72] Update testing --- .github/workflows/testing.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 4abe457d..e1500eea 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -12,8 +12,8 @@ jobs: strategy: matrix: #os: [ubuntu-latest, macos-latest, windows-latest] - os: [ubuntu-latest] #, macos-latest] #Re-enable this at some point after duplicating the problem on 3.9+ (seems to attempt to install itself as a dependency and fails) - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + os: [ubuntu-latest, macos-latest] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -24,7 +24,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" - - name: Set up *nix dependencies + - name: Set up linux dependencies if: runner.os == 'Linux' run: | sudo apt-get update @@ -32,14 +32,16 @@ jobs: - name: Install prereqs run: python -m pip install -r requirements.txt - name: Build/install - run: LV_OSMESA=1 python -m pip install . + run: python -m pip install . - name: Run headless test (linux only) - if: runner.os == 'Linux' + env: + LV_CONTEXT: moderngl + LV_ECHO_FAIL: 1 + LV_ARGS: -v run: | + python -m pip install moderngl git clone --depth 1 https://github.com/lavavu/Testing cd Testing - export LV_ECHO_FAIL=1 - export LV_ARGS="-v" python runall.py cd .. From 77136152d0a082659b4f70446e309f5e691342b3 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 21:02:42 +1100 Subject: [PATCH 69/72] Test build 3.12 --- .github/workflows/new_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/new_deploy.yaml index 0320075b..be081ff0 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/new_deploy.yaml @@ -11,7 +11,7 @@ jobs: env: CIBW_BUILD_VERBOSITY: 1 #3 CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686 - CIBW_BUILD: cp38-* + CIBW_BUILD: cp312-* #CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* CIBW_ENVIRONMENT: > LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib From 02247014ad53c8e547ecf6ab70cace5129e47a0e Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 21:23:49 +1100 Subject: [PATCH 70/72] Rename test deploy --- .github/workflows/{new_deploy.yaml => test_deploy.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{new_deploy.yaml => test_deploy.yaml} (98%) diff --git a/.github/workflows/new_deploy.yaml b/.github/workflows/test_deploy.yaml similarity index 98% rename from .github/workflows/new_deploy.yaml rename to .github/workflows/test_deploy.yaml index be081ff0..0d4694de 100644 --- a/.github/workflows/new_deploy.yaml +++ b/.github/workflows/test_deploy.yaml @@ -6,7 +6,7 @@ on: jobs: build_wheels: - name: Build wheels on ${{ matrix.os }} + name: Build test wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} env: CIBW_BUILD_VERBOSITY: 1 #3 From 621ba089075849897ae4b5b2b9b03bed8fdfa6a2 Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 21:24:04 +1100 Subject: [PATCH 71/72] Disable auto run --- .github/workflows/test_deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_deploy.yaml b/.github/workflows/test_deploy.yaml index 0d4694de..a8af7ce4 100644 --- a/.github/workflows/test_deploy.yaml +++ b/.github/workflows/test_deploy.yaml @@ -1,8 +1,8 @@ -name: Multi-build +name: Wheel-build-test on: workflow_dispatch: - push: + #push: jobs: build_wheels: From c5df03c2f6aef7f5b9a06a8c6cbe1bd6a876c54c Mon Sep 17 00:00:00 2001 From: Owen Kaluza Date: Tue, 4 Feb 2025 21:24:12 +1100 Subject: [PATCH 72/72] Rename job --- .github/workflows/testing.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index e1500eea..77643279 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -33,7 +33,7 @@ jobs: run: python -m pip install -r requirements.txt - name: Build/install run: python -m pip install . - - name: Run headless test (linux only) + - name: Run headless test env: LV_CONTEXT: moderngl LV_ECHO_FAIL: 1