In CPython there is a configuration option for the build machine's system type
$ wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
$ tar -xzvf Python-3.7.3.tgz
$ cd Python-3.7.3
$ ./configure --help | grep -A 3 "System types"
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]
How does one properly determine what BUILD
should be here for any Linux distribution? Through searching I found CPython Issue 3754 (cross-compilation support for python build) I can see that valid BUILD
values are --build=x86_64-linux-gnu
and --build=x86_64-redhat-linux-gnu
. I can also see from the CPython Dockerfile for Python 3.7 that --build
is being set to the output of $(dpkg-architecture --query DEB_BUILD_GNU_TYPE)
, which on Debian stretch gives
$ docker run --rm debian:stretch /bin/bash -c "echo '$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)'"
x86_64-linux-gnu
but if I am on something like CentOS 7 then how would I properly determine this using OS commands?
Ideally what I would like is some documentation that better describes the --build
option. So if this is known and can be linked to that would sufficiently answer the question.
Edit: Thanks to Anthony Shaw I learned that this is not a CPython issue but related to autoconf. From this information given to me, I see in the autoconf manual (Section 16.7 Specifying the System Type) that
...give it the
--build=type
option.type
can either be a short name for the system type, such as ‘sun4’, or a canonical name which has the form:cpu-company-system
where system can have one of these forms:
os kernel-os
See the file
config.sub
for the possible values of each field. Ifconfig.sub
isn't included in this package, then this package doesn't need to know the machine type.
CPython has a config.sub
$ wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
$ tar -xzvf Python-3.7.3.tgz
$ cd Python-3.7.3
$ ./config.sub --help
Usage: ./config.sub [OPTION] CPU-MFR-OPSYS or ALIAS
Canonicalize a configuration name.
Options:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to <config-patches@gnu.org>.
but it still isn't very clear to me if there is a general Linux wide solution to determining with OS commands how to get this information.