diff options
author | Alexander Shorin <kxepal@gmail.com> | 2011-12-25 22:27:02 +0400 |
---|---|---|
committer | Alexander Shorin <kxepal@gmail.com> | 2011-12-25 22:27:02 +0400 |
commit | 30a61e17a1cb3c2a582429caf793d38d92f9c655 (patch) | |
tree | 83106004b0c252bd7fe62fe8b3adfcd94df4b98d | |
parent | 99f71983e7540ebcc7ccfa138064347068cf3524 (diff) | |
download | python-json-patch-30a61e17a1cb3c2a582429caf793d38d92f9c655.tar.gz |
Add support of Python 2.4 and 2.5 with simplejson.
-rw-r--r-- | jsonpatch.py | 6 | ||||
-rw-r--r-- | setup.py | 24 |
2 files changed, 28 insertions, 2 deletions
diff --git a/jsonpatch.py b/jsonpatch.py index 8ab5278..c82b692 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -39,8 +39,12 @@ __version__ = '0.1' __website__ = 'https://github.com/stefankoegl/python-json-patch' __license__ = 'Modified BSD License' +import sys -import json +if sys.version_info < (2, 6): + import simplejson as json +else: + import json class JsonPatchException(Exception): @@ -1,7 +1,14 @@ #!/usr/bin/env python -from distutils.core import setup +import sys import re +import warnings +try: + from setuptools import setup + has_setuptools = True +except ImportError: + from distutils.core import setup + has_setuptools = False src = open('jsonpatch.py').read() metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", src)) @@ -13,6 +20,20 @@ MODULES = ( 'jsonpatch', ) +REQUIREMENTS = [] +if sys.version_info < (2, 6): + REQUIREMENTS += ['simplejson'] + +if has_setuptools: + OPTIONS = { + 'install_requires': REQUIREMENTS + } +else: + if sys.version_info < (2, 6): + warnings.warn('No setuptools installed. Be sure that you have ' + 'json or simplejson package installed') + OPTIONS = {} + AUTHOR_EMAIL = metadata['author'] VERSION = metadata['version'] WEBSITE = metadata['website'] @@ -30,4 +51,5 @@ setup(name=PACKAGE, license=LICENSE, url=WEBSITE, py_modules=MODULES, + **OPTIONS ) |