Skip to content

Commit

Permalink
Merge pull request intake#119 from jonashaag/master
Browse files Browse the repository at this point in the history
Fix intake#46: Add __version__
  • Loading branch information
martindurant authored and ewianda committed Oct 22, 2023
2 parents c4411ae + 1e07464 commit fc9ce38
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 55 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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" pipx run cibuildwheel --output-dir dist
92 changes: 51 additions & 41 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,79 +24,89 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sys

try:
from setuptools import setup, Extension
from setuptools import Extension, setup
except ImportError:
from distutils.core import setup, Extension

import os

version = '0.6.1'
version = "0.6.1"
long_description = """
Python bindings for the snappy compression library from Google.
More details about Snappy library: http://google.github.io/snappy
"""

library_dirs, include_dirs = [], []
if os.environ.get("CIBUILDWHEEL", False) and sys.version_info[:2] == (3, 9) and sys.platform =="darwin":
if (
os.environ.get("CIBUILDWHEEL", False)
and sys.version_info[:2] == (3, 9)
and sys.platform == "darwin"
):
library_dirs = ["/usr/local/lib/"]
include_dirs = ["/usr/local/include/"]


snappymodule = Extension('snappy._snappy',
libraries=['snappy'],
sources=['src/snappy/snappymodule.cc', 'src/snappy/crc32c.c'],
library_dirs=library_dirs,
include_dirs=include_dirs)
snappymodule = Extension(
"snappy._snappy",
libraries=["snappy"],
sources=["src/snappy/snappymodule.cc", "src/snappy/crc32c.c"],
library_dirs=library_dirs,
include_dirs=include_dirs,
)

ext_modules = [snappymodule]
packages = ['snappy']
packages = ["snappy"]
install_requires = []
setup_requires = []
cffi_modules = []

if 'PyPy' in sys.version:
if "PyPy" in sys.version:
from setuptools import setup

ext_modules = []
install_requires = ['cffi>=1.15.0']
setup_requires = ['cffi>=1.15.0']
cffi_modules = ['./src/snappy/snappy_cffi_builder.py:ffi']
install_requires = ["cffi>=1.15.0"]
setup_requires = ["cffi>=1.15.0"]
cffi_modules = ["./src/snappy/snappy_cffi_builder.py:ffi"]

setup(
name='python-snappy',
name="python-snappy",
version=version,
author='Andres Moreira',
author_email='andres@andresmoreira.com',
url='http://github.com/andrix/python-snappy',
description='Python library for the snappy compression library from Google',
author="Andres Moreira",
author_email="andres@andresmoreira.com",
url="http://github.com/andrix/python-snappy",
description="Python library for the snappy compression library from Google",
long_description=long_description,
keywords='snappy, compression, google',
license='BSD',
classifiers=['Development Status :: 4 - Beta',
'Topic :: Internet',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
'Topic :: System :: Archiving :: Compression',
'License :: OSI Approved :: BSD License',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Operating System :: MacOS :: MacOS X',
# 'Operating System :: Microsoft :: Windows', -- Not tested yet
'Operating System :: POSIX',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'
],
keywords="snappy, compression, google",
license="BSD",
classifiers=[
"Development Status :: 4 - Beta",
"Topic :: Internet",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Archiving :: Compression",
"License :: OSI Approved :: BSD License",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Operating System :: MacOS :: MacOS X",
# 'Operating System :: Microsoft :: Windows', -- Not tested yet
"Operating System :: POSIX",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10"
"Programming Language :: Python :: 3.11",
],
ext_modules=ext_modules,
packages=packages,
install_requires=install_requires,
setup_requires=setup_requires,
cffi_modules=cffi_modules,
package_dir={'': 'src'},
package_dir={"": "src"},
)
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 fc9ce38

Please sign in to comment.