Added murmur3.__version__

This commit is contained in:
Cameron Eure 2012-10-08 13:44:19 -07:00
commit 19306a118f
3 changed files with 19 additions and 6 deletions

View file

@ -1,5 +1,6 @@
#include <Python.h> #include <Python.h>
#include "MurmurHash3.h" #include "MurmurHash3.h"
#include "version.py"
static PyObject *hash32(PyObject *, PyObject *); static PyObject *hash32(PyObject *, PyObject *);
static PyObject *hash128(PyObject *, PyObject *); static PyObject *hash128(PyObject *, PyObject *);
@ -145,12 +146,16 @@ static PyObject *hash128_64(PyObject *self, PyObject *args)
#if PY_MAJOR_VERSION <= 2 #if PY_MAJOR_VERSION <= 2
/* Python 1.x/2.x */ /* Python 1.x/2.x */
extern "C" extern "C" PyMODINIT_FUNC
PyMODINIT_FUNC
initmurmur3(void) initmurmur3(void)
{ {
//Py_Initialize(); //Py_Initialize();
(void) Py_InitModule3("murmur3", methods, (char *)documentation); PyObject *module;
module = Py_InitModule3("murmur3", methods, (char *)documentation);
if (!module) return;
PyModule_AddStringConstant(module, "__version__", MODULE_VERSION);
} }
#else #else
/* Python 3.x */ /* Python 3.x */
@ -167,13 +172,15 @@ static PyObject *hash128_64(PyObject *self, PyObject *args)
NULL NULL
}; };
extern "C" extern "C" PyMODINIT_FUNC
PyMODINIT_FUNC
PyInit_murmur3(void) PyInit_murmur3(void)
{ {
PyObject *module; PyObject *module;
module = PyModule_Create(&murmur3_module); module = PyModule_Create(&murmur3_module);
if (!module) return module;
PyModule_AddStringConstant(module, "__version__", MODULE_VERSION);
return module; return module;
} }
#endif #endif

View file

@ -1,8 +1,9 @@
from distutils.core import setup, Extension from distutils.core import setup, Extension
import version
setup( setup(
name = 'murmur3', name = 'murmur3',
version = '0.2', version = version.MODULE_VERSION,
ext_modules = [ ext_modules = [
Extension('murmur3', ['module.cpp', 'MurmurHash3.cpp'],), Extension('murmur3', ['module.cpp', 'MurmurHash3.cpp'],),
], ],

5
version.py Normal file
View file

@ -0,0 +1,5 @@
#ifndef __FILE__
MODULE_VERSION = "0.2.0"
#else
#define MODULE_VERSION "0.2.0"
#endif