Where is the Python launch banner defined?

I am compiling several different versions of Python for my system, and I would like to know where the launch banner is defined in the source code, so I can change it for each version. For example, when the interpreter starts,

Python 3.3.1 (default, Apr 28 2013, 10:19:42) 
[GCC 4.7.2 20121109 (Red Hat 4.7.2-8)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

I would like to change the line defaultto other things to tell which version I'm using, but I'm also interested in how the whole shebang is going. Where is this defined?

+5
source share
2 answers

grep . default, , Type "Help", . C, . C Python .

Python $ grep 'Type \\"help\\"' . -Ir
./Modules/main.c:    "Type \"help\", \"copyright\", \"credits\" or \"license\" " \

Modules/main.c, Py_Main(). :

fprintf(stderr, "Python %s on %s\n",
    Py_GetVersion(), Py_GetPlatform());

"on" , Py_GetPlatform() linux Py_GetVersion() ...

Python $ grep Py_GetVersion . -Irl
...
./Python/getversion.c
...

...

PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
              PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());

Py_GetBuildInfo(), ...

Python $ grep Py_GetBuildInfo . -Irl
...
./Modules/getbuildinfo.c
...

.

const char *
Py_GetBuildInfo(void)
{
    static char buildinfo[50 + sizeof(HGVERSION) +
                          ((sizeof(HGTAG) > sizeof(HGBRANCH)) ?
                           sizeof(HGTAG) : sizeof(HGBRANCH))];
    const char *revision = _Py_hgversion();
    const char *sep = *revision ? ":" : "";
    const char *hgid = _Py_hgidentifier();
    if (!(*hgid))
        hgid = "default";
    PyOS_snprintf(buildinfo, sizeof(buildinfo),
                  "%s%s%s, %.20s, %.9s", hgid, sep, revision,
                  DATE, TIME);
    return buildinfo;
}

, default - Mercurial. make , , HGTAG. makefile HGTAG , . ,

Python

Python $ ./configure
Python $ make HGTAG='echo awesome'
Python $ ./python
Python 3.2.3 (awesome, May  1 2013, 21:33:27) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
+14

, , default (: Modules/getbuildinfo.c: _Py_hgidentifier())

, default, . , , , , ( tip).

0

All Articles