Add support of Python 2.4 and 2.5 with simplejson.
This commit is contained in:
@@ -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):
|
||||
|
||||
24
setup.py
24
setup.py
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user