Build Python without optional dependencies (openssl, zstd)

Is it possible to explicitly set configuration to build Python without openssl/zstd?

I’m cross-compiling Python for intel on arm64 machine and during configuration it keeps picking up globally installed openssl/zstd and then fail during build due to architecture mismatch.

In my case I don’t really need openssl/zstd in the Python I want to build. And since they’re optional, is there option to skip them?

Found very old similar threads about building openssl - the only solutions were to patch configuration files / temporarily disguise openssl. Perhaps something has changed since then.

Doesn’t the build script (Makefile) not build the openssl stuff, if openssl is not found in the build environment? Perhaps that means building in a docker container is necessary, if you don’t want to uninstall openssl or zstd.

I’m not entirely sure how it works, but it manages to pick up arm64 dependencies in my case and then fail somewhere later.

ld: warning: ignoring file '/opt/homebrew/Cellar/zstd/1.5.7/lib/libzstd.1.5.7.dylib': found architecture 'arm64', required architecture 'x86_64'
Error:  _zstd failed to import: dlopen(/Users/runner/work/IfcOpenShell/IfcOpenShell/build/Darwin/x86_64/10.15/build/Python-3.14.0/build/build/lib.macosx-14.7-x86_64-3.14/_zstd.cpython-314-darwin.so, 0x0002): symbol not found in flat namespace '_ZDICT_finalizeDictionary'

Investigating more, I’ve found a workaround. Python’s configuration is relying on pkg-configto find dependencies like zstd.

So if we prefix PATH to make sure it will find pkg-config that only knows about intel dependencies, it will work:

/usr/local/bin/brew install pkg-config


PATH=/usr/local/bin:$PATH ../configure --prefix=/Users/m1/python-install-root --with-universal-archs=intel-64 --enable-universalsdk

Great stuff - well done.

Why are binaries for both architectures are present? Are you cross-compiling for x64 from an ARM machine? Does some other hardware need the ARM ones?

Was using github action arm64 runner for both arm64 build and cross compiled Intel build.

And arm64 runner image has some arm64 dependenceies preinstalled that get in the way (runner-images/images/macos/macos-14-arm64-Readme.md at main · actions/runner-images) - zstd and openssl in particular. In theory could just remove them, but wasn’t sure - maybe something else is tied to them.

The reason why it’s arm64 and cross-compilation instead of just using Intel image - wanted to keep macOS 14 for the build, but there’s only large runner available for Intel on that version.

1 Like