From 485f1c7cfb85d8a26e8ba01686546abb40e6b500 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:16:49 -0400 Subject: [PATCH 01/11] build : Add `postBuildMoves` This optional configuration item will move a given set of files after the `commands` step. It is useful for unifying the Linux and Windows configurations, particularly when it comes to moving directories and creating destination directories. --- Changes.md | 1 + build.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Changes.md b/Changes.md index 98a8bee976..1690eb2172 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,7 @@ 11.x.x (relative to 11.0.0a4) ------ +- build.py : Added `postBuildCopy` and `postBuildMove` configuration steps. 11.0.0a4 (relative to 11.0.0a3) diff --git a/build.py b/build.py index 0ec0bbffd4..5875a2f8d4 100755 --- a/build.py +++ b/build.py @@ -8,6 +8,7 @@ import os import operator import multiprocessing +import pathlib import subprocess import shutil import sys @@ -39,6 +40,13 @@ - enabled : May be set to `False` to disable a project entirely. This is only expected to be useful in conjunction with platform overrides or variants. +- postBuildCopy / postBuildMove : List of copy / move directives, each + of the form ( sourceRoot, globPattern, destinationRoot ) + specifying paths that should be copied / moved after all `commands` + have run. Files in `sourceRoot` that match `globPattern` (including + the recursive `**` pattern) are copied / moved, with their path relative + to `sourceRoot`, to `destinationRoot`. Destination directories will be + created if necessary. ### Packaging @@ -188,6 +196,8 @@ def __updateDigest( project, config ) : __appendHash( config["digest"], config.get( "environment" ) ) __appendHash( config["digest"], config.get( "commands" ) ) __appendHash( config["digest"], config.get( "symbolicLinks" ) ) + __appendHash( config["digest"], config.get( "postBuildCopy" ) ) + __appendHash( config["digest"], config.get( "postBuildMove" ) ) for e in config.get( "requiredEnvironment", [] ) : __appendHash( config["digest"], os.environ.get( e, "" ) ) @@ -316,6 +326,19 @@ def __buildProject( project, config, buildDir, cleanup ) : sys.stderr.write( command + "\n" ) subprocess.check_call( command, shell = True, env = environment ) + for operation in [ "postBuildCopy", "postBuildMove" ] : + for sourceRoot, pattern, destinationRoot in config.get( operation, () ) : + sourceRoot = pathlib.Path( sourceRoot or "." ) + destinationRoot = pathlib.Path( destinationRoot ) + + for p in sourceRoot.glob( pattern ) : + destinationPath = destinationRoot / p.relative_to( sourceRoot ) + destinationPath.parent.mkdir( parents = True, exist_ok = True ) + if operation == "postBuildCopy" : + shutil.copy( p, destinationPath ) + else : + p.replace( destinationPath ) + for link in config.get( "symbolicLinks", [] ) : sys.stderr.write( "Linking {} to {}\n".format( link[0], link[1] ) ) if os.path.lexists( link[0] ) : From 7a5c51e75b6aa4301682c2b121867e30f21768da Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:22:07 -0400 Subject: [PATCH 02/11] BitstreamVera : Use `postBuildMoves` --- .github/workflows/main.yml | 2 +- BitstreamVera/config.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c1dd49aa3..14c6ed8cc4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: jobs: 4 containerImage: # Something simple to start. When ready, the projects below should be included in the first job. - projectsString: --projects GafferResources + projectsString: --projects GafferResources BitstreamVera # projectsString: --projects LibFFI TBB Python ZLib Boost Imath OpenEXR HDF5 Alembic BitstreamVera Blosc CMark PyBind11 LibJPEG-Turbo LibTIFF LibPNG OpenJPEG Expat YAML-CPP PyString Minizip OpenColorIO LibRaw PugiXML Fmt LibWebP FreeType OpenImageIO LLVM OpenShadingLanguage GLEW OpenVDB OpenSubdiv PyOpenGL Qt PySide uses: ./.github/workflows/buildDependencyBatch.yml diff --git a/BitstreamVera/config.py b/BitstreamVera/config.py index f4a7f141aa..15bfe0719e 100644 --- a/BitstreamVera/config.py +++ b/BitstreamVera/config.py @@ -10,10 +10,11 @@ "license" : "COPYRIGHT.TXT", - "commands" : [ + "commands" : [], - "mkdir -p {buildDir}/fonts", - "cp *.ttf {buildDir}/fonts" + "postBuildCopy" : [ + + ( None, "*.ttf", "{buildDir}/fonts" ), ], From 7e58dabc800d0f9eca8a080b3e2cfc5b5605ad34 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:33:51 -0400 Subject: [PATCH 03/11] OpenColorIO : Use `postBuildMoves` --- OpenColorIO/config.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/OpenColorIO/config.py b/OpenColorIO/config.py index eaeef69ac8..ba53809193 100644 --- a/OpenColorIO/config.py +++ b/OpenColorIO/config.py @@ -43,12 +43,19 @@ "cd build && make clean && make VERBOSE=1 -j {jobs} && make install", - "mkdir -p {buildDir}/python", - "mv {buildDir}/lib*/python*/site-packages/PyOpenColorIO* {buildDir}/python", + ], + + "postBuildCopy" : [ + + + ( "..", "studio-config-v3.0.0_aces-v2.0_ocio-v2.4.ocio", "{buildDir}/openColorIO" ), + ( "..", "cg-config-v3.0.0_aces-v2.0_ocio-v2.4.ocio", "{buildDir}/openColorIO" ), + + ], + + "postBuildMove" : [ - "mkdir -p {buildDir}/openColorIO", - "cp ../studio-config-v3.0.0_aces-v2.0_ocio-v2.4.ocio {buildDir}/openColorIO", - "cp ../cg-config-v3.0.0_aces-v2.0_ocio-v2.4.ocio {buildDir}/openColorIO", + ( "{buildDir}/lib/python{pythonVersion}/site-packages", "PyOpenColorIO*/**/*", "{buildDir}/python" ), ], From e530dec0430534a902074f97a7e480d77817291e Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:40:51 -0400 Subject: [PATCH 04/11] OpenShadingLanguage : Use `postBuildMoves` --- OpenShadingLanguage/config.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenShadingLanguage/config.py b/OpenShadingLanguage/config.py index 26132a6772..80b9e79399 100644 --- a/OpenShadingLanguage/config.py +++ b/OpenShadingLanguage/config.py @@ -45,14 +45,12 @@ " {extraArguments}" " ..", "cd gafferBuild && make install -j {jobs} VERBOSE=1", - "{extraCommands}", ], "variables" : { "extraArguments" : "", - "extraCommands" : "", "useBatched" : "b8_AVX,b8_AVX2,b8_AVX2_noFMA,b8_AVX512,b8_AVX512_noFMA,b16_AVX512,b16_AVX512_noFMA", }, @@ -81,9 +79,14 @@ "platform:macos" : { + "postBuildMove" : [ + + ( "{buildDir}/lib/python{pythonVersion}/site-packages", "oslquery", "{pythonLibDir}/python{pythonVersion}/site-packages" ), + + ], + "variables" : { - "extraCommands" : "mv {buildDir}/lib/python{pythonVersion}/site-packages/oslquery {pythonLibDir}/python{pythonVersion}/site-packages/oslquery", "useBatched" : "0", }, From 8ac44c37f96fd359382ff3e2f7dc3f538bb061eb Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:41:25 -0400 Subject: [PATCH 05/11] PCG : Use `postBuildMoves` --- .github/workflows/main.yml | 2 +- PCG/config.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14c6ed8cc4..980a6e7281 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: jobs: 4 containerImage: # Something simple to start. When ready, the projects below should be included in the first job. - projectsString: --projects GafferResources BitstreamVera + projectsString: --projects GafferResources BitstreamVera PCG # projectsString: --projects LibFFI TBB Python ZLib Boost Imath OpenEXR HDF5 Alembic BitstreamVera Blosc CMark PyBind11 LibJPEG-Turbo LibTIFF LibPNG OpenJPEG Expat YAML-CPP PyString Minizip OpenColorIO LibRaw PugiXML Fmt LibWebP FreeType OpenImageIO LLVM OpenShadingLanguage GLEW OpenVDB OpenSubdiv PyOpenGL Qt PySide uses: ./.github/workflows/buildDependencyBatch.yml diff --git a/PCG/config.py b/PCG/config.py index 97a7fb671e..68dfe0c450 100644 --- a/PCG/config.py +++ b/PCG/config.py @@ -10,10 +10,11 @@ "license" : "LICENSE-MIT.txt", + "commands" : [], - "commands" : [ - "mkdir -p {buildDir}/include/pcg", - "cp include/*.hpp {buildDir}/include/pcg", + "postBuildCopy" : [ + + ( "include", "*.hpp", "{buildDir}/include/pcg" ), ], From f500164623f0378b0b4f6b956a9b39b2a89f4977 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:41:50 -0400 Subject: [PATCH 06/11] PyString : Use `postBuildMoves` --- PyString/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PyString/config.py b/PyString/config.py index f933353f67..006c196acc 100644 --- a/PyString/config.py +++ b/PyString/config.py @@ -20,7 +20,12 @@ " -D BUILD_SHARED_LIBS=ON" " ..", "cd build && make -j {jobs} && make install", - "mkdir -p {buildDir}/include/pystring && cp pystring.h {buildDir}/include/pystring", + + ], + + "postBuildCopy" : [ + + ( None, "pystring.h", "{buildDir}/include/pystring" ), ], From c45218aa4817efa6bf8beaa27d9365bbf84f2bed Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:43:49 -0400 Subject: [PATCH 07/11] Qt : Use `postBuildMoves` --- Qt/config.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Qt/config.py b/Qt/config.py index 6c1dcdc228..76003b5bd3 100644 --- a/Qt/config.py +++ b/Qt/config.py @@ -62,9 +62,13 @@ "cmake --build . --parallel {jobs} && cmake --install .", - "cp {buildDir}/libexec/moc {buildDir}/bin", - "cp {buildDir}/libexec/rcc {buildDir}/bin", - "cp {buildDir}/libexec/uic {buildDir}/bin", + ], + + "postBuildCopy" : [ + + ( "{buildDir}/libexec", "moc", "{buildDir}/bin" ), + ( "{buildDir}/libexec", "rcc", "{buildDir}/bin" ), + ( "{buildDir}/libexec", "uic", "{buildDir}/bin" ), ], From 368099e3691708b3753d0bf05993f356cf1d2191 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:45:10 -0400 Subject: [PATCH 08/11] Qt.py : Use `postBuildMoves` --- Qt.py/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Qt.py/config.py b/Qt.py/config.py index 3699e53cee..9767a4df14 100644 --- a/Qt.py/config.py +++ b/Qt.py/config.py @@ -11,9 +11,11 @@ "dependencies" : [ "Python" ], - "commands" : [ + "commands" : [], - "cp Qt.py {buildDir}/python", + "postBuildCopy" : [ + + ( None, "Qt.py", "{buildDir}/python" ) ], From 4712d837d8899435aa8c2f299e9a36eab35b4045 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 16:58:56 -0400 Subject: [PATCH 09/11] USD : Use `postBuildMoves` --- USD/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/USD/config.py b/USD/config.py index f0f3bf5672..4ac456e366 100644 --- a/USD/config.py +++ b/USD/config.py @@ -51,7 +51,12 @@ "make install", "rm -rf {buildDir}/python/pxr", - "mv {buildDir}/lib/python/pxr {buildDir}/python", + + ], + + "postBuildMove" : [ + + ( "{buildDir}/lib/python", "pxr/**/*", "{buildDir}/python" ), ], From 5080b25dff559cd47f121bde6ac24307d1114a64 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 11 Mar 2026 17:52:34 -0400 Subject: [PATCH 10/11] Cycles : Use `postBuildMoves` --- Cycles/config.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Cycles/config.py b/Cycles/config.py index 21011221d7..e2241c5c3d 100644 --- a/Cycles/config.py +++ b/Cycles/config.py @@ -40,13 +40,20 @@ " ..", "cd build && make install -j {jobs} VERBOSE=1", - "mkdir -p {buildDir}/cycles/include", - "cd src && find . -name '*.h' | cpio -pdm {buildDir}/cycles/include", - "cp -r third_party/atomic/* {buildDir}/cycles/include", - "mkdir -p {buildDir}/cycles/bin", - "mv {buildDir}/cycles/cycles {buildDir}/cycles/bin/cycles", - "cp -r build/lib {buildDir}/cycles", + ], + + "postBuildCopy" : [ + ( "src", "**/*.h", "{buildDir}/cycles/include" ), + ( "third_party/atomic", "**/*.h", "{buildDir}/cycles/include" ), + ( "build/lib", "**/*", "{buildDir}/cycles/lib" ), + + ], + + "postBuildMove" : [ + + ( "{buildDir}/cycles", "cycles", "{buildDir}/cycles/bin" ), + ], "manifest" : [ From bd182488d4bef2c31b7f5846f5ed467e2b193ff0 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 19 Mar 2026 15:13:41 -0400 Subject: [PATCH 11/11] build : Fix cleaning of read-only files on Windows --- build.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.py b/build.py index 5875a2f8d4..8fb19597f3 100755 --- a/build.py +++ b/build.py @@ -11,6 +11,7 @@ import pathlib import subprocess import shutil +import stat import sys import tarfile import zipfile @@ -346,8 +347,12 @@ def __buildProject( project, config, buildDir, cleanup ) : os.symlink( link[1], link[0] ) if cleanup : + def removeReadonly( func, path, *unused ) : + os.chmod( path, stat.S_IWRITE ) + func( path ) + os.chdir( buildRootDirectory ) - shutil.rmtree( fullWorkingDir ) + shutil.rmtree( fullWorkingDir, onexc = removeReadonly ) def __checkConfigs( projects, configs ) :