Skip to content

Commit 7adfb66

Browse files
martindurantewianda
authored andcommitted
Merge pull request intake#119 from jonashaag/master
Fix intake#46: Add __version__
2 parents c4411ae + 1e07464 commit 7adfb66

File tree

5 files changed

+72
-55
lines changed

5 files changed

+72
-55
lines changed

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CIBW_BUILD=cp311-* CIBW_SKIP=*musllinux* CIBW_BEFORE_ALL="bash build_snappy.sh" CIBW_BEFORE_ALL_LINUX="yum install -y snappy-devel" CIBW_BEFORE_ALL_MACOS="brew install snappy" CIBW_ARCHS_MACOS="auto" pipx run cibuildwheel --output-dir dist

setup.py

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,79 +24,89 @@
2424
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525

2626
import sys
27+
2728
try:
28-
from setuptools import setup, Extension
29+
from setuptools import Extension, setup
2930
except ImportError:
3031
from distutils.core import setup, Extension
3132

3233
import os
3334

34-
version = '0.6.1'
35+
version = "0.6.1"
3536
long_description = """
3637
Python bindings for the snappy compression library from Google.
3738
3839
More details about Snappy library: http://google.github.io/snappy
3940
"""
4041

4142
library_dirs, include_dirs = [], []
42-
if os.environ.get("CIBUILDWHEEL", False) and sys.version_info[:2] == (3, 9) and sys.platform =="darwin":
43+
if (
44+
os.environ.get("CIBUILDWHEEL", False)
45+
and sys.version_info[:2] == (3, 9)
46+
and sys.platform == "darwin"
47+
):
4348
library_dirs = ["/usr/local/lib/"]
4449
include_dirs = ["/usr/local/include/"]
4550

4651

47-
snappymodule = Extension('snappy._snappy',
48-
libraries=['snappy'],
49-
sources=['src/snappy/snappymodule.cc', 'src/snappy/crc32c.c'],
50-
library_dirs=library_dirs,
51-
include_dirs=include_dirs)
52+
snappymodule = Extension(
53+
"snappy._snappy",
54+
libraries=["snappy"],
55+
sources=["src/snappy/snappymodule.cc", "src/snappy/crc32c.c"],
56+
library_dirs=library_dirs,
57+
include_dirs=include_dirs,
58+
)
5259

5360
ext_modules = [snappymodule]
54-
packages = ['snappy']
61+
packages = ["snappy"]
5562
install_requires = []
5663
setup_requires = []
5764
cffi_modules = []
5865

59-
if 'PyPy' in sys.version:
66+
if "PyPy" in sys.version:
6067
from setuptools import setup
68+
6169
ext_modules = []
62-
install_requires = ['cffi>=1.15.0']
63-
setup_requires = ['cffi>=1.15.0']
64-
cffi_modules = ['./src/snappy/snappy_cffi_builder.py:ffi']
70+
install_requires = ["cffi>=1.15.0"]
71+
setup_requires = ["cffi>=1.15.0"]
72+
cffi_modules = ["./src/snappy/snappy_cffi_builder.py:ffi"]
6573

6674
setup(
67-
name='python-snappy',
75+
name="python-snappy",
6876
version=version,
69-
author='Andres Moreira',
70-
author_email='[email protected]',
71-
url='http://github.com/andrix/python-snappy',
72-
description='Python library for the snappy compression library from Google',
77+
author="Andres Moreira",
78+
author_email="[email protected]",
79+
url="http://github.com/andrix/python-snappy",
80+
description="Python library for the snappy compression library from Google",
7381
long_description=long_description,
74-
keywords='snappy, compression, google',
75-
license='BSD',
76-
classifiers=['Development Status :: 4 - Beta',
77-
'Topic :: Internet',
78-
'Topic :: Software Development',
79-
'Topic :: Software Development :: Libraries',
80-
'Topic :: System :: Archiving :: Compression',
81-
'License :: OSI Approved :: BSD License',
82-
'Intended Audience :: Developers',
83-
'Intended Audience :: System Administrators',
84-
'Operating System :: MacOS :: MacOS X',
85-
# 'Operating System :: Microsoft :: Windows', -- Not tested yet
86-
'Operating System :: POSIX',
87-
'Programming Language :: Python :: 2.7',
88-
'Programming Language :: Python :: 3',
89-
'Programming Language :: Python :: 3.5',
90-
'Programming Language :: Python :: 3.6',
91-
'Programming Language :: Python :: 3.7',
92-
'Programming Language :: Python :: 3.8',
93-
'Programming Language :: Python :: 3.9',
94-
'Programming Language :: Python :: 3.10'
95-
],
82+
keywords="snappy, compression, google",
83+
license="BSD",
84+
classifiers=[
85+
"Development Status :: 4 - Beta",
86+
"Topic :: Internet",
87+
"Topic :: Software Development",
88+
"Topic :: Software Development :: Libraries",
89+
"Topic :: System :: Archiving :: Compression",
90+
"License :: OSI Approved :: BSD License",
91+
"Intended Audience :: Developers",
92+
"Intended Audience :: System Administrators",
93+
"Operating System :: MacOS :: MacOS X",
94+
# 'Operating System :: Microsoft :: Windows', -- Not tested yet
95+
"Operating System :: POSIX",
96+
"Programming Language :: Python :: 2.7",
97+
"Programming Language :: Python :: 3",
98+
"Programming Language :: Python :: 3.5",
99+
"Programming Language :: Python :: 3.6",
100+
"Programming Language :: Python :: 3.7",
101+
"Programming Language :: Python :: 3.8",
102+
"Programming Language :: Python :: 3.9",
103+
"Programming Language :: Python :: 3.10"
104+
"Programming Language :: Python :: 3.11",
105+
],
96106
ext_modules=ext_modules,
97107
packages=packages,
98108
install_requires=install_requires,
99109
setup_requires=setup_requires,
100110
cffi_modules=cffi_modules,
101-
package_dir={'': 'src'},
111+
package_dir={"": "src"},
102112
)

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)