Tim Peters | 22a51ef | 2001-12-04 01:11:32 +0000 | [diff] [blame] | 1 | #include "Python.h" |
Guido van Rossum | 49bff65 | 1997-05-20 22:40:26 +0000 | [diff] [blame] | 2 | |
Guido van Rossum | ff7e83d | 1999-08-27 20:39:37 +0000 | [diff] [blame] | 3 | #ifndef DONT_HAVE_STDIO_H |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 4 | #include <stdio.h> |
Guido van Rossum | ff7e83d | 1999-08-27 20:39:37 +0000 | [diff] [blame] | 5 | #endif |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 6 | |
| 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 Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 23 | /* 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öwis | d078e40 | 2006-01-18 09:13:51 +0000 | [diff] [blame] | 28 | #define SVNVERSION "$WCRANGE$$WCMODS?M:$" |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 29 | #endif |
| 30 | |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 31 | const char * |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 32 | Py_GetBuildInfo(void) |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 33 | { |
Guido van Rossum | 54ecc3d | 1999-01-27 17:53:11 +0000 | [diff] [blame] | 34 | static char buildinfo[50]; |
Tim Peters | a9652f1 | 2006-01-06 02:45:17 +0000 | [diff] [blame] | 35 | const char *revision = Py_SubversionRevision(); |
| 36 | const char *sep = *revision ? ":" : ""; |
| 37 | const char *branch = Py_SubversionShortBranch(); |
Tim Peters | 22a51ef | 2001-12-04 01:11:32 +0000 | [diff] [blame] | 38 | PyOS_snprintf(buildinfo, sizeof(buildinfo), |
Martin v. Löwis | 43b5780 | 2006-01-05 23:38:54 +0000 | [diff] [blame] | 39 | "%s%s%s, %.20s, %.9s", branch, sep, revision, |
| 40 | DATE, TIME); |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 41 | return buildinfo; |
| 42 | } |
Barry Warsaw | ce3a913 | 2005-12-19 14:43:44 +0000 | [diff] [blame] | 43 | |
| 44 | const char * |
Martin v. Löwis | 43b5780 | 2006-01-05 23:38:54 +0000 | [diff] [blame] | 45 | _Py_svnversion(void) |
Barry Warsaw | ce3a913 | 2005-12-19 14:43:44 +0000 | [diff] [blame] | 46 | { |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 47 | /* the following string can be modified by subwcrev.exe */ |
| 48 | static const char svnversion[] = SVNVERSION; |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 49 | if (svnversion[0] != '$') |
| 50 | return svnversion; /* it was interpolated, or passed on command line */ |
Benjamin Peterson | f53eec8 | 2009-05-23 19:36:27 +0000 | [diff] [blame^] | 51 | return "Unversioned directory"; |
Barry Warsaw | ce3a913 | 2005-12-19 14:43:44 +0000 | [diff] [blame] | 52 | } |