This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sysconfig.get_platform() raises ValueError on macOS if '-arch' is present in CFLAGS but doesn't refer to the '-arch' compiler flag
Type: compile error Stage: resolved
Components: Library (Lib), macOS Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: duplicate
Dependencies: Superseder: -arch <arch> detection in _osx_support generates false positives
View: 47154
Assigned To: Nosy List: duncanmmacleod, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2022-02-09 12:16 by duncanmmacleod, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg412900 - (view) Author: Duncan Macleod (duncanmmacleod) Date: 2022-02-09 12:16
The `sysconfig.get_platform()` function raises a `ValueError` if the `cflags` config value (e.g. the `CFLAGS` used at build time) includes the text `-arch` where that doesn't refer to the compiler flag of the same name.

Consider the following example build:

$ sw_vers
ProductName:    macOS
ProductVersion: 11.6.3
BuildVersion:   20G415
$ curl -LO https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
$ tar -xf Python-3.10.2.tar.xz
$ cd Python-3.10.2
$ export CFLAGS="-Itest-arch/fake"  # just something that includes -arch
$ ./configure --prefix=$(pwd)/test-arch
$ make -j

Here the build fails with the following error:


./python.exe -E -S -m sysconfig --generate-posix-vars ;\
        if test $? -ne 0 ; then \
                echo "generate-posix-vars failed" ; \
                rm -f ./pybuilddir.txt ; \
                exit 1 ; \
        fi
Traceback (most recent call last):
  File "/Users/duncanmacleod/src/Python-3.10.2/Lib/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/duncanmacleod/src/Python-3.10.2/Lib/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/duncanmacleod/src/Python-3.10.2/Lib/sysconfig.py", line 803, in <module>
    _main()
  File "/Users/duncanmacleod/src/Python-3.10.2/Lib/sysconfig.py", line 791, in _main
    _generate_posix_vars()
  File "/Users/duncanmacleod/src/Python-3.10.2/Lib/sysconfig.py", line 457, in _generate_posix_vars
    pybuilddir = f'build/lib.{get_platform()}-{_PY_VERSION_SHORT}'
  File "/Users/duncanmacleod/src/Python-3.10.2/Lib/sysconfig.py", line 744, in get_platform
    osname, release, machine = _osx_support.get_platform_osx(
  File "/Users/duncanmacleod/src/Python-3.10.2/Lib/_osx_support.py", line 556, in get_platform_osx
    raise ValueError(
ValueError: Don't know machine value for archs=()
generate-posix-vars failed

Sorry if this is a duplicate of an existing issue.
msg412959 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2022-02-10 00:19
Thanks for the report; I don't recall this coming up before. Of course, the easy workaround is to avoid using "-arch" in CFLAGS paths and the like, but we should fix this.
msg416281 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2022-03-29 17:59
Also reported in bpo-47154 including a suggested fix
History
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90849
2022-03-29 17:59:46ned.deilysetstatus: open -> closed
superseder: -arch <arch> detection in _osx_support generates false positives
messages: + msg416281

resolution: duplicate
stage: resolved
2022-02-10 00:19:34ned.deilysetmessages: - msg412958
2022-02-10 00:19:22ned.deilysetmessages: + msg412959
2022-02-10 00:15:54ned.deilysetversions: + Python 3.9, Python 3.11
nosy: + ronaldoussoren, ned.deily

messages: + msg412958

components: + macOS
type: crash -> compile error
2022-02-09 12:16:49duncanmmacleodcreate