Skip to content

Commit

Permalink
Fix #46: Add __version__
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashaag committed Mar 12, 2022
1 parent c4411ae commit 1e07464
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
20 changes: 11 additions & 9 deletions src/snappy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from __future__ import absolute_import

from .snappy import (
compress,
decompress,
uncompress,
stream_compress,
stream_decompress,
StreamCompressor,
StreamDecompressor,
UncompressError,
isValidCompressed,
compress,
decompress,
uncompress,
stream_compress,
stream_decompress,
StreamCompressor,
StreamDecompressor,
UncompressError,
isValidCompressed,
)

from .hadoop_snappy import (
stream_compress as hadoop_stream_compress,
stream_decompress as hadoop_stream_decompress,
)

__version__ = '0.6.1'
5 changes: 0 additions & 5 deletions src/snappy/snappymodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <snappy-c.h>
#include "crc32c.h"

#define MODULE_VERSION "0.4.1"
#define RESIZE_TOLERATION 0.75

struct module_state {
Expand Down Expand Up @@ -306,10 +305,6 @@ init_snappy(void)
SnappyInvalidCompressedInputError);
PyModule_AddObject(m, "CompressedLengthError", SnappyCompressedLengthError);

/* Version = MODULE_VERSION */
if (PyModule_AddStringConstant(m, "__version__", MODULE_VERSION))
INITERROR;

#if PY_MAJOR_VERSION >= 3
return m;
#endif
Expand Down
9 changes: 9 additions & 0 deletions test_snappy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
from unittest import TestCase


class SnappyModuleTest(TestCase):
def test_version(self):
assert tuple(map(int, snappy.__version__.split("."))) >= (0, 6, 1)
# Make sure that __version__ is identical to the version defined in setup.py
with open(os.path.join(os.path.dirname(__file__), "setup.py")) as f:
version_line, = (l for l in f.read().splitlines() if l.startswith("version"))
assert version_line.split("=")[1].strip(" '\"") == snappy.__version__


class SnappyCompressionTest(TestCase):
def test_simple_compress(self):
text = "hello world!".encode('utf-8')
Expand Down

0 comments on commit 1e07464

Please sign in to comment.