hku-ect / gazebosc

3 stars 6 forks source link

fixup python executable wrong path #96

Open sphaero opened 3 years ago

sphaero commented 3 years ago
 5/8: fixing up '/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/MacOS/gazebosc'

-- 6/8: fixing up '/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/Frameworks/libpython3.8.dylib'

-- 7/8: fixing up '/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/Frameworks/libzmq.5.dylib'

-- 8/8: fixing up '/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/Resources/python/bin/python3.8'

-- fixup_bundle: cleaning up...

-- fixup_bundle: verifying...

-- ===========================================================================

-- Analyzing app='/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app'

-- bundle='/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app'

-- executable='/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/MacOS/gazebosc'

-- valid='1'

-- executable file 1: /Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/MacOS/gazebosc

-- executable file 2: /Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/Resources/python/bin/python3.8

-- warning: embedded item does not exist '/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/Resources/python/Frameworks/libpython3.8.dylib'
-- 

warning: cannot resolve item '@executable_path/../Frameworks/libpython3.8.dylib'

  possible problems:

    need more directories?

    need to use InstallRequiredSystemLibraries?

  run in install tree instead of build tree?

-- verified='1'

-- info='Verified 2 executable files in '/Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app''

-- 

-- verified='1'

-- info=''

-- 

-- fixup_bundle: done

Path @executable_path/../Frameworks/libpython3.8.dylib is wrong

sphaero commented 3 years ago

path should be /Users/travis/build/hku-ect/gazebosc/build/bin/gazebosc.app/Contents/Frameworks/libpython3.8.dylib

sphaero commented 1 year ago

This has been resolved partly. Now the problem is that all Python binaries have absolute paths from the build host. This should be fixed by fixup_bundle from cmake. However we are ignoring Python binaries in the cmake script:

https://github.com/hku-ect/gazebosc/blob/f64db15456a39ac471531df9febbc2cc4e98632a/CMakeLists.txt#L389

Probably because fixup bundle can't recursively fixup bundles

sphaero commented 1 year ago

ref: https://stackoverflow.com/questions/59415784/cmake-macos-bundleutilities-adds-python-interpreter-to-app-and-doesnt-do-fi

https://cmake.org/pipermail/cmake/2017-March/065140.html

sphaero commented 1 year ago

Error from cpack:

CPack Verbose: fixup_bundle
CPack Verbose:   app='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app'
CPack Verbose:   libs=''
CPack Verbose:   dirs='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build;/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/ext/openvr/bin/osx32'
CPack Verbose:   ignoreItems='exe_with_z64;exe_with_zip'
CPack Verbose: fixup_bundle: preparing...
CPack Verbose: fixup_bundle: copying...
CPack Verbose: 1/8: *NOT* copying '/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/MacOS/gazebosc'
CPack Verbose: 2/8: copying '/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/python/Python.framework/Versions/3.8/Python'
CPack Verbose: 3/8: copying '/usr/local/lib/libzmq.5.dylib'
CPack Verbose: 4/8: *NOT* copying '/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/bin/python3.8'
CPack Verbose: fixup_bundle: fixing...
CPack Verbose: 5/8: fixing up '/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/MacOS/gazebosc'
CPack Verbose: 6/8: fixing up '/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/Python'
CPack Verbose: 7/8: fixing up '/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/libzmq.5.dylib'
CPack Verbose: 8/8: fixing up '/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/bin/python3.8'
CPack Verbose: fixup_bundle: cleaning up...
CPack Verbose: fixup_bundle: verifying...
CPack Verbose: ===========================================================================
CPack Verbose: Analyzing app='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app'
CPack Verbose: bundle='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app'
CPack Verbose: executable='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/MacOS/gazebosc'
CPack Verbose: valid='1'
CPack Verbose: executable file 1: /Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/MacOS/gazebosc
CPack Verbose: executable file 2: /Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/bin/python3.8
CPack Verbose: warning: embedded item does not exist '/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/Frameworks/Python.framework/Versions/3.8/Python'
CPack Verbose: executable file 3: /Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
CPack Verbose: verified='0'
CMake Error at /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/BundleUtilities.cmake:1124 (message):
  error: verify_app failed
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/BundleUtilities.cmake:991 (verify_app)
  /Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/cmake_install.cmake:90 (fixup_bundle)

CPack Verbose: info='external prerequisites found:
f='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_c99d/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python'
external_prereqs='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/python/Python.framework/Versions/3.8/Python'
'
CPack Verbose: 
CPack Error: Error when generating package: Gazebosc
Error: Process completed with exit code 1.
sphaero commented 1 year ago

upstream bugreport https://gitlab.kitware.com/cmake/cmake/-/issues/20165

sphaero commented 1 year ago

Now getting:

 CPack Verbose: executable file 2: /Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_e09f/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
CPack Verbose: verified='0'
CMake Error at /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/BundleUtilities.cmake:1124 (message):
  error: verify_app failed
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/BundleUtilities.cmake:991 (verify_app)
  /Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/cmake_install.cmake:86 (fixup_bundle)

CPack Verbose: info='external prerequisites found:
f='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/_CPack_Packages/Darwin/DragNDrop/gazebosc_OSX_10.15_e09f/ALL_IN_ONE/gazebosc.app/Contents/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python'
external_prereqs='/Users/ect/opt/actions-runner/_work/gazebosc/gazebosc/build/python/Python.framework/Versions/3.8/Python'
'
CPack Verbose: 
CPack Error: Error when generating package: Gazebosc

Perhaps we can fixup the Python framework we build just after build by removing the absolute path references

sphaero commented 1 year ago

cpython issue: https://github.com/python/cpython/issues/86680

sphaero commented 1 year ago

Now erroring on cmake not finding python:

CMake Error at /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
  Could NOT find Python3 (missing: Python3_INCLUDE_DIRS Python3_LIBRARIES
  Development Development.Module Development.Embed)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/FindPython/Support.cmake:3148 (find_package_handle_standard_args)
  /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/FindPython3.cmake:398 (include)
  CMakeLists.txt:115 (find_package)
sphaero commented 1 year ago

reproducable by hand on buildhost:

cmake .. -DPython3_ROOT_DIR=/Users/ect/src/relocatable-python/test/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/../../../../../../Versions/3.11

CMake Error at /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
  Could NOT find Python3 (missing: Python3_INCLUDE_DIRS Python3_LIBRARIES
  Development Development.Module Development.Embed)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/FindPython/Support.cmake:3148 (find_package_handle_standard_args)
  /usr/local/Cellar/cmake/3.19.7/share/cmake/Modules/FindPython3.cmake:398 (include)
  CMakeLists.txt:115 (find_package)
sphaero commented 1 year ago

fix for the app binary:

install_name_tool -change "@rpath/Versions/3.9/Python" "@rpath/../Frameworks/Python.framework/Versions/3.9/Python" PyApp

rootlessNL commented 1 year ago

latest build (ec59) is running but the python binary fails to run. Fix for this is:

install_name_tool -change @executable_path/../Frameworks/libpython3.9.dylib @executable_path/../../../Frameworks/libpython3.9.dylib python3.9