Unable to Shipping With Python



  • Hi all, I'm writing a Qt program with Python embedded. I use the old embed way (python.h, not CFFI).
    It works fine on my creator. But when i try to deploy my program. macdeployqt couldn't help me deploy python.Framework to Frameworks. And the Qt program try to use user's own python environment which is not what i want.
    And Google tells me very little thing about how to deploy python framework when you are embedding it.
    Does anyone try this before? Or Where can i get the right information about how to ship Qt program with python embedded. many thanks



  • when macdeployqt, it shows this:
    ERROR: no file at "/usr/local/opt/python/lib/Python.framework/Versions/2.7/Python"
    but my python is not here. where should i specific this path for macdeployqt to find Python?



  • i can only copy python.framework by my self now. still want it processed by macdeployqt automate


  • Lifetime Qt Champion

    Hi,

    One thing you can try is to use the -libpath parameter of macdeployqt to give add additional search path that the tool will use to search for libraries/frameworks.

    Hope it helps



  • @SGaist didn't work.
    BTW, when otool -L my binary

    it shows:

    /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1348.28.0)
    @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.8.0, current version 5.8.0)
    @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.8.0, current version 5.8.0)
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.8.0, current version 5.8.0)
    ...
    

    that happened before i use macdeployqt.

    So the path has been set when the binary is created. and macdeployqt copy frameworks according to this. And my Python.Framework is in the wrong place since then.



  • @SGaist For now I have to workaround like this:

    • build my code.
    install_name_tool -change /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python @executable_path/../Frameworks/Python.framework/Versions/2.7/Python
    
    • copy Python.Framework to Frameworks manually

    It works, but I'm not very confident with it.


  • Lifetime Qt Champion

    It should be the other way around, copy the framework first and then update the paths inside it. That's basically what macdeployqt does.



  • Yes, It sounds reasonable that macdeployqt use these shared library information to deploy frameworks.
    so I take your advice, use install_name_tool to specify my Framework path, try to let macdeployqt to finish the deploy work. And the result is frustrating again:

    • otool shows it's using:
    /my_path/.../python/mac/Python.framework/Versions/2.7/Python
    
    • macdeployqt try to find in:
    /my_path/.../python/lib/Python.framework/Versions/2.7/Python
    

    T^T ... So werid.

    after that, i create a link name "lib" and link to "mac", hope it can help macdeployqt to find the right Framework. and it didn't help, the problem stays all the same


  • Lifetime Qt Champion

    In that kind of corner cases, the fastest is to write a small script that run macdeployqt on your application bundle, then copy the problematic frameworks and update their paths.



  • @SGaist Yes that's how i fix it now. maybe macdeployqt is designed to deploy only qt framework. we should do the rest.


  • Lifetime Qt Champion

    No it's not, however it's easy to be using additional frameworks that may have some quirks once deployed which usually not your fault since you follow their installation instructions.



  • @SGaist With this workaround, I should mark this as solved


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.