Skip to content

Commit 22d7e4c

Browse files
committed
ENH: WIP bundle fixup script in python
Add a new BundleFixup.py script to replace the CMakeScript "fixup_bundle" routine. Advantages are: - speed: `make package` runs in ~3 min as compared to ~1 hr - debuggability: can be debugged in-place with standard pdb (note: For debugging, it is very helpful to create a git image of the package directory after the install step. Then the script can be run/re-run stand-alone, and reset without deleting or re-running other CMake steps) There are two steps to the process: - find all dependencies. For this, we start from the `libs` passed by SlicerCPackBundleFixup (generated based on configured libraries). We look at all dependencies, and based on various criteria, may copy the dependency into the bundle. Similar to existing script, and uses modified versions of the existing regex filters to map source_lib -> target_dir in the bundle. - fixup step: this is a change from the existing script. We look at *all* Mach-O files in the potential bundle, and correct dylib references based on *which files are actually in the bundle*. System library or allow-listed references are ignored (currently only pqsql and mysql re allow-listed -- they are needed by the optional qt database drivers). - implicit verification -- bundling will fail if the dependency is not found or allow-listed. - we remove all absolute RPATH references. This should allow to run tests from the bundle itself on the factory, as a separate verification step (we can't check dlopen calls, but assuming we only `dlopen` checked dylibs from inside the bundle...).
1 parent 8ea85a3 commit 22d7e4c

File tree

2 files changed

+513
-5
lines changed

2 files changed

+513
-5
lines changed

CMake/SlicerCPackBundleFixup.cmake.in

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,43 @@ function(fixup_bundle_with_plugins app)
317317
set(inner_re "${inner_re}|pyw|pyx|raw|sample|so|supp|tcl|txt|ui|xml|exe|mexw32|mexw64")
318318
set(GP_IS_FILE_EXECUTABLE_EXCLUDE_REGEX "\\.(${inner_re})$")
319319

320-
fixup_bundle(
321-
"${app_dir}"
322-
"${libs}"
323-
"${libs_path}"
324-
)
320+
if(NOT APPLE)
321+
fixup_bundle(
322+
"${app_dir}"
323+
"${libs}"
324+
"${libs_path}"
325+
)
326+
else()
327+
set(bundle_config "${Slicer_BUILD_DIR}/CMake/SlicerCPackBundleFixup/bundle_config.txt")
328+
329+
file(WRITE ${bundle_config}
330+
"slicer_build='${Slicer_BUILD_DIR}'
331+
slicer_superbuild='${Slicer_SUPERBUILD_DIR}'
332+
app_name='${app_name}'
333+
app_dir='${app_dir}'
334+
libs='${libs}'
335+
libs_path='${libs_path}'
336+
slicer_lib_dir='@Slicer_LIB_DIR@'
337+
itkfactories_dir='@Slicer_ITKFACTORIES_DIR@'
338+
qtmodules_dir='@Slicer_QTLOADABLEMODULES_LIB_DIR@'
339+
qtplugins_dir='@Slicer_QtPlugins_DIR@'
340+
climodules_dir='@Slicer_CLIMODULES_LIB_DIR@'
341+
python_stdlib_dir='${PYTHON_STDLIB_SUBDIR}'
342+
python_sitepackages_dir='${PYTHON_SITE_PACKAGES_SUBDIR}'
343+
fixup_path='@fixup_path@'
344+
")
345+
346+
file(GLOB_RECURSE bundle_python FALSE "${app_dir}*/python-real")
347+
if(DEFINED bundle_python-NOTFOUND)
348+
message(FATAL_ERROR "Unable to locate python in app_dir: ${app_dir}")
349+
endif()
350+
351+
message(INFO "Running BundlePython app packaging step!")
352+
message(INFO " using python: ${bundle_python}")
353+
354+
execute_process(COMMAND "${bundle_python}" "@Slicer_SOURCE_DIR@/Utilities/Scripts/BundleFixup.py" "${bundle_config}")
355+
endif()
356+
325357
endfunction()
326358

327359
set(app_name "@[email protected]")

0 commit comments

Comments
 (0)