Skip to content

Commit 1e07464

Browse files
committed
Fix intake#46: Add __version__
1 parent c4411ae commit 1e07464

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

src/snappy/__init__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
from __future__ import absolute_import
22

33
from .snappy import (
4-
compress,
5-
decompress,
6-
uncompress,
7-
stream_compress,
8-
stream_decompress,
9-
StreamCompressor,
10-
StreamDecompressor,
11-
UncompressError,
12-
isValidCompressed,
4+
compress,
5+
decompress,
6+
uncompress,
7+
stream_compress,
8+
stream_decompress,
9+
StreamCompressor,
10+
StreamDecompressor,
11+
UncompressError,
12+
isValidCompressed,
1313
)
1414

1515
from .hadoop_snappy import (
1616
stream_compress as hadoop_stream_compress,
1717
stream_decompress as hadoop_stream_decompress,
1818
)
19+
20+
__version__ = '0.6.1'

src/snappy/snappymodule.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
#include <snappy-c.h>
3434
#include "crc32c.h"
3535

36-
#define MODULE_VERSION "0.4.1"
3736
#define RESIZE_TOLERATION 0.75
3837

3938
struct module_state {
@@ -306,10 +305,6 @@ init_snappy(void)
306305
SnappyInvalidCompressedInputError);
307306
PyModule_AddObject(m, "CompressedLengthError", SnappyCompressedLengthError);
308307

309-
/* Version = MODULE_VERSION */
310-
if (PyModule_AddStringConstant(m, "__version__", MODULE_VERSION))
311-
INITERROR;
312-
313308
#if PY_MAJOR_VERSION >= 3
314309
return m;
315310
#endif

test_snappy.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535
from unittest import TestCase
3636

3737

38+
class SnappyModuleTest(TestCase):
39+
def test_version(self):
40+
assert tuple(map(int, snappy.__version__.split("."))) >= (0, 6, 1)
41+
# Make sure that __version__ is identical to the version defined in setup.py
42+
with open(os.path.join(os.path.dirname(__file__), "setup.py")) as f:
43+
version_line, = (l for l in f.read().splitlines() if l.startswith("version"))
44+
assert version_line.split("=")[1].strip(" '\"") == snappy.__version__
45+
46+
3847
class SnappyCompressionTest(TestCase):
3948
def test_simple_compress(self):
4049
text = "hello world!".encode('utf-8')

0 commit comments

Comments
 (0)