You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by te...@apache.org on 2012/10/06 17:37:20 UTC

svn commit: r1395098 - in /avro/trunk/lang/py: setup.py src/avro/datafile.py

Author: tebeka
Date: Sat Oct  6 15:37:19 2012
New Revision: 1395098

URL: http://svn.apache.org/viewvc?rev=1395098&view=rev
Log:
AVRO-981. Python. Make snappy optional package

Modified:
    avro/trunk/lang/py/setup.py
    avro/trunk/lang/py/src/avro/datafile.py

Modified: avro/trunk/lang/py/setup.py
URL: http://svn.apache.org/viewvc/avro/trunk/lang/py/setup.py?rev=1395098&r1=1395097&r2=1395098&view=diff
==============================================================================
--- avro/trunk/lang/py/setup.py (original)
+++ avro/trunk/lang/py/setup.py Sat Oct  6 15:37:19 2012
@@ -21,7 +21,7 @@ except ImportError:
   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 @@ setup(
   license = 'Apache License 2.0',
   keywords = 'avro serialization rpc',
   url = 'http://hadoop.apache.org/avro',
+  extras_require = {
+    'snappy': ['python-snappy'],
+  },
 )

Modified: avro/trunk/lang/py/src/avro/datafile.py
URL: http://svn.apache.org/viewvc/avro/trunk/lang/py/src/avro/datafile.py?rev=1395098&r1=1395097&r2=1395098&view=diff
==============================================================================
--- avro/trunk/lang/py/src/avro/datafile.py (original)
+++ avro/trunk/lang/py/src/avro/datafile.py Sat Oct  6 15:37:19 2012
@@ -25,8 +25,9 @@ from avro import schema
 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 @@ META_SCHEMA = schema.parse("""\
    {"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"