From e2a604f7ebc230e811ec6af15ac20551553b8a81 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 15 Mar 2015 11:45:34 -0400 Subject: [PATCH] Switch to vcversioner, use repoze.lru only on 2.6, and add extras_require for format. --- .gitignore | 23 ++--------------------- MANIFEST.in | 1 + jsonschema/__init__.py | 2 +- jsonschema/compat.py | 7 ++++++- jsonschema/version.py | 1 - setup.py | 28 +++++++++++++++------------- tox.ini | 6 ++---- 7 files changed, 27 insertions(+), 41 deletions(-) delete mode 100644 jsonschema/version.py diff --git a/.gitignore b/.gitignore index 4ea7454..a4dc846 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,7 @@ -.DS_Store -.idea - -*.pyc -*.pyo - -*.egg-info -_build -build -dist -MANIFEST - -.coverage -.coveragerc -coverage -htmlcov - _cache _static _templates -_trial_temp - -.tox - TODO + +jsonschema/_version.py diff --git a/MANIFEST.in b/MANIFEST.in index a951c8a..a122503 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include *.rst include COPYING include tox.ini +include version.txt recursive-include json * diff --git a/jsonschema/__init__.py b/jsonschema/__init__.py index e23168d..baf1d89 100644 --- a/jsonschema/__init__.py +++ b/jsonschema/__init__.py @@ -19,6 +19,6 @@ from jsonschema.validators import ( Draft3Validator, Draft4Validator, RefResolver, validate ) -from jsonschema.version import __version__ +from jsonschema._version import __version__ # flake8: noqa diff --git a/jsonschema/compat.py b/jsonschema/compat.py index 9f52ded..8ea8d31 100644 --- a/jsonschema/compat.py +++ b/jsonschema/compat.py @@ -10,6 +10,7 @@ except ImportError: from collections.abc import MutableMapping, Sequence # noqa PY3 = sys.version_info[0] >= 3 +PY26 = sys.version_info[:2] == (2, 6) if PY3: zip = zip @@ -24,7 +25,6 @@ if PY3: iteritems = operator.methodcaller("items") else: from itertools import izip as zip # noqa - from repoze.lru import lru_cache from StringIO import StringIO from urlparse import ( urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit # noqa @@ -35,6 +35,11 @@ else: int_types = int, long iteritems = operator.methodcaller("iteritems") + if PY26: + from repoze.lru import lru_cache + else: + from functools32 import lru_cache + # On python < 3.3 fragments are not handled properly with unknown schemes def urlsplit(url): diff --git a/jsonschema/version.py b/jsonschema/version.py deleted file mode 100644 index 9509105..0000000 --- a/jsonschema/version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "2.5.0-dev" diff --git a/setup.py b/setup.py index ffd61f1..bbd2b2e 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,10 @@ -import os.path -from setuptools import setup +import os import sys -# Load __version__ info globals without importing anything -with open( - os.path.join(os.path.dirname(__file__), 'jsonschema', 'version.py') -) as fh: - exec(fh.read()) +from setuptools import setup -with open("README.rst") as readme: + +with open(os.path.join(os.path.dirname(__file__), "README.rst")) as readme: long_description = readme.read() classifiers = [ @@ -26,16 +22,22 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] -install_requires = [] -if sys.version_info < (3, 2): - install_requires.append('repoze.lru >= 0.6') +extras_require = {"format" : ["rfc3987", "strict-rfc3339", "webcolors"]} +if sys.version_info[:2] == (2, 6): + install_requires = ["argparse", "repoze.lru"] +elif sys.version_info[:2] == (2, 7): + install_requires = ["functools32"] +else: + install_requires = [] setup( name="jsonschema", - version=__version__, packages=["jsonschema", "jsonschema.tests"], package_data={"jsonschema": ["schemas/*.json"]}, + setup_requires=["vcversioner"], + install_requires=install_requires, + extras_require=extras_require, author="Julian Berman", author_email="Julian@GrayVines.com", classifiers=classifiers, @@ -44,5 +46,5 @@ setup( long_description=long_description, url="http://github.com/Julian/jsonschema", entry_points={"console_scripts": ["jsonschema = jsonschema.cli:main"]}, - install_requires=install_requires, + vcversioner={"version_module_paths" : ["jsonschema/_version.py"]}, ) diff --git a/tox.ini b/tox.ini index d267bd3..e3c69cf 100644 --- a/tox.ini +++ b/tox.ini @@ -10,11 +10,9 @@ commands = py{26,27,34,py}: sphinx-build -b doctest {toxinidir}/docs {envtmpdir}/html deps = pytest - strict-rfc3339 - webcolors - py{27,34,py,py3}: rfc3987 - py26: argparse + -e{toxinidir}[format] + py26: unittest2 py{26,27,py,py3}: mock