blob: 0971a64fccbadc9d6887b91da03e3efbeeb6447f [file] [log] [blame]
Tim Peters22a51ef2001-12-04 01:11:32 +00001#include "Python.h"
Guido van Rossum49bff651997-05-20 22:40:26 +00002
Guido van Rossumff7e83d1999-08-27 20:39:37 +00003#ifndef DONT_HAVE_STDIO_H
Guido van Rossum2fff2e61997-01-20 18:34:26 +00004#include <stdio.h>
Guido van Rossumff7e83d1999-08-27 20:39:37 +00005#endif
Guido van Rossum2fff2e61997-01-20 18:34:26 +00006
7#ifndef DATE
8#ifdef __DATE__
9#define DATE __DATE__
10#else
11#define DATE "xx/xx/xx"
12#endif
13#endif
14
15#ifndef TIME
16#ifdef __TIME__
17#define TIME __TIME__
18#else
19#define TIME "xx:xx:xx"
20#endif
21#endif
22
Georg Brandl1ca2e792011-03-05 20:51:24 +010023/* XXX Only unix build process has been tested */
24#ifndef HGVERSION
25#define HGVERSION ""
26#endif
27#ifndef HGTAG
28#define HGTAG ""
29#endif
30#ifndef HGBRANCH
31#define HGBRANCH ""
32#endif
33
Guido van Rossum2fff2e61997-01-20 18:34:26 +000034const char *
Thomas Woutersf3f33dc2000-07-21 06:00:07 +000035Py_GetBuildInfo(void)
Guido van Rossum2fff2e61997-01-20 18:34:26 +000036{
Benjamin Petersonad45bfe2011-03-28 17:25:15 -050037 static char buildinfo[50 + sizeof(HGVERSION) +
38 ((sizeof(HGTAG) > sizeof(HGBRANCH)) ?
39 sizeof(HGTAG) : sizeof(HGBRANCH))];
Georg Brandl1ca2e792011-03-05 20:51:24 +010040 const char *revision = _Py_hgversion();
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000041 const char *sep = *revision ? ":" : "";
Georg Brandl1ca2e792011-03-05 20:51:24 +010042 const char *hgid = _Py_hgidentifier();
43 if (!(*hgid))
44 hgid = "default";
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000045 PyOS_snprintf(buildinfo, sizeof(buildinfo),
Georg Brandl1ca2e792011-03-05 20:51:24 +010046 "%s%s%s, %.20s, %.9s", hgid, sep, revision,
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000047 DATE, TIME);
48 return buildinfo;
Guido van Rossum2fff2e61997-01-20 18:34:26 +000049}
Barry Warsawce3a9132005-12-19 14:43:44 +000050
51const char *
Georg Brandl1ca2e792011-03-05 20:51:24 +010052_Py_hgversion(void)
53{
54 return HGVERSION;
55}
56
57const char *
58_Py_hgidentifier(void)
59{
60 const char *hgtag, *hgid;
61 hgtag = HGTAG;
62 if ((*hgtag) && strcmp(hgtag, "tip") != 0)
63 hgid = hgtag;
64 else
65 hgid = HGBRANCH;
66 return hgid;
67}