Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS build with SSL problems #4514

Closed
1 task done
syleishere opened this issue Dec 7, 2024 · 10 comments
Closed
1 task done

MacOS build with SSL problems #4514

syleishere opened this issue Dec 7, 2024 · 10 comments
Assignees

Comments

@syleishere
Copy link
Contributor

syleishere commented Dec 7, 2024

Duplicate Check

Describe the bug

File "./ssl.py", line 100, in
ImportError: dlopen(/Users/dan/flet/crystaltunes/build/macos/Crystal Tunes.app/Contents/Frameworks/serious_python_darwin.framework/Resources/python-stdlib/lib-dynload/_ssl.cpython-312-darwin.so, 0x0002): Library not loaded: @rpath/Python.framework/Versions/3.12/lib/libssl.3.dylib
Referenced from: <025BF2AA-54E7-333A-B7FA-BD852F11C4CE> /Users/dan/flet/crystaltunes/build/macos/Crystal Tunes.app/Contents/Frameworks/serious_python_darwin.framework/Versions/A/Resources/python-stdlib/lib-dynload/_ssl.cpython-312-darwin.so
Reason: tried: '/usr/lib/swift/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/Users/dan/flet/crystaltunes/build/macos/Crystal Tunes.app/Contents/Frameworks/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/Users/dan/flet/crystaltunes/build/macos/Crystal Tunes.app/Contents/MacOS/Frameworks/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/usr/local/lib/libssl.3.dylib' (no such file), '/usr/lib/libssl.3.dylib' (no such file, not in dyld cache)

Code sample

Code

A simple hello world that does an "import ssl" is sufficient to reproduce along with a "flet build macos" and try to run app.
Should keep in mind here I am talking about the final build macos app, and not just running flet in pycharm or vscode, as that of course would work....

To reproduce

A simple hello world with "import ssl" or import aiohttp or httpx which will call import ssl for you under the hood.
flet build macos
and run the app in build/macos folder.

Expected behavior

The app should run fine, end users should not be expected to install python or openssl in order to run app. On windows builds the .dll files are included in same directory as the app itself, on macos the .dylib could be included. At this point I am thinking VMs should be created that are fresh for MacOS/windows with no python or anything development related installed and see if a simple flet program with 'hello world" and import ssl are working.

Screenshots / Videos

No response

Operating System

macOS

Operating system details

Mac Mini M4

Flet version

Latest devel

Regression

No, it isn't

Suggestions

After app is built you could do something like

mkdir build/macos/<appname>/Contents/Frameworks/Python.framework/Versions/3.12/lib
cp -f /path/to/libssl.3.dylib build/macos/<appname>/Contents/Frameworks/Python.framework/Versions/3.12/lib/
cp -f /path/to/libcrypto.3.dylib build/macos/<appname>/Contents/Frameworks/Python.framework/Versions/3.12/lib/

or maybe _ssl.cpython-312-darwin.so could be built statically to include those 2 .dylib files somehow...

Logs

No response

Additional details

There are more dylib files that may be needed for other things as well:

# ls /Library/Frameworks/Python.framework/Versions/3.12/lib/
Tk.icns                 libformw.5.dylib        libncursesw.dylib       libssl.dylib            pkgconfig               tclConfig.sh            tdbcpostgres1.1.7
Tk.tiff                 libformw.dylib          libpanelw.5.dylib       libtcl8.6.dylib         python3.12              tclooConfig.sh          thread2.8.9
itcl4.2.4               libmenuw.5.dylib        libpanelw.dylib         libtclstub8.6.a         sqlite3.44.2            tdbc1.1.7               tk8.6
libcrypto.3.dylib       libmenuw.dylib          libpython3.12.dylib     libtk8.6.dylib          tcl8                    tdbcmysql1.1.7          tkConfig.sh
libcrypto.dylib         libncursesw.5.dylib     libssl.3.dylib          libtkstub8.6.a          tcl8.6                  tdbcodbc1.1.7

@dsx1986
Copy link

dsx1986 commented Dec 10, 2024

same here. I am on intel mac:

mportError: dlopen(/Applications/diogenesaibutlerflet.app/Contents/Frameworks/serious_python_darwin.framework/Resources/python-stdlib/lib-dynload/_ssl.cpython-312-darwin.so, 0x0002): Library not loaded: @rpath/Python.framework/Versions/3.12/lib/libssl.3.dylib
Referenced from: <100FC5D6-F38C-332F-912E-9133D08CA90A> /Applications/diogenesaibutlerflet.app/Contents/Frameworks/serious_python_darwin.framework/Versions/A/Resources/python-stdlib/lib-dynload/_ssl.cpython-312-darwin.so
Reason: tried: '/usr/lib/swift/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/Applications/diogenesaibutlerflet.app/Contents/Frameworks/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/Applications/diogenesaibutlerflet.app/Contents/MacOS/Frameworks/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/Python.framework/Versions/3.12/lib/libssl.3.dylib' (no such file), '/usr/local/lib/libssl.3.dylib' (file system sandbox blocked open()), '/usr/lib/libssl.3.dylib' (no such file, not in dyld cache)

@dsx1986
Copy link

dsx1986 commented Dec 10, 2024

I got this error when I release it to test flight and test on my mac M4:

File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/pydantic_core/init.py", line 6, in
from ._pydantic_core import (
ImportError: dlopen(/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/pydantic_core/_pydantic_core.cpython-312-darwin.so, 0x0002): tried: '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/pydantic_core/_pydantic_core.cpython-312-darwin.so' (code signature in <17D6EF5C-4D71-3E06-912D-5464BC98FC00> '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/pydantic_core/_pydantic_core.cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy), '/System/Volumes/Preboot/Cryptexes/OS/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/pydantic_core/_pydantic_core.cpython-312-darwin.so' (no such file), '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/pydantic_core/_pydantic_core.cpython-312-darwin.so' (code signature in <17D6EF5C-4D71-3E06-912D-5464BC98FC00> '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/pydantic_core/_pydantic_core.cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy)

@FeodorFitsner
Copy link
Contributor

Have you signed and notarized the bundle?

@FeodorFitsner
Copy link
Contributor

I'm going to perform a full test of macOS packaging. Two things I suspect: 1) the app needs some entitlements: https://forums.developer.apple.com/forums/thread/716918 (also, flet build creates non-sandboxed app) and 2) it could be a problem with signing 3rd-party python packages (like pydantic) unpacked during the first run.

@FeodorFitsner FeodorFitsner self-assigned this Dec 10, 2024
@dsx1986
Copy link

dsx1986 commented Dec 10, 2024

Have you signed and notarized the bundle?

Yes, I signed through xcode build/archive using mac distribution certificate and profile, and it passed app store connect upload. The error happened when I test in through TestFlight

@FeodorFitsner
Copy link
Contributor

Good, will be investigating the issue. Packaging has #1 priority for us.

@FeodorFitsner
Copy link
Contributor

@syleishere SSL issue has been fixed. macOS package now includes libcrypto.dylib and libssl.dylib. import ssl in Python worked for me. Re-build the app. I'm closing this issue as fixed.

@dsx1986 For "library load disallowed by system policy" error I've opened another issue: #4543

@dsx1986
Copy link

dsx1986 commented Dec 11, 2024

@syleishere SSL issue has been fixed. macOS package now includes libcrypto.dylib and libssl.dylib. import ssl in Python worked for me. Re-build the app. I'm closing this issue as fixed.

@dsx1986 For "library load disallowed by system policy" error I've opened another issue: #4543

How do we get latest fix? Did you release new version?

@FeodorFitsner
Copy link
Contributor

How do we get latest fix? Did you release new version?

I've updated iOS distro here: https://github.com/flet-dev/python-build/releases/tag/v3.12
It gets downloaded every time you flet build. Delete build directory in your project and re-build the app.

@syleishere
Copy link
Contributor Author

All good.

macos:~/flet/crystaltunes/build/macos/Crystal Tunes.app $ find .|grep dylib |xargs ls -al
-rwxr-xr-x@ 1 dan  staff  7860080 Dec 10 15:20 ./Contents/Frameworks/Python.framework/Versions/3.12/lib/libcrypto.3.dylib
lrwxr-xr-x@ 1 dan  staff       17 Sep 30 22:35 ./Contents/Frameworks/Python.framework/Versions/3.12/lib/libcrypto.dylib -> libcrypto.3.dylib
-rwxr-xr-x@ 1 dan  staff  1321936 Dec 10 15:20 ./Contents/Frameworks/Python.framework/Versions/3.12/lib/libssl.3.dylib
lrwxr-xr-x@ 1 dan  staff       14 Sep 30 22:35 ./Contents/Frameworks/Python.framework/Versions/3.12/lib/libssl.dylib -> libssl.3.dylib
-rw-r--r--@ 1 dan  staff     1261 Dec 10 23:11 ./Contents/Frameworks/serious_python_darwin.framework/Versions/A/Resources/python-stdlib/ctypes/macholib/dylib.pyc
macos:~/flet/crystaltunes/build/macos/Crystal Tunes.app $ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants