Repository metrics
- Stars
- (10,351 stars)
- PR merge metrics
- (Avg merge 5d 12h) (6 merged PRs in 30d)
Description
Output of python -m nuitka --version:
1.8.4
Commercial: None
Python: 3.11.6 (main, Oct 2 2023, 13:45:54) [Clang 15.0.0 (clang-1500.0.40.1)]
Flavor: Homebrew Python
Executable: /Users/tilman/Library/Caches/pypoetry/virtualenvs/project-b1WZl3cy-py3.11/bin/python
OS: Darwin
Arch: arm64
Version C compiler: /opt/homebrew/opt/llvm/bin/clang (clang).
Problem description: I am trying to build an executable on macOS 14.0 Sonoma, that will run on older versions of macOS, too. To do this, I set the following two environment variables:
export CFLAGS="-mmacosx-version-min=12.0"
export MACOSX_DEPLOYMENT_TARGET="12.0
I would expect that this would suffice to create an executable that runs on macOS versions > 12.0. Running otool -l on the created binary nevertheless shows that the minimum version is still 14.0:
Load command 12
cmd LC_BUILD_VERSION
cmdsize 32
platform 1
minos 14.0
sdk 14.0
ntools 1
tool 3
version 1015.7
The same is shown in the output log of Nuitka:
Nuitka:INFO: Created binary that runs on macOS 14.0 (arm64) or higher.
I tracked the issue down to this line, where it will always set the os version to 14.0, no matter what I supply within my environment variables: https://github.com/Nuitka/Nuitka/blob/bac73eae0090563aa0c19a569cb0486002337661/nuitka/build/SconsCompilerSettings.py#L643
I haven't been able to determine how to change the value stored in env.macos_min_version, nevertheless, if I hard-code it to 12.0 the resulting binary has the correct minos version:
Load command 12
cmd LC_BUILD_VERSION
cmdsize 32
platform 1
minos 12.0
sdk 12.0
ntools 1
tool 3
version 1015.7
So, the minimum example to reproduce this would be:
print("Hello World")
And compile it with:
poetry run python -m nuitka --standalone --disable-console --macos-create-app-bundle main.py
This results in the following output:
Nuitka-Options:INFO: Used command line options: --standalone --disable-console --macos-create-app-bundle main.py
Nuitka:WARNING: For GUI applications, you ought to specify an icon with '--macos-app-icon'.", otherwise a dock icon may not be present.
Nuitka:INFO: Starting Python compilation with Nuitka '1.8.4' on Python '3.11' commercial grade 'not installed'.
Nuitka:INFO: Completed Python level compilation and optimization.
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.
Nuitka:INFO: Running C compilation via Scons.
Nuitka-Scons:INFO: Backend C compiler: clang (clang).
Nuitka-Scons:INFO: Inherited CFLAGS='-mmacosx-version-min=12.0' variable.
Nuitka-Scons:INFO: Backend linking program with 6 files (no progress information available for this stage).
Nuitka-Scons:INFO: Compiled 6 C files using ccache.
Nuitka-Scons:INFO: Cached C files (using ccache) with result 'cache hit': 3
Nuitka-Scons:INFO: Cached C files (using ccache) with result 'cache miss': 3
Nuitka:INFO: Keeping build directory 'main.build'.
Nuitka:INFO: Created binary that runs on macOS 14.0 (arm64) or higher.
Nuitka:INFO: Successfully created 'main.app/Contents/MacOS/main'.
I hope this gives you all the information necessary to resolve this issue. If this works as expected, you might want to consider updating the docs on this as I haven't been able to figure out how to set the version correctly.