cpython-withatomic / Modules / getbuildinfo.c

#include "Python.h"

#include <stdio.h>

#ifndef DATE
#ifdef __DATE__
#define DATE __DATE__
#define DATE "xx/xx/xx"

#ifndef TIME
#ifdef __TIME__
#define TIME __TIME__
#define TIME "xx:xx:xx"

/* on unix, SVNVERSION is passed on the command line.
 * on Windows, the string is interpolated using
 * subwcrev.exe

/* XXX Only unix build process has been tested */
#define HGVERSION ""
#ifndef HGTAG
#define HGTAG ""
#ifndef HGBRANCH
#define HGBRANCH ""

const char *
    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;

const char *
    /* the following string can be modified by subwcrev.exe */
    static const char svnversion[] = SVNVERSION;
    if (svnversion[0] != '$')
        return svnversion; /* it was interpolated, or passed on command line */
    return "Unversioned directory";

const char *
    return HGVERSION;

const char *
    const char *hgtag, *hgid;
    hgtag = HGTAG;
    if ((*hgtag) && strcmp(hgtag, "tip") != 0)
        hgid = hgtag;
        hgid = HGBRANCH;
    return hgid;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.