| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#include <Python.h> |
| 33 |
|
| 34 |
#include <stdlib.h> |
| 35 |
#include <lz4.h> |
| 36 |
#include <lz4hc.h> |
| 37 |
|
| 38 |
static PyObject * |
| 39 |
library_version_number (PyObject * Py_UNUSED (self), PyObject * Py_UNUSED (args)) |
| 40 |
{ |
| 41 |
return Py_BuildValue ("i", LZ4_versionNumber ()); |
| 42 |
} |
| 43 |
|
| 44 |
static PyObject * |
| 45 |
library_version_string (PyObject * Py_UNUSED (self), PyObject * Py_UNUSED (args)) |
| 46 |
{ |
| 47 |
return Py_BuildValue ("s", LZ4_versionString ()); |
| 48 |
} |
| 49 |
|
| 50 |
PyDoc_STRVAR |
| 51 |
( |
| 52 |
library_version_number__doc, |
| 53 |
"library_version_number()\n\n" \ |
| 54 |
"Returns the version number of the LZ4 library.\n" \ |
| 55 |
"\n" \ |
| 56 |
"Args:\n" \ |
| 57 |
" None\n" \ |
| 58 |
"\n" \ |
| 59 |
"Returns:\n" \ |
| 60 |
" int: version number eg. 10705" |
| 61 |
); |
| 62 |
|
| 63 |
PyDoc_STRVAR |
| 64 |
( |
| 65 |
library_version_string__doc, |
| 66 |
"library_version_string()\n\n" \ |
| 67 |
"Returns the version number of the LZ4 library as a string\n" \ |
| 68 |
"containing the semantic version.\n" \ |
| 69 |
"\n" \ |
| 70 |
"Args:\n" \ |
| 71 |
" None\n" \ |
| 72 |
"\n" \ |
| 73 |
"Returns:\n" \ |
| 74 |
" str: version number eg. \"1.7.5\"" |
| 75 |
); |
| 76 |
|
| 77 |
static PyMethodDef module_methods[] = { |
| 78 |
{ |
| 79 |
"library_version_number", |
| 80 |
(PyCFunction) library_version_number, |
| 81 |
METH_VARARGS, |
| 82 |
library_version_number__doc |
| 83 |
}, |
| 84 |
{ |
| 85 |
"library_version_string", |
| 86 |
(PyCFunction) library_version_string, |
| 87 |
METH_VARARGS, |
| 88 |
library_version_string__doc |
| 89 |
}, |
| 90 |
{ |
| 91 |
|
| 92 |
NULL, |
| 93 |
NULL, |
| 94 |
0, |
| 95 |
NULL |
| 96 |
} |
| 97 |
}; |
| 98 |
|
| 99 |
static struct PyModuleDef moduledef = |
| 100 |
{ |
| 101 |
PyModuleDef_HEAD_INIT, |
| 102 |
"_version", |
| 103 |
NULL, |
| 104 |
-1, |
| 105 |
module_methods |
| 106 |
}; |
| 107 |
|
| 108 |
PyMODINIT_FUNC |
| 109 |
PyInit__version(void) |
| 110 |
{ |
| 111 |
PyObject *module = PyModule_Create (&moduledef); |
| 112 |
|
| 113 |
if (module == NULL) |
| 114 |
return NULL; |
| 115 |
|
| 116 |
#ifdef Py_GIL_DISABLED |
| 117 |
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED); |
| 118 |
#endif |
| 119 |
|
| 120 |
return module; |
| 121 |
} |