blob: c70126d58419b321d8c8d1b6a827e2c3ebb7b5de [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
Guido van Rossumcd16bf62007-06-13 18:07:49 +000023/* on unix, SVNVERSION is passed on the command line.
24 * on Windows, the string is interpolated using
25 * subwcrev.exe
26 */
27#ifndef SVNVERSION
Martin v. Löwisd078e402006-01-18 09:13:51 +000028#define SVNVERSION "$WCRANGE$$WCMODS?M:$"
Guido van Rossumcd16bf62007-06-13 18:07:49 +000029#endif
30
Georg Brandl1ca2e792011-03-05 20:51:24 +010031/* XXX Only unix build process has been tested */
32#ifndef HGVERSION
33#define HGVERSION ""
34#endif
35#ifndef HGTAG
36#define HGTAG ""
37#endif
38#ifndef HGBRANCH
39#define HGBRANCH ""
40#endif
41
Guido van Rossum2fff2e61997-01-20 18:34:26 +000042const char *
Thomas Woutersf3f33dc2000-07-21 06:00:07 +000043Py_GetBuildInfo(void)
Guido van Rossum2fff2e61997-01-20 18:34:26 +000044{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000045 static char buildinfo[50];
Georg Brandl1ca2e792011-03-05 20:51:24 +010046 const char *revision = _Py_hgversion();
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000047 const char *sep = *revision ? ":" : "";
Georg Brandl1ca2e792011-03-05 20:51:24 +010048 const char *hgid = _Py_hgidentifier();
49 if (!(*hgid))
50 hgid = "default";
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000051 PyOS_snprintf(buildinfo, sizeof(buildinfo),
Georg Brandl1ca2e792011-03-05 20:51:24 +010052 "%s%s%s, %.20s, %.9s", hgid, sep, revision,
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000053 DATE, TIME);
54 return buildinfo;
Guido van Rossum2fff2e61997-01-20 18:34:26 +000055}
Barry Warsawce3a9132005-12-19 14:43:44 +000056
57const char *
Martin v. Löwis43b57802006-01-05 23:38:54 +000058_Py_svnversion(void)
Barry Warsawce3a9132005-12-19 14:43:44 +000059{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000060 /* the following string can be modified by subwcrev.exe */
61 static const char svnversion[] = SVNVERSION;
62 if (svnversion[0] != '$')
63 return svnversion; /* it was interpolated, or passed on command line */
64 return "Unversioned directory";
Barry Warsawce3a9132005-12-19 14:43:44 +000065}
Georg Brandl1ca2e792011-03-05 20:51:24 +010066
67const char *
68_Py_hgversion(void)
69{
70 return HGVERSION;
71}
72
73const char *
74_Py_hgidentifier(void)
75{
76 const char *hgtag, *hgid;
77 hgtag = HGTAG;
78 if ((*hgtag) && strcmp(hgtag, "tip") != 0)
79 hgid = hgtag;
80 else
81 hgid = HGBRANCH;
82 return hgid;
83}