From c0fcca0c7d128a5c7edf3e6e293490552ec80d78 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Tue, 2 Jan 2018 16:12:56 +0200 Subject: [PATCH 01/10] Update supported Django / Python versions We now support Django 1.8, 1.11, 2.0, and Python 3.4, 3.5, 3.6 Bump package version to 0.3.0 --- .travis.yml | 17 ++++++++++------- HISTORY.rst | 8 ++++++++ docs/conf.py | 2 +- setup.py | 2 +- tg_utils/__init__.py | 2 +- tg_utils/models.py | 4 ++-- tox.ini | 5 +++-- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 06890b7..c2b1445 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,18 @@ language: python python: - - "3.5" + - "3.6" env: - - TOX_ENV=py35-django18 - - TOX_ENV=py35-django19 - TOX_ENV=py34-django18 - - TOX_ENV=py34-django19 - - TOX_ENV=py27-django18 - - TOX_ENV=py27-django19 + - TOX_ENV=py34-django111 + - TOX_ENV=py34-django20 + - TOX_ENV=py35-django18 + - TOX_ENV=py35-django111 + - TOX_ENV=py35-django20 + - TOX_ENV=py36-django18 + - TOX_ENV=py36-django111 + - TOX_ENV=py36-django20 - TOX_ENV=lint - TOX_ENV=coverage - TOX_ENV=docs @@ -23,7 +26,7 @@ script: jobs: include: - stage: deploy - env: TOX_ENV=py35-django19 + env: TOX_ENV=py36-django20 deploy: provider: pypi user: thorgate diff --git a/HISTORY.rst b/HISTORY.rst index 9dcd7a1..c4052f4 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,14 @@ History ======= +0.3.0 (2018-01-02) +------------------ + +* Supported Django versions are now 1.8, 1.11, and 2.0. + `ClosableModel.created_by` and `closed_by` now have `on_delete=models.SET_NULL` attribute. +* Supported Python versions are now 3.4, 3.5, and 3.6. + + 0.2.0 (2016-01-27) ------------------ diff --git a/docs/conf.py b/docs/conf.py index 55ec7e2..dab7303 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,7 +60,7 @@ # General information about the project. project = u'tg-utils' -copyright = u'2016, Thorgate' +copyright = u'2018, Thorgate' # The version info for the project you're documenting, acts as replacement # for |version| and |release|, also used in various other places throughout diff --git a/setup.py b/setup.py index 712f627..7695c5c 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ history = history_file.read() requirements = [ - 'django>=1.8,<1.10', + 'django>=1.8,<2.1', ] setup( diff --git a/tg_utils/__init__.py b/tg_utils/__init__.py index 3b1e189..15a098e 100644 --- a/tg_utils/__init__.py +++ b/tg_utils/__init__.py @@ -2,4 +2,4 @@ __author__ = 'Thorgate' __email__ = 'code@thorgate.eu' -__version__ = '0.2.0' +__version__ = '0.3.0' diff --git a/tg_utils/models.py b/tg_utils/models.py index 002b1cc..9974236 100644 --- a/tg_utils/models.py +++ b/tg_utils/models.py @@ -12,10 +12,10 @@ class ClosableModel(models.Model): Also provides default manager that automatically filters queryset to only include active (non-closed) items plus a .close() function to mark objects as closed. """ - created_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='+', null=True, blank=True) + created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', null=True, blank=True) created_at = models.DateTimeField(default=timezone.now) - closed_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='+', null=True, blank=True) + closed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', null=True, blank=True) closed_at = models.DateTimeField(null=True, blank=True) all_objects = models.Manager() diff --git a/tox.ini b/tox.ini index 0b91d5e..dd26f1e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{27,34,35}-django{18,19} +envlist = py{34,35,36}-django{18,111,20} [testenv] setenv = @@ -8,5 +8,6 @@ whitelist_externals = make commands = make test deps = django18: Django>=1.8,<1.9 - django19: Django>=1.9,<1.10 + django111: Django>=1.11,<1.12 + django20: Django>=2.0,<2.1 -r{toxinidir}/requirements_test.txt From d9a9fa501eaa57328efd528e41b4103185b8347a Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Tue, 2 Jan 2018 17:02:26 +0200 Subject: [PATCH 02/10] Try to fix Travis builds --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index c2b1445..bcafc1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,10 @@ env: - TOX_ENV=coverage - TOX_ENV=docs +before_install: +# For reasons: https://github.com/travis-ci/travis-ci/issues/4990 + - if [[ $TOXENV =~ "py35" && -f ~/virtualenv/python3.5/bin/activate ]]; then source ~/virtualenv/python3.5/bin/activate; fi + install: - pip install -U tox From b1cc93f375fc94bf8e603f2456ae4e212d6ae064 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Thu, 4 Jan 2018 21:48:32 +0200 Subject: [PATCH 03/10] Update Python versions in setup.py --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 7695c5c..7795ca2 100755 --- a/setup.py +++ b/setup.py @@ -43,10 +43,9 @@ 'Intended Audience :: Developers', 'License :: OSI Approved :: ISC License (ISCL)', 'Natural Language :: English', - "Programming Language :: Python :: 2", - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', ], ) From 694d37a0421fb32222a70b56fe88ac6e7a7d0202 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Thu, 4 Jan 2018 21:49:07 +0200 Subject: [PATCH 04/10] Update Travis config based on docs, examples and django-rest-framework repo --- .travis.yml | 59 +++++++++++++++++++++-------------------------------- tox.ini | 6 ++++++ 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index bcafc1b..5f193ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,14 @@ language: python python: + - "3.4" + - "3.5" - "3.6" env: - - TOX_ENV=py34-django18 - - TOX_ENV=py34-django111 - - TOX_ENV=py34-django20 - - TOX_ENV=py35-django18 - - TOX_ENV=py35-django111 - - TOX_ENV=py35-django20 - - TOX_ENV=py36-django18 - - TOX_ENV=py36-django111 - - TOX_ENV=py36-django20 - - TOX_ENV=lint - - TOX_ENV=coverage - - TOX_ENV=docs - -before_install: -# For reasons: https://github.com/travis-ci/travis-ci/issues/4990 - - if [[ $TOXENV =~ "py35" && -f ~/virtualenv/python3.5/bin/activate ]]; then source ~/virtualenv/python3.5/bin/activate; fi + - DJANGO=1.8 + - DJANGO=1.11 + - DJANGO=2.0 install: - pip install -U tox @@ -27,26 +16,24 @@ install: script: - tox -jobs: - include: - - stage: deploy - env: TOX_ENV=py36-django20 - deploy: - provider: pypi - user: thorgate - password: - secure: > - gsOZAUv7GMDdQ5PVyi8+qpZSLZJ0bGs+iX8i7acIHFZU3jHpMm3NevMIuka8Xkd0cpnEW9xmAqGf6UyEW0pLa/dp5NWlggUIsRdFS0JH9aQ7c - A0cRbAPQo5ZjAaVqcHDjmKHAVjfRvHOvAcceRe/AODm/EBXx2pzxHb2YSOolFuSmK0OWjaAoJ0kK1DoWI2gltOoPC3NebdTJCmcdn1thmh1su - LanvkOn9v6363KrGz7t3y4h7qvmAYH0iM3xyarHPwodd1vChnvHdXEJoNFHzPuMcvI44nOlrf6phhFyyGyzsJQrwITwAROzLLRuKq1VbFS+nc - yj7vPa8CRh9J26ccA/W4tx0AqkwsFVxHdDIrbQ7apZ8TXIWDovv9nxRoN8e8fr+5u4umUbKLBgBKINfW2BA9LyqMCBj7YaNUwNAYxxMu8xBO4 - m6DUuCDZqXyMQVgZraJwrn0p1qmyacAcOJMbcNNlmwvo6+4kMgKVvsoFBAB9MOqH1y4UFgXsvvbx2sN46XDqmvagjtlyZMcHh6L5riRhhTl8r - YZLCmM62WKM05hjx03KDVHlNVSs4VWVCXVXkrIlDm8rHM0wy6pWUov9LREoazaDL11vAFbKBM0D3qOhDzZlD1xECa3lRWW1K3g1Pa5/DatozO - NyOCYve/jqlkfFKV3VEvgEBBBqF5g= - on: - tags: true - distributions: sdist bdist_wheel - repo: thorgate/tg-utils +deploy: + provider: pypi + user: thorgate + password: + secure: > + gsOZAUv7GMDdQ5PVyi8+qpZSLZJ0bGs+iX8i7acIHFZU3jHpMm3NevMIuka8Xkd0cpnEW9xmAqGf6UyEW0pLa/dp5NWlggUIsRdFS0JH9aQ7c + A0cRbAPQo5ZjAaVqcHDjmKHAVjfRvHOvAcceRe/AODm/EBXx2pzxHb2YSOolFuSmK0OWjaAoJ0kK1DoWI2gltOoPC3NebdTJCmcdn1thmh1su + LanvkOn9v6363KrGz7t3y4h7qvmAYH0iM3xyarHPwodd1vChnvHdXEJoNFHzPuMcvI44nOlrf6phhFyyGyzsJQrwITwAROzLLRuKq1VbFS+nc + yj7vPa8CRh9J26ccA/W4tx0AqkwsFVxHdDIrbQ7apZ8TXIWDovv9nxRoN8e8fr+5u4umUbKLBgBKINfW2BA9LyqMCBj7YaNUwNAYxxMu8xBO4 + m6DUuCDZqXyMQVgZraJwrn0p1qmyacAcOJMbcNNlmwvo6+4kMgKVvsoFBAB9MOqH1y4UFgXsvvbx2sN46XDqmvagjtlyZMcHh6L5riRhhTl8r + YZLCmM62WKM05hjx03KDVHlNVSs4VWVCXVXkrIlDm8rHM0wy6pWUov9LREoazaDL11vAFbKBM0D3qOhDzZlD1xECa3lRWW1K3g1Pa5/DatozO + NyOCYve/jqlkfFKV3VEvgEBBBqF5g= + distributions: sdist bdist_wheel + on: + repo: thorgate/tg-utils + tags: true + python: "3.6" + condition: "2.0" notifications: email: false diff --git a/tox.ini b/tox.ini index dd26f1e..54345b7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,12 @@ [tox] envlist = py{34,35,36}-django{18,111,20} +[travis:env] +DJANGO = + 1.8: django18 + 1.11: django111 + 2.0: django20 + [testenv] setenv = PYTHONPATH = {toxinidir} From 467a11beb86cf93323827a93a177b3303f4e298c Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Thu, 4 Jan 2018 21:59:31 +0200 Subject: [PATCH 05/10] Use tox-travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5f193ee..1ad821c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ env: - DJANGO=2.0 install: - - pip install -U tox + - pip install tox tox-travis script: - tox From fa66aeb167c910665f88ab9a54303bdbeae3988a Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Fri, 5 Jan 2018 12:13:12 +0200 Subject: [PATCH 06/10] Fix Travis deploy condition --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1ad821c..ba94b8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ deploy: repo: thorgate/tg-utils tags: true python: "3.6" - condition: "2.0" + condition: "$DJANGO = 2.0" notifications: email: false From 1c5c1288b1d896832a9e5134eb8be6b6810c51f8 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Fri, 5 Jan 2018 13:17:34 +0200 Subject: [PATCH 07/10] Fix linter issues --- setup.cfg | 2 ++ tests/django_settings.py | 2 +- tests/test_importing.py | 3 +++ tg_utils/profiling.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 65575e8..f78d492 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,3 +8,5 @@ tag = True [wheel] universal = 1 +[flake8] +max-line-length = 140 diff --git a/tests/django_settings.py b/tests/django_settings.py index 02b7127..47cc7fc 100644 --- a/tests/django_settings.py +++ b/tests/django_settings.py @@ -3,7 +3,7 @@ DEBUG = True -SECRET_KEY='hunter2' +SECRET_KEY = 'hunter2' SITE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/tests/test_importing.py b/tests/test_importing.py index 1dd2522..9e2d3e2 100644 --- a/tests/test_importing.py +++ b/tests/test_importing.py @@ -1,3 +1,6 @@ +# flake8: noqa + + def test_imports(): """ Ensures all submodules are importable diff --git a/tg_utils/profiling.py b/tg_utils/profiling.py index b6b2b76..f92e57f 100644 --- a/tg_utils/profiling.py +++ b/tg_utils/profiling.py @@ -22,7 +22,7 @@ def profile_yappi(label): func_stats = yappi.get_func_stats() file_prefix = '/tmp/profile-yappi-%s-%s' % (label, timestamp.isoformat('T')) with open(file_prefix + '-summary.txt', 'w') as f: - func_stats.print_all(out=f, columns={0:("name",140), 1:("ncall", 8), 2:("tsub", 8), 3:("ttot", 8), 4:("tavg",8)}) + func_stats.print_all(out=f, columns={0: ("name", 140), 1: ("ncall", 8), 2: ("tsub", 8), 3: ("ttot", 8), 4: ("tavg", 8)}) func_stats.save(file_prefix + '.kgrind', 'CALLGRIND') yappi.stop() yappi.clear_stats() From 88ee30f69f6b4eff93dc35a47b1370d777b1bfe5 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Fri, 5 Jan 2018 13:31:35 +0200 Subject: [PATCH 08/10] Run linter and coverage via tox/Travis --- Makefile | 7 +++---- requirements_test.txt | 3 +++ tox.ini | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 621bca9..a8ac439 100644 --- a/Makefile +++ b/Makefile @@ -51,14 +51,13 @@ lint: test: py.test +test-full: test lint coverage + test-all: tox coverage: - coverage run --source tg_utils setup.py test - coverage report -m - coverage html - $(BROWSER) htmlcov/index.html + py.test --cov-config .coveragerc --cov=tg_utils --cov-report html --cov-report term-missing docs: rm -f docs/tg_utils.rst diff --git a/requirements_test.txt b/requirements_test.txt index 1ac0243..3d4c488 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,7 @@ pytest==2.8.5 +coverage==4.2 +coveralls==1.1 +pytest-cov==2.4.0 pytest-django==2.9.1 django_compressor==2.0 hashids==1.1.0 diff --git a/tox.ini b/tox.ini index 54345b7..b666a99 100644 --- a/tox.ini +++ b/tox.ini @@ -17,3 +17,6 @@ deps = django111: Django>=1.11,<1.12 django20: Django>=2.0,<2.1 -r{toxinidir}/requirements_test.txt + +[testenv:py36-django20] +commands = make test-full From d9008fd5a0a001284cdd05d2db30455ca7558cfc Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Mon, 8 Jan 2018 12:06:12 +0200 Subject: [PATCH 09/10] Add flake8 to test reqs --- requirements_test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_test.txt b/requirements_test.txt index 3d4c488..31e2e8f 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -5,3 +5,4 @@ pytest-cov==2.4.0 pytest-django==2.9.1 django_compressor==2.0 hashids==1.1.0 +flake8==2.5.1 From 5883ec7d67d84e33ba047341ca026afa223d9cd3 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Mon, 12 Mar 2018 12:47:27 +0200 Subject: [PATCH 10/10] Let's get 0.3 out --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index c4052f4..bee8cb7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,7 +2,7 @@ History ======= -0.3.0 (2018-01-02) +0.3.0 (2018-03-12) ------------------ * Supported Django versions are now 1.8, 1.11, and 2.0.