Build failing on macOS ext_python

Hi, I’m trying to build Krita from source on macOS. I’m following the instructions in the docs, but it keeps failing to build dependencies.

This is the error at the end:

    import binascii
ModuleNotFoundError: No module named 'binascii'
make[4]: *** [install] Error 1
make[3]: *** [ext_python/ext_python-prefix/src/ext_python-stamp/ext_python-install] Error 2
make[2]: *** [ext_python/CMakeFiles/ext_python.dir/all] Error 2
make[1]: *** [ext_python/CMakeFiles/ext_python.dir/rule] Error 2
make: *** [ext_python] Error 2
 build fail, attempting known fixes...
Error building package ext_python, stopping...

It looks like it’s failing here:

building 'binascii' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -fno-semantic-interposition -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-instr-use=code.profclangd -I/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python/Include/internal -I. -IObjects -IPython -I/usr/local/include -I/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python/Include -I/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build -c /Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python/Modules/binascii.c -o build/temp.macosx-10.13-x86_64-3.10/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python/Modules/binascii.o -DUSE_ZLIB_CRC32
clang: warning: argument unused during compilation: '-fno-semantic-interposition' [-Wunused-command-line-argument]
warning: no profile data available for file "binascii.c" [-Wprofile-instr-unprofiled]
1 warning generated.
gcc -bundle -undefined dynamic_lookup build/temp.macosx-10.13-x86_64-3.10/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python/Modules/binascii.o -L/usr/local/lib -lz -o build/lib.macosx-10.13-x86_64-3.10/binascii.cpython-310-darwin.so -Wl,-search_paths_first
*** WARNING: renaming "_ssl" since importing it failed: dlopen(/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build/build/lib.macosx-10.13-x86_64-3.10/_ssl.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_SSL_get1_peer_certificate'
*** WARNING: renaming "_hashlib" since importing it failed: dlopen(/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build/build/lib.macosx-10.13-x86_64-3.10/_hashlib.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_EVP_MD_CTX_get0_md'
*** WARNING: renaming "zlib" since importing it failed: dlopen(/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build/build/lib.macosx-10.13-x86_64-3.10/zlib.cpython-310-darwin.so, 0x0002): Symbol not found: _adler32
  Referenced from: <297AB9E6-352C-38D7-9F8C-8311A3B30794> /Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build/build/lib.macosx-10.13-x86_64-3.10/zlib.cpython-310-darwin.so
  Expected in:     <no uuid> unknown
*** WARNING: renaming "binascii" since importing it failed: dlopen(/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build/build/lib.macosx-10.13-x86_64-3.10/binascii.cpython-310-darwin.so, 0x0002): Symbol not found: _crc32
  Referenced from: <30E33D40-5955-359F-A06D-FE4EC9BDB5C3> /Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build/build/lib.macosx-10.13-x86_64-3.10/binascii.cpython-310-darwin.so
  Expected in:     <no uuid> unknown

The necessary bits to build these optional modules were not found:
_gdbm                 ossaudiodev           spwd               
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time               


Following modules built successfully but were removed because they could not be imported:
_hashlib              _ssl                  binascii           
zlib                                                           


Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer
Custom linker flags may require --with-openssl-rpath=auto

Does anyone know how to fix this? Thank you!

Just a wild guess, it says openssl module is not found/old version. See if your openssl is right version openssl version -a, if not, update it

I’m not sure if this is the right version, but it seems up to date.

OpenSSL 3.2.0 23 Nov 2023 (Library: OpenSSL 3.2.0 23 Nov 2023)
built on: Thu Nov 23 13:20:19 2023 UTC
platform: darwin64-x86_64-cc
options:  bn(64,64)
compiler: clang -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
OPENSSLDIR: "/usr/local/etc/openssl@3"
ENGINESDIR: "/usr/local/Cellar/openssl@3/3.2.0/lib/engines-3"
MODULESDIR: "/usr/local/Cellar/openssl@3/3.2.0/lib/ossl-modules"
Seeding source: os-specific
CPUINFO: OPENSSL_ia32cap=0x7ffaf3ffffebffff:0x29c6fbf

If you’re using the latest version of Xcode (15), building dependencies is broken at the moment and you’ll need to downgrade to Xcode 14.

I downgraded to Xcode 14 and nothing changed.

I’m not sure, then… I might have misremembered the reason it’s broken, sorry. But @IvanYossi has been working on the macOS dependencies issues and might could give better insight.

The error itself is caused by the new linker introduced in XCode15 which broke most dependencies linkage. Right now you need to either downgrade to XCode14 (remember to change the default compiler) or help us test compiling with the newest version of the any broken dependency.

Afaik (I haven’t tested myself) the latest python should fix this issue in particular.

I deleted XCode 15 and am running XCode 14. Homebrew says Python is up to date. It’s still not working, but with a slightly different error now:

Error: Printing last lines of log output
Traceback (most recent call last):
  File "/Users/Alice/dev/krita/3rdparty/ext_python/install_certificates.py", line 12, in <module>
    import ssl
  File "/Users/Alice/dev/i/lib/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 99, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
make[3]: *** [ext_python/ext_python-prefix/src/ext_python-stamp/ext_python-update_certifi] Error 1
make[2]: *** [ext_python/CMakeFiles/ext_python.dir/all] Error 2
make[1]: *** [ext_python/CMakeFiles/ext_python.dir/rule] Error 2
make: *** [ext_python] Error 2
Error: Failed build ext_python
 build fail, attempting known fixes...
Error building package ext_python, stopping...

Further up there was this bit, which seems related:

*** WARNING: renaming "_ssl" since importing it failed: dlopen(/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build/build/lib.macosx-10.13-x86_64-3.10/_ssl.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_SSL_get1_peer_certificate'
*** WARNING: renaming "_hashlib" since importing it failed: dlopen(/Users/Alice/dev/depbuild/ext_python/ext_python-prefix/src/ext_python-build/build/lib.macosx-10.13-x86_64-3.10/_hashlib.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_EVP_MD_CTX_get0_md'

The necessary bits to build these optional modules were not found:
_gdbm                 ossaudiodev           spwd               
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time               


Following modules built successfully but were removed because they could not be imported:
_hashlib              _ssl                                     


Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer
Custom linker flags may require --with-openssl-rpath=auto

I asked my family about this over the holidays. The python error was fixed by adding this to env.sh:

export LDFLAGS="-L/usr/local/Cellar/openssl@3/3.2.0/lib"
export CPPFLAGS="-I/usr/local/Cellar/openssl@3/3.2.0/include"

I’m now having an issue with building Krita itself. I ran the buildinstall script from the manual, but it isn’t installing Krita to “dev/i/krita.app”. There’s a Krita app in “dev/kisbuild/krita”, but it crashes as soon as I open it and says it couldn’t find QtNetwork in the “kisbuild/libs/ui” folder. Does anyone know how to fix this?

Check if it’s installed to dev/i/bin/krita.app; the manual seems to be missing the bin part of the path in places. If it’s not there, try copying it manually, since it needs to be in the install folder with the libraries to find them.

That fixed it! Thanks so much for helping, I wouldn’t have thought to look there.