Expose Subversion revision number (calculated via "svnversion .") to Python.
Add C API function Py_GetBuildNumber(), add it to the interactive prompt banner (i.e. Py_GetBuildInfo()), and add it as the sys.build_number attribute. The build number is a string instead of an int because it may contain a trailing 'M' if there are local modifications.
This commit is contained in:
parent
11ca77e6de
commit
2a38a86c1c
|
@ -272,6 +272,12 @@
|
|||
\withsubitem{(in module sys)}{\ttindex{version}}
|
||||
\end{cfuncdesc}
|
||||
|
||||
\begin{cfuncdesc}{const char*}{Py_GetBuildNumber}{}
|
||||
Return a string representing the Subversion revision that this Python
|
||||
executable was built from. This number is a string because it may contain a
|
||||
trailing 'M' if Python was built from a mixed revision source tree.
|
||||
\end{cfuncdesc}
|
||||
|
||||
\begin{cfuncdesc}{const char*}{Py_GetPlatform}{}
|
||||
Return the platform identifier for the current platform. On \UNIX,
|
||||
this is formed from the ``official'' name of the operating system,
|
||||
|
|
|
@ -27,6 +27,12 @@ It is always available.
|
|||
\versionadded{2.0}
|
||||
\end{datadesc}
|
||||
|
||||
\begin{datadesc}{build_number}
|
||||
A string representing the Subversion revision that this Python executable
|
||||
was built from. This number is a string because it may contain a trailing
|
||||
'M' if Python was built from a mixed revision source tree.
|
||||
\end{datadesc}
|
||||
|
||||
\begin{datadesc}{builtin_module_names}
|
||||
A tuple of strings giving the names of all modules that are compiled
|
||||
into this Python interpreter. (This information is not available in
|
||||
|
|
|
@ -108,6 +108,7 @@ PyAPI_FUNC(const char *) Py_GetPlatform(void);
|
|||
PyAPI_FUNC(const char *) Py_GetCopyright(void);
|
||||
PyAPI_FUNC(const char *) Py_GetCompiler(void);
|
||||
PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
|
||||
PyAPI_FUNC(const char *) Py_GetBuildNumber(void);
|
||||
|
||||
/* Internal -- various one-time initializations */
|
||||
PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
|
||||
|
|
|
@ -349,7 +349,9 @@ buildno: $(PARSER_OBJS) \
|
|||
$(SIGNAL_OBJS) \
|
||||
$(MODOBJS) \
|
||||
$(srcdir)/Modules/getbuildinfo.c
|
||||
if test -f buildno; then \
|
||||
if test -d .svn; then \
|
||||
svnversion . >buildno; \
|
||||
elif test -f buildno; then \
|
||||
expr `cat buildno` + 1 >buildno1; \
|
||||
mv -f buildno1 buildno; \
|
||||
else echo 1 >buildno; fi
|
||||
|
@ -444,7 +446,7 @@ Modules/Setup: $(srcdir)/Modules/Setup.dist
|
|||
# Special rules for object files
|
||||
|
||||
Modules/getbuildinfo.o: $(srcdir)/Modules/getbuildinfo.c buildno
|
||||
$(CC) -c $(PY_CFLAGS) -DBUILD=`cat buildno` -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
$(CC) -c $(PY_CFLAGS) -DBUILD=\"`cat buildno`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
|
||||
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
|
||||
$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
|
||||
|
|
|
@ -12,6 +12,10 @@ What's New in Python 2.5 alpha 1?
|
|||
Core and builtins
|
||||
-----------------
|
||||
|
||||
- Patch #1382163: Expose Subversion revision number to Python. New C API
|
||||
function Py_GetBuildNumber(). New attribute sys.build_number. Build number
|
||||
is now displayed in interactive prompt banner.
|
||||
|
||||
- Implementation of PEP 341 - Unification of try/except and try/finally.
|
||||
"except" clauses can now be written together with a "finally" clause in
|
||||
one try statement instead of two nested ones. Patch #1355913.
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef BUILD
|
||||
#define BUILD 0
|
||||
#define BUILD "0"
|
||||
#endif
|
||||
|
||||
const char *
|
||||
|
@ -29,6 +29,12 @@ Py_GetBuildInfo(void)
|
|||
{
|
||||
static char buildinfo[50];
|
||||
PyOS_snprintf(buildinfo, sizeof(buildinfo),
|
||||
"#%d, %.20s, %.9s", BUILD, DATE, TIME);
|
||||
"%s, %.20s, %.9s", BUILD, DATE, TIME);
|
||||
return buildinfo;
|
||||
}
|
||||
|
||||
const char *
|
||||
Py_GetBuildNumber(void)
|
||||
{
|
||||
return BUILD;
|
||||
}
|
||||
|
|
|
@ -1003,6 +1003,9 @@ _PySys_Init(void)
|
|||
PyDict_SetItemString(sysdict, "hexversion",
|
||||
v = PyInt_FromLong(PY_VERSION_HEX));
|
||||
Py_XDECREF(v);
|
||||
PyDict_SetItemString(sysdict, "build_number",
|
||||
v = PyString_FromString(Py_GetBuildNumber()));
|
||||
Py_XDECREF(v);
|
||||
/*
|
||||
* These release level checks are mutually exclusive and cover
|
||||
* the field, so don't get too fancy with the pre-processor!
|
||||
|
|
Loading…
Reference in New Issue