expose sigar_version to Python
This commit is contained in:
parent
73b0850a52
commit
5619873f02
|
@ -697,10 +697,24 @@ static PyMethodDef pysigar_module_methods[] = {
|
|||
#define PY_SIGAR_CONST_STR(name) \
|
||||
PyDict_SetItemString(dict, #name, o=PyString_FromString(SIGAR_##name)); Py_DECREF(o)
|
||||
|
||||
#define PY_SIGAR_DEFINE_CONST_STR(name, value) \
|
||||
PyDict_SetItemString(dict, name, o=PyString_FromString(value)); Py_DECREF(o)
|
||||
|
||||
static void init_pysigar_version(PyObject *dict)
|
||||
{
|
||||
PyObject *o;
|
||||
sigar_version_t *sv = sigar_version_get();
|
||||
PY_SIGAR_DEFINE_CONST_STR("BUILD_DATE", sv->build_date);
|
||||
PY_SIGAR_DEFINE_CONST_STR("SCM_REVISION", sv->scm_revision);
|
||||
PY_SIGAR_DEFINE_CONST_STR("VERSION", sv->version);
|
||||
}
|
||||
|
||||
static void init_pysigar_constants(PyObject *dict)
|
||||
{
|
||||
PyObject *o;
|
||||
|
||||
init_pysigar_version(dict);
|
||||
|
||||
PY_SIGAR_CONST_INT(FIELD_NOTIMPL);
|
||||
|
||||
PY_SIGAR_CONST_INT(IFF_UP);
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
#
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
from os import system, mkdir, path, popen
|
||||
from distutils.util import get_platform
|
||||
from distutils.sysconfig import get_config_var, get_python_version
|
||||
from os import system, mkdir, path, popen, rename
|
||||
import sys
|
||||
|
||||
build = 'build'
|
||||
|
@ -69,6 +71,18 @@ else :
|
|||
print "Inlining libsigar sources"
|
||||
src = sargs('inline_src -- ' + build)
|
||||
src.append('_sigar.c')
|
||||
|
||||
version_file = "sigar_version.c"
|
||||
build_version_file = build + "/" + version_file
|
||||
libname = "_sigar" + get_config_var("SO")
|
||||
filters = \
|
||||
'ARCHNAME=' + get_platform() + '-' + get_python_version() + ' ' + \
|
||||
'ARCHLIB=' + libname + ' ' + \
|
||||
'BINNAME=' + libname
|
||||
system(options['perl'] + ' -Mlib=.. -MSigarBuild -e version_file ' + filters)
|
||||
rename(version_file, build_version_file)
|
||||
src.append(build_version_file)
|
||||
|
||||
cppflags = sargs('cppflags')
|
||||
cppflags.append('-Wall')
|
||||
_sigar = Extension(
|
||||
|
|
Loading…
Reference in New Issue