diff --git a/.gitignore b/.gitignore index 060650d..03f99cc 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,3 @@ deb_dist .coverage coverage.xml pep8.txt -Pipfile -Pipfile.lock \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index b3825db..e34322f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,5 @@ language: python -python: -- 2.7 -env: -- DJANGO=">=1.6,<1.7" -- DJANGO=">=1.7,<1.8" -- DJANGO=">=1.8,<1.9" -- DJANGO=">=1.9,<1.10" -- DJANGO=">=1.10,<1.11" -- DJANGO=">=1.11,<1.12" install: -- pip install gitversion -- pip install "Django${DJANGO}" -- pip install . - pip install coveralls script: - python setup.py test @@ -19,9 +7,7 @@ after_success: - coveralls matrix: include: - - python: 2.6 - env: DJANGO=">=1.4,<1.5" - - python: 3.3 + - python: 3.4 env: DJANGO=">=1.8,<1.9" - python: 3.4 env: DJANGO=">=1.9,<1.10" @@ -33,14 +19,3 @@ matrix: env: DJANGO=">=1.8,<1.9" - python: pypy env: DJANGO=">=1.9,<1.10" -deploy: - provider: pypi - user: ocadotechnology - password: - secure: kdfRG0+3xsH4DSlTtVi8WT8/vhTzlfC58c0gP/MhsrN7k7ffGs6fjxkUoKpIGPZXV+v9kI5elYkFs4wInOrtq5ZgPHKMTpaHxQLrDtCkurYY7mD0e9KP2xVjvPEDQxDrynn1/x75Doi0Oe9StJ5E2odUJ0HcOwqhlKXJuOZa19M= - distributions: "bdist_wheel sdist" - on: - all_branches: true - repo: ocadotechnology/django-closuretree - tags: true - condition: "$DJANGO = '>=1.11,<1.12'" diff --git a/README.rst b/README.rst index a393c0a..fcee602 100644 --- a/README.rst +++ b/README.rst @@ -3,28 +3,20 @@ django-closuretree ****************** -.. image:: https://travis-ci.org/ocadotechnology/django-closuretree.svg - :target: https://travis-ci.org/ocadotechnology/django-closuretree +.. image:: https://travis-ci.com/ykiu/django-closuretree.svg?branch=master + :target: https://travis-ci.com/ykiu/django-closuretree :alt: Build Status -.. image:: https://landscape.io/github/ocadotechnology/django-closuretree/master/landscape.svg?style=flat - :target: https://landscape.io/github/ocadotechnology/django-closuretree/master - :alt: Code Health Badge -.. image:: https://readthedocs.org/projects/django-closuretree/badge/?version=latest - :target: http://django-closuretree.readthedocs.org/en/latest/ - :alt: Documentation Status -.. image:: https://coveralls.io/repos/ocadotechnology/django-closuretree/badge.svg - :target: https://coveralls.io/r/ocadotechnology/django-closuretree +.. image:: https://landscape.io/github/ykiu/django-closuretree/master/landscape.svg?style=flat + :target: https://landscape.io/github/ykiu/django-closuretree/master + :alt: Code Health +.. image:: https://coveralls.io/repos/github/ykiu/django-closuretree/badge.svg?branch=master + :target: https://coveralls.io/github/ykiu/django-closuretree?branch=master :alt: Test Coverage -.. image:: https://pypip.in/v/django-closuretree/badge.svg?style=flat - :target: https://pypi.python.org/pypi/django-closuretree/ - :alt: Version Badge -.. image:: https://pypip.in/license/django-closuretree/badge.svg?style=flat - :target: https://pypi.python.org/pypi/django-closuretree/ - :alt: License Badge - ``django-closuretree`` is an implementation of the `closure tree `_ technique for `Django `_ applications designed to provide efficient querying of `tree-based structures `_ in a relational database. Its goal is to reduce the number of queries required when querying the children or parents of a given object. +This is a folk of `the original work by Ocado Technology`_ with a few extra features. + Given the following model: .. code-block:: python @@ -60,7 +52,7 @@ A single query will obtain all the descendants. Quick Start =========== -* Install ``django-closuretree`` with ``pip install django-closuretree``. +* Install ``django-closuretree`` with ``pip install git+https://github.com/ykiu/django-closuretree.git``. * Inherit your models from ``closuretree.models.ClosureModel`` instead of ``django.db.models.Model``. That's it. You can now use ``get_descendants()`` and ``get_ancestors()`` on a model instance. @@ -75,14 +67,9 @@ If you're adding this to an existing application that already has data in the da Contributing ============ -The following workflow assumes you are using pipenv. - 1. Fork the repo and create your branch from master. -2. Enter into a virtual environment (``pipenv shell``). -3. Install gitversion (``pipenv install gitversion``). -4. Install the remaining dependencies (``setup.py install``). -5. Do your work. -6. Run tests (``setup.py test``). -7. Make a PR. +2. Do your work. +3. Run tests (``setup.py test``). Dependencies will be installed into `./.eggs/`. No need to explicitly activate a virtual environment. +4. Make a PR. We ask that contributors adhere to `PEP8 `_ standards, and include full tests for all their code. diff --git a/closuretree/version.py b/closuretree/version.py index 5e136d0..e9e2596 100644 --- a/closuretree/version.py +++ b/closuretree/version.py @@ -1,2 +1,7 @@ -from gitversion import rewritable_git_version -__VERSION__ = rewritable_git_version(__file__) +from pkg_resources import get_distribution, DistributionNotFound + +try: + __VERSION__ = get_distribution(__name__).version +except DistributionNotFound: + # package is not installed + pass diff --git a/run_tests.py b/run_tests.py deleted file mode 100644 index b515343..0000000 --- a/run_tests.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python -import os -import sys - -import django -from django.conf import settings -from django.test.utils import get_runner - -if __name__ == "__main__": - django.setup() - TestRunner = get_runner(settings) - test_runner = TestRunner() - failures = test_runner.run_tests(["closuretree"]) - sys.exit(bool(failures)) \ No newline at end of file diff --git a/setup.py b/setup.py index 9ca8de5..caaaa7b 100755 --- a/setup.py +++ b/setup.py @@ -12,26 +12,40 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Setup file for django-closuretree.""" -from setuptools import setup, find_packages +"""Setup file for django-closuretree. -from closuretree.version import __VERSION__ +See also: +https://packaging.python.org/en/latest/distributing.html +https://github.com/pypa/sampleproject +""" +from setuptools import setup, find_packages setup( name='django-closuretree', - version=__VERSION__, + + # getting version info from git tags + use_scm_version = True, + # (the following will be installed into ./.eggs/) + setup_requires=['setuptools_scm'], + + # specifying packages to install packages=find_packages(), + + # dependencies + # (the following will be installed into ./.eggs/) + install_requires=['django >= 1.8, < 2.0'], + + # test + # (the following will be installed into ./.eggs/) + tests_require=['django-setuptest >= 0.2'], + test_suite='setuptest.setuptest.SetupTestSuite', + + # meta data author='Mike Bryant', author_email='mike.bryant@ocado.com', description='Efficient tree-based datastructure for Django', long_description=open('README.rst').read(), url='https://github.com/ocadotechnology/django-closuretree/', - install_requires=[ - 'django >= 1.4, < 1.12', - 'django-autoconfig', - ], - tests_require=['django-setuptest >= 0.2'], - test_suite='setuptest.setuptest.SetupTestSuite', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Framework :: Django', @@ -39,7 +53,6 @@ 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', diff --git a/test_settings.py b/test_settings.py index 5cbcb33..f07003b 100644 --- a/test_settings.py +++ b/test_settings.py @@ -18,5 +18,4 @@ }, } INSTALLED_APPS = ['closuretree'] -ROOT_URLCONF = 'django_autoconfig.autourlconf' SECRET_KEY = 'foobar'