Cpython built-in module problem

here is my local python built-in module list:

Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.builtin_module_names)
('_abc', '_ast', '_bisect', '_blake2', '_codecs', '_collections', '_csv', '_datetime', '_elementtree', '_functools', '_heapq', '_imp', '_io', '_locale', '_md5', '_operator', '_pickle', '_posixsubprocess', '_random', '_sha1', '_sha256', '_sha3', '_sha512', '_signal', '_socket', '_sre', '_stat', '_statistics', '_string', '_struct', '_symtable', '_thread', '_tracemalloc', '_warnings', '_weakref', 'array', 'atexit', 'binascii', 'builtins', 'cmath', 'errno', 'faulthandler', 'fcntl', 'gc', 'grp', 'itertools', 'marshal', 'math', 'posix', 'pwd', 'pyexpat', 'select', 'spwd', 'sys', 'syslog', 'time', 'unicodedata', 'xxsubtype', 'zlib')
>>> 

here is python interpreter that compiled from the latest cpython project in github:

╰─$ ./python           
Python 3.13.0a6+ (heads/main:a23fa3368e, Apr 17 2024, 14:47:48) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.builtin_module_names)
('_abc', '_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_suggestions', '_symtable', '_sysconfig', '_thread', '_tokenize', '_tracemalloc', '_typing', '_warnings', '_weakref', 'atexit', 'builtins', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'posix', 'pwd', 'sys', 'time')
>>> 

It has many fewer built-in modules than local python interpreter.
How to add more built-in module in the compiled python interpreter ?

Did you want to you the still being developer 3.13 version?
If not suggest that you use 3.12.

I would expect that you did not have all the development libraries installed that python’s build needs to detect. The configure should have reported what was being looked for and not found. Check the configure output to see.

The status of those modules as builtin is usually irrelevant. All it means is that those don’t have __file__ attributes because they’re baked into the interpreter itself. You can still import them just fine, it’s just that your 3.13 will be fetching those from files where your 3.10 has them preloaded.

But how to make it as a built-in module like other built-in module such as sys (why is this package in my local python interpreter built-in?), because if i want to execute some python code in c/c++ code it will thow a exception ModuleNotFoundError: No module named ‘math’ Here is my c++ code:

#include <Python.h>
#include <iostream>

int main() {
    Py_Initialize();

    // Run Python code to import sys and math modules
    PyRun_SimpleString("import math");
    
    PyRun_SimpleString("import sys");
    // Get the list of built-in module names
    PyObject* builtins = PySys_GetObject("builtin_module_names");
    if (builtins == NULL) {
        PyErr_Print();
        return 1;
    }

    // Print the list of built-in module names
    PyObject *iterator = PyObject_GetIter(builtins);
    PyObject *item;

    if (iterator == NULL) {
        PyErr_Print();
        return 1;
    }

    while ((item = PyIter_Next(iterator))) {
        const char* str = PyUnicode_AsUTF8(item);
        if (str == NULL) {
            PyErr_Print();
            return 1;
        }
        std::cout << str << std::endl;
        Py_DECREF(item);
    }

    Py_DECREF(iterator);
    Py_Finalize();

    Py_Finalize();

    return 0;
}

Here is the output, of course it reported an error because it was not built-in and the search path of this package was not added,

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'math'
_abc
_ast
_codecs
_collections
_functools
_imp
_io
_locale
_operator
_signal
_sre
_stat
_string
_suggestions
_symtable
_sysconfig
_thread
_tokenize
_tracemalloc
_typing
_warnings
_weakref
atexit
builtins
errno
faulthandler
gc
itertools
marshal
posix
pwd
sys
time

That’s why i want to make it as a built-in module.