From 3083d7e31f275b2477dc67c0bf83b054f3ca0f85 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 5 Jul 2022 10:32:57 -0500 Subject: [PATCH 1/6] build(project_urls): Add PyPI links to changelog and issues --- setup.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.py b/setup.py index c5d046b..d004aac 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,12 @@ def get_version(): url='http://github.com/ambitioninc/django-manager-utils/', author='Wes Kendall', author_email='opensource@ambition.com', + project_urls={ + "Bug Tracker": "https://github.com/ambitioninc/django-manager-utils/issues", + "Changes": "https://django-manager-utils.readthedocs.io/en/latest/release_notes.html", + "Documentation": "https://django-manager-utils.readthedocs.io/en/latest/", + "Source Code": "https://github.com/ambitioninc/django-manager-utils", + }, packages=find_packages(), classifiers=[ 'Programming Language :: Python', From ef22d1745fa9dbece2b10c331b15bb49c08ccb9f Mon Sep 17 00:00:00 2001 From: Wes Okes Date: Fri, 19 Aug 2022 19:09:09 -0400 Subject: [PATCH 2/6] version support --- .gitignore | 2 ++ .travis.yml | 21 ++++++++--- MANIFEST.in | 1 + docs/release_notes.rst | 6 ++++ manager_utils/manager_utils.py | 5 ++- manager_utils/version.py | 2 +- requirements/requirements-testing.txt | 2 +- requirements/requirements.txt | 2 ++ settings.py | 52 ++++++++++++++++----------- setup.py | 30 ++++++++-------- tox.ini | 32 +++++++++++------ 11 files changed, 102 insertions(+), 53 deletions(-) create mode 100644 requirements/requirements.txt diff --git a/.gitignore b/.gitignore index b6b5c6b..48cd5d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Compiled python files *.pyc +.tox/ + # Vim files *.swp *.swo diff --git a/.travis.yml b/.travis.yml index 93cb67b..7e1ef3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,24 +2,37 @@ dist: xenial language: python sudo: false +services: + - postgresql + python: - - "3.6" - "3.7" - "3.8" + - "3.9" env: + global: + - PGPORT=5433 + - PGUSER=travis matrix: - DJANGO=2.2 - DJANGO=3.0 - DJANGO=3.1 + - DJANGO=3.2 + - DJANGO=4.0 + - DJANGO=4.1 - DJANGO=master addons: - postgresql: '9.6' + postgresql: '13' + apt: + packages: + - postgresql-13 + - postgresql-client-13 matrix: include: - - { python: "3.6", env: TOXENV=flake8 } + - { python: "3.7", env: TOXENV=flake8 } allow_failures: - env: DJANGO=master @@ -28,7 +41,7 @@ install: - pip install tox-travis before_script: - - psql -c 'CREATE DATABASE manager_utils;' -U postgres + - psql -c 'CREATE DATABASE manager_utils;' -U travis script: - tox diff --git a/MANIFEST.in b/MANIFEST.in index a5021c6..ddffd89 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ include README.rst include LICENSE +recursive-include requirements * diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 1082f0b..1e23fde 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -1,6 +1,12 @@ Release Notes ============= +v3.0.0 +------ +* Add support for django 3.2, 4.0, 4.1 +* Add support for python 3.9 +* Drop support for python 3.6 + v2.0.1 ------ * Fixed docstring (alextatarinov) diff --git a/manager_utils/manager_utils.py b/manager_utils/manager_utils.py index 60c4738..1dc775c 100644 --- a/manager_utils/manager_utils.py +++ b/manager_utils/manager_utils.py @@ -10,7 +10,10 @@ # A signal that is emitted when any bulk operation occurs -post_bulk_operation = Signal(providing_args=['model']) +post_bulk_operation = Signal() +""" +providing_args=['model'] +""" def id_dict(queryset): diff --git a/manager_utils/version.py b/manager_utils/version.py index 3f39079..4eb28e3 100644 --- a/manager_utils/version.py +++ b/manager_utils/version.py @@ -1 +1 @@ -__version__ = '2.0.1' +__version__ = '3.0.0' diff --git a/requirements/requirements-testing.txt b/requirements/requirements-testing.txt index e69e98f..3be58fd 100644 --- a/requirements/requirements-testing.txt +++ b/requirements/requirements-testing.txt @@ -4,6 +4,6 @@ psycopg2 django-nose>=1.3 django-dynamic-fixture pytz -django-timezone-field +django-timezone-field==4.0 parameterized freezegun diff --git a/requirements/requirements.txt b/requirements/requirements.txt new file mode 100644 index 0000000..c9c0b06 --- /dev/null +++ b/requirements/requirements.txt @@ -0,0 +1,2 @@ +Django>=2.2 +django-query-builder>=2.0.0 diff --git a/settings.py b/settings.py index c028a2f..af8488d 100644 --- a/settings.py +++ b/settings.py @@ -12,41 +12,53 @@ def configure_settings(): test_db = os.environ.get('DB', None) if test_db is None: db_config = { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'ambition', - 'USER': 'ambition', - 'PASSWORD': 'ambition', - 'HOST': 'db' + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'ambition_test', + 'USER': 'postgres', + 'PASSWORD': '', + 'HOST': 'db', } elif test_db == 'postgres': db_config = { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'USER': 'postgres', + 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'manager_utils', - } + 'USER': 'travis', + 'PORT': '5433', + } + # db_config = { + # 'ENGINE': 'django.db.backends.postgresql', + # 'NAME': 'manager_utils', + # 'USER': 'postgres', + # 'PASSWORD': '', + # 'HOST': 'db', + # } elif test_db == 'sqlite': db_config = { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'manager_utils', - } + } else: raise RuntimeError('Unsupported test DB {0}'.format(test_db)) + installed_apps = [ + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.admin', + 'manager_utils', + 'manager_utils.tests', + ] + settings.configure( - TEST_RUNNER='django_nose.NoseTestSuiteRunner', - NOSE_ARGS=['--nocapture', '--nologcapture', '--verbosity=1'], - MIDDLEWARE_CLASSES={}, DATABASES={ 'default': db_config, }, - INSTALLED_APPS=( - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.admin', - 'manager_utils', - 'manager_utils.tests', - ), + MIDDLEWARE_CLASSES={}, + INSTALLED_APPS=installed_apps, ROOT_URLCONF='manager_utils.urls', DEBUG=False, + NOSE_ARGS=['--nocapture', '--nologcapture', '--verbosity=1'], + TEST_RUNNER='django_nose.NoseTestSuiteRunner', + SECRET_KEY='*', + USE_DEPRECATED_PYTZ=True, ) diff --git a/setup.py b/setup.py index c5d046b..bc9a2db 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,14 @@ def get_version(): raise RuntimeError('Unable to find version string in {0}.'.format(VERSION_FILE)) +def get_lines(file_path): + return open(file_path, 'r').read().split('\n') + + +install_requires = get_lines('requirements/requirements.txt') +tests_require = get_lines('requirements/requirements-testing.txt') + + setup( name='django-manager-utils', version=get_version(), @@ -29,31 +37,21 @@ def get_version(): classifiers=[ 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Framework :: Django :: 2.2', 'Framework :: Django :: 3.0', 'Framework :: Django :: 3.1', + 'Framework :: Django :: 3.2', + 'Framework :: Django :: 4.0', + 'Framework :: Django :: 4.1', ], - install_requires=[ - 'Django>=2.2', - 'django-query-builder>=2.0.0', - ], - tests_require=[ - 'coverage', - 'freezegun', - 'mock', - 'psycopg2', - 'django-nose>=1.3', - 'django-dynamic-fixture', - 'pytz', - 'django-timezone-field', - 'parameterized', - ], + install_requires=install_requires, + tests_require=tests_require, test_suite='run_tests.run', include_package_data=True, ) diff --git a/tox.ini b/tox.ini index 77d6894..fb90e56 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,33 @@ [tox] envlist = flake8 - py{36,37}-django22 - py{36,37,38}-django30 - py{36,37,38}-django31 - py{36,37,38}-djangomaster + coverage + py{37,38}-django22 + py{37,38}-django30 + py{37,38}-django31 + py{37,38}-django32 + py{38,39}-django40 + py{38,39}-django41 + py{38,39}-djangomaster [testenv] setenv = DB = postgres deps = - django22: Django>=2.2,<3.0 - django30: Django>=3.0,<3.1 - django31: Django>=3.1,<3.2 + django22: Django~=2.2 + django30: Django~=3.0 + django31: Django~=3.1 + django32: Django~=3.2 + django40: Django~=4.0 + django41: Django~=4.1 djangomaster: https://github.com/django/django/archive/master.tar.gz -rrequirements/requirements-testing.txt + commands = - coverage run --concurrency=multiprocessing setup.py test - coverage combine - coverage report --fail-under=100 + pip freeze + python --version + coverage run manage.py test manager_utils --failfast + coverage report --fail-under=90 [testenv:flake8] deps = flake8 @@ -29,4 +38,7 @@ DJANGO = 2.2: django22 3.0: django30 3.1: django31 + 3.2: django32 + 4.0: django40 + 4.1: django41 master: djangomaster From 1d634a239de320a0a4d1c91afbce2c5fe7fd794b Mon Sep 17 00:00:00 2001 From: Wes Okes Date: Mon, 22 Aug 2022 22:33:31 -0400 Subject: [PATCH 3/6] github actions --- .github/workflows/tests.yml | 85 +++++++++++++++++++++++++++ .travis.yml => .travis_old.yml | 0 requirements/requirements-testing.txt | 1 + requirements/requirements.txt | 2 +- settings.py | 4 ++ tox.ini => tox_old.ini | 0 6 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml rename .travis.yml => .travis_old.yml (100%) rename tox.ini => tox_old.ini (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..df32d2d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,85 @@ +# copied from django-cte +name: manager_utils tests +on: + push: + branches: [master] + pull_request: + branches: [master,develop] + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python: ['3.7'] +# python: ['3.7', '3.8', '3.9'] + # Time to switch to pytest or nose2? + # nosetests is broken on 3.10 + # AttributeError: module 'collections' has no attribute 'Callable' + # https://github.com/nose-devs/nose/issues/1099 + django: + - 'Django~=2.2.0' +# - 'Django~=3.0.0' +# - 'Django~=3.1.0' +# - 'Django~=3.2.0' +# - 'Django~=4.0.0' +# - 'Django~=4.1.0' + experimental: [false] +# include: +# - python: '3.9' +# django: 'https://github.com/django/django/archive/refs/heads/main.zip#egg=Django' +# experimental: true +# # NOTE this job will appear to pass even when it fails because of +# # `continue-on-error: true`. Github Actions apparently does not +# # have this feature, similar to Travis' allow-failure, yet. +# # https://github.com/actions/toolkit/issues/399 +# exclude: +# - python: '3.7' +# django: 'Django~=4.0.0' +# - python: '3.7' +# django: 'Django~=4.1.0' + services: + postgres: + image: postgres:latest + env: + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Setup + run: | + python --version + pip install --upgrade pip wheel + pip install -r requirements/requirements.txt + pip install -r requirements/requirements-testing.txt + pip install "${{ matrix.django }}" + pip freeze + - name: Run tests + env: + DB_SETTINGS: >- + { + "ENGINE":"django.db.backends.postgresql_psycopg2", + "NAME":"manager_utils", + "USER":"postgres", + "PASSWORD":"postgres", + "HOST":"localhost", + "PORT":"5432" + } + run: | + coverage run manage.py test manager_utils + coverage report --fail-under=90 + continue-on-error: ${{ matrix.experimental }} + - name: Check style + run: flake8 manager_utils diff --git a/.travis.yml b/.travis_old.yml similarity index 100% rename from .travis.yml rename to .travis_old.yml diff --git a/requirements/requirements-testing.txt b/requirements/requirements-testing.txt index 3be58fd..05643d8 100644 --- a/requirements/requirements-testing.txt +++ b/requirements/requirements-testing.txt @@ -7,3 +7,4 @@ pytz django-timezone-field==4.0 parameterized freezegun +flake8 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index c9c0b06..f59a12d 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,2 +1,2 @@ Django>=2.2 -django-query-builder>=2.0.0 +django-query-builder>=3.0.1 diff --git a/settings.py b/settings.py index af8488d..8ab7039 100644 --- a/settings.py +++ b/settings.py @@ -1,4 +1,5 @@ import os +import json from django.conf import settings @@ -40,6 +41,9 @@ def configure_settings(): else: raise RuntimeError('Unsupported test DB {0}'.format(test_db)) + if os.environ.get('DB_SETTINGS'): + db_config = json.loads(os.environ.get('DB_SETTINGS')) + installed_apps = [ 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/tox.ini b/tox_old.ini similarity index 100% rename from tox.ini rename to tox_old.ini From 9ed39925d626f6d2b9f4d369a56266ff60cad6e7 Mon Sep 17 00:00:00 2001 From: Wes Okes Date: Mon, 22 Aug 2022 22:34:00 -0400 Subject: [PATCH 4/6] note --- docs/release_notes.rst | 4 ++++ manager_utils/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 1e23fde..25a2194 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -1,6 +1,10 @@ Release Notes ============= +v3.0.1 +------ +* Switch to github actions + v3.0.0 ------ * Add support for django 3.2, 4.0, 4.1 diff --git a/manager_utils/version.py b/manager_utils/version.py index 4eb28e3..b7a5531 100644 --- a/manager_utils/version.py +++ b/manager_utils/version.py @@ -1 +1 @@ -__version__ = '3.0.0' +__version__ = '3.0.1' From 3e0617559375fb9e467f167dc794d09add7e5f9e Mon Sep 17 00:00:00 2001 From: Wes Okes Date: Mon, 22 Aug 2022 22:46:06 -0400 Subject: [PATCH 5/6] djangos --- .github/workflows/tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index df32d2d..6ad4ab6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,19 +12,19 @@ jobs: strategy: fail-fast: false matrix: - python: ['3.7'] + python: ['3.9'] # python: ['3.7', '3.8', '3.9'] # Time to switch to pytest or nose2? # nosetests is broken on 3.10 # AttributeError: module 'collections' has no attribute 'Callable' # https://github.com/nose-devs/nose/issues/1099 django: - - 'Django~=2.2.0' +# - 'Django~=2.2.0' # - 'Django~=3.0.0' # - 'Django~=3.1.0' -# - 'Django~=3.2.0' -# - 'Django~=4.0.0' -# - 'Django~=4.1.0' + - 'Django~=3.2.0' + - 'Django~=4.0.0' + - 'Django~=4.1.0' experimental: [false] # include: # - python: '3.9' @@ -79,7 +79,7 @@ jobs: } run: | coverage run manage.py test manager_utils - coverage report --fail-under=90 + coverage report --fail-under=100 continue-on-error: ${{ matrix.experimental }} - name: Check style run: flake8 manager_utils From 9cef6319468a1a4b2a8f9034c51422509631318b Mon Sep 17 00:00:00 2001 From: Wes Okes Date: Mon, 22 Aug 2022 22:48:44 -0400 Subject: [PATCH 6/6] all versions --- .github/workflows/tests.yml | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6ad4ab6..476a542 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,33 +12,32 @@ jobs: strategy: fail-fast: false matrix: - python: ['3.9'] -# python: ['3.7', '3.8', '3.9'] + python: ['3.7', '3.8', '3.9'] # Time to switch to pytest or nose2? # nosetests is broken on 3.10 # AttributeError: module 'collections' has no attribute 'Callable' # https://github.com/nose-devs/nose/issues/1099 django: -# - 'Django~=2.2.0' -# - 'Django~=3.0.0' -# - 'Django~=3.1.0' + - 'Django~=2.2.0' + - 'Django~=3.0.0' + - 'Django~=3.1.0' - 'Django~=3.2.0' - 'Django~=4.0.0' - 'Django~=4.1.0' experimental: [false] -# include: -# - python: '3.9' -# django: 'https://github.com/django/django/archive/refs/heads/main.zip#egg=Django' -# experimental: true -# # NOTE this job will appear to pass even when it fails because of -# # `continue-on-error: true`. Github Actions apparently does not -# # have this feature, similar to Travis' allow-failure, yet. -# # https://github.com/actions/toolkit/issues/399 -# exclude: -# - python: '3.7' -# django: 'Django~=4.0.0' -# - python: '3.7' -# django: 'Django~=4.1.0' + include: + - python: '3.9' + django: 'https://github.com/django/django/archive/refs/heads/main.zip#egg=Django' + experimental: true + # NOTE this job will appear to pass even when it fails because of + # `continue-on-error: true`. Github Actions apparently does not + # have this feature, similar to Travis' allow-failure, yet. + # https://github.com/actions/toolkit/issues/399 + exclude: + - python: '3.7' + django: 'Django~=4.0.0' + - python: '3.7' + django: 'Django~=4.1.0' services: postgres: image: postgres:latest