Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

AVRO-981. Python. Make snappy optional package

git-svn-id: https://svn.apache.org/repos/asf/avro/trunk@1395098 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 01f774f28153d220f59bff026ade4982d20ace2d 1 parent f920d4e
Miki Tebeka authored
Showing with 10 additions and 4 deletions.
  1. +4 −1 lang/py/setup.py
  2. +6 −3 lang/py/src/avro/datafile.py
View
5 lang/py/setup.py
@@ -21,7 +21,7 @@
from distutils.core import setup
from sys import version_info
-install_requires = ['python-snappy']
+install_requires = []
if version_info[:2] <= (2, 5):
install_requires.append('simplejson >= 2.0.9')
@@ -43,4 +43,7 @@
license = 'Apache License 2.0',
keywords = 'avro serialization rpc',
url = 'http://hadoop.apache.org/avro',
+ extras_require = {
+ 'snappy': ['python-snappy'],
+ },
)
View
9 lang/py/src/avro/datafile.py
@@ -25,8 +25,9 @@
from avro import io
try:
import snappy
-except:
- pass # fail later if snappy is used
+ has_snappy = True
+except ImportError:
+ has_snappy = False
#
# Constants
#
@@ -43,7 +44,9 @@
{"name": "meta", "type": {"type": "map", "values": "bytes"}},
{"name": "sync", "type": {"type": "fixed", "name": "sync", "size": %d}}]}
""" % (MAGIC_SIZE, SYNC_SIZE))
-VALID_CODECS = ['null', 'deflate', 'snappy']
+VALID_CODECS = ['null', 'deflate']
+if has_snappy:
+ VALID_CODECS.append('snappy')
VALID_ENCODINGS = ['binary'] # not used yet
CODEC_KEY = "avro.codec"
Please sign in to comment.
Something went wrong with that request. Please try again.