/src/cpython/Python/getversion.c
Line | Count | Source |
1 | | |
2 | | /* Return the full version string. */ |
3 | | |
4 | | #include "Python.h" |
5 | | |
6 | | #include "patchlevel.h" |
7 | | |
8 | | static int initialized = 0; |
9 | | static char version[300]; |
10 | | |
11 | | void _Py_InitVersion(void) |
12 | 32 | { |
13 | 32 | if (initialized) { |
14 | 16 | return; |
15 | 16 | } |
16 | 16 | initialized = 1; |
17 | | #ifdef Py_GIL_DISABLED |
18 | | const char *buildinfo_format = "%.80s free-threading build (%.80s) %.80s"; |
19 | | #else |
20 | 16 | const char *buildinfo_format = "%.80s (%.80s) %.80s"; |
21 | 16 | #endif |
22 | 16 | PyOS_snprintf(version, sizeof(version), buildinfo_format, |
23 | 16 | PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler()); |
24 | 16 | } |
25 | | |
26 | | const char * |
27 | | Py_GetVersion(void) |
28 | 16 | { |
29 | 16 | _Py_InitVersion(); |
30 | 16 | return version; |
31 | 16 | } |
32 | | |
33 | | // Export the Python hex version as a constant. |
34 | | const unsigned long Py_Version = PY_VERSION_HEX; |