diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3dfcf30 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + build: + if: github.repository == 'jazzband/django-dbtemplates' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install -U setuptools twine wheel + + - name: Build package + run: | + python setup.py --version + python setup.py sdist --format=gztar bdist_wheel + twine check dist/* + + - name: Upload packages to Jazzband + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: jazzband + password: ${{ secrets.JAZZBAND_RELEASE_KEY }} + repository_url: https://jazzband.co/projects/django-dbtemplates/upload diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b39f323 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ['3.6', '3.7', '3.8', '3.9'] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: + ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox tox-gh-actions + + - name: Tox tests + run: | + tox -v + + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + name: Python ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 5636b3d..58950d1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ docs/_build .tox/ *.egg/ .coverage +coverage.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7eb95fa..0000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: python -python: -- '2.7' -- '3.5' -- '3.6' -# Enable 3.7 without globally enabling sudo and dist: xenial for other build jobs -# See https://github.com/travis-ci/travis-ci/issues/9815 -matrix: - include: - - python: 3.7 - dist: xenial - sudo: true -sudo: false -cache: pip -install: -- pip install tox-travis -script: tox -v -after_success: -- bash <(curl -s https://codecov.io/bash) -deploy: - provider: pypi - user: jazzband - server: https://jazzband.co/projects/django-dbtemplates/upload - distributions: sdist bdist_wheel - password: - secure: xDkRgaRI29FIVfQ5WEj6zSIlbBdFK/BE2RYQpSggVeTpUaZucS2RtE7it2hCMMYU5patHbcGJtw/DKGMtAhhZcm9tYCpn7cyW6vyF7tT385mbk5yggdjz5MoIHjQJD9NW1fqFRwLIJPICy6U6apxvQ1SpVtF13Dfu5AaCMv4cvk= - on: - tags: true - repo: jazzband/django-dbtemplates - python: 3.7 diff --git a/README.rst b/README.rst index 973b169..4ddc5b5 100644 --- a/README.rst +++ b/README.rst @@ -5,9 +5,9 @@ django-dbtemplates :alt: Jazzband :target: https://jazzband.co/ -.. image:: https://travis-ci.org/jazzband/django-dbtemplates.svg?branch=master - :alt: Build Status - :target: http://travis-ci.org/jazzband/django-dbtemplates +.. image:: https://github.com/jazzband/django-dbtemplates/workflows/Test/badge.svg + :target: https://github.com/jazzband/django-dbtemplates/actions + :alt: GitHub Actions .. image:: https://codecov.io/github/jazzband/django-dbtemplates/coverage.svg?branch=master :alt: Codecov diff --git a/dbtemplates/__init__.py b/dbtemplates/__init__.py index f032be0..23b4a18 100644 --- a/dbtemplates/__init__.py +++ b/dbtemplates/__init__.py @@ -1,3 +1,10 @@ -__version__ = "3.0" +from pkg_resources import get_distribution, DistributionNotFound + +try: + __version__ = get_distribution("django-dbtemplates").version +except DistributionNotFound: + # package is not installed + __version__ = None + default_app_config = 'dbtemplates.apps.DBTemplatesConfig' diff --git a/dbtemplates/conf.py b/dbtemplates/conf.py index 3d9aeec..8b8809a 100644 --- a/dbtemplates/conf.py +++ b/dbtemplates/conf.py @@ -2,7 +2,6 @@ from django.core.exceptions import ImproperlyConfigured from django.conf import settings -from six import string_types from appconf import AppConf @@ -33,7 +32,7 @@ def configure_cache_backend(self, value): return "dbtemplates" else: return "default" - if isinstance(value, string_types) and value.startswith("dbtemplates."): + if isinstance(value, str) and value.startswith("dbtemplates."): raise ImproperlyConfigured("Please upgrade to one of the " "supported backends as defined " "in the Django docs.") diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 7ef8a72..cd65be3 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -1,14 +1,9 @@ import io import os -import sys from django.contrib.sites.models import Site from django.core.management.base import CommandError, BaseCommand from django.template.utils import get_app_template_dirs from django.template.loader import _engine_list -try: - from six import input -except ImportError: - pass from dbtemplates.models import Template diff --git a/dbtemplates/models.py b/dbtemplates/models.py index 2c7976c..10cb83c 100644 --- a/dbtemplates/models.py +++ b/dbtemplates/models.py @@ -8,12 +8,10 @@ from django.db import models from django.db.models import signals from django.template import TemplateDoesNotExist -from six import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from django.utils.timezone import now -@python_2_unicode_compatible class Template(models.Model): """ Defines a template model for use with the database template loader. diff --git a/docs/changelog.txt b/docs/changelog.txt index e8515af..f969846 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,6 +1,21 @@ Changelog ========= +v4.0 (unreleased) +----------------- + +.. warning:: + + This is a backwards-incompatible release! + +* Dropped support for Python 2.7. + +* Added support for Python 3.8. + +* Moved test runner to GitHub Actions: + + http://github.com/jazzband/django-dbtemplates/actions + v3.0 (2019-01-27) ----------------- diff --git a/setup.py b/setup.py index 9529139..51a3989 100644 --- a/setup.py +++ b/setup.py @@ -1,62 +1,45 @@ -import ast import os import io from setuptools import setup, find_packages -class VersionFinder(ast.NodeVisitor): - def __init__(self): - self.version = None - - def visit_Assign(self, node): - if node.targets[0].id == '__version__': - self.version = node.value.s - - def read(*parts): filename = os.path.join(os.path.dirname(__file__), *parts) - with io.open(filename, encoding='utf-8') as fp: + with io.open(filename, encoding="utf-8") as fp: return fp.read() -def find_version(*parts): - finder = VersionFinder() - finder.visit(ast.parse(read(*parts))) - return finder.version - - setup( - name='django-dbtemplates', - version=find_version('dbtemplates', '__init__.py'), - description='Template loader for templates stored in the database', - long_description=read('README.rst'), - author='Jannis Leidel', - author_email='jannis@leidel.info', - url='https://django-dbtemplates.readthedocs.io/', + name="django-dbtemplates", + use_scm_version={"version_scheme": "post-release"}, + setup_requires=["setuptools_scm"], + description="Template loader for templates stored in the database", + long_description=read("README.rst"), + author="Jannis Leidel", + author_email="jannis@leidel.info", + url="https://django-dbtemplates.readthedocs.io/", packages=find_packages(), zip_safe=False, package_data={ - 'dbtemplates': [ - 'locale/*/LC_MESSAGES/*', - 'static/dbtemplates/css/*.css', - 'static/dbtemplates/js/*.js', + "dbtemplates": [ + "locale/*/LC_MESSAGES/*", + "static/dbtemplates/css/*.css", + "static/dbtemplates/js/*.js", ], }, classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - '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', - 'Programming Language :: Python :: 3.7', - 'Framework :: Django', + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Django", ], - install_requires=['django-appconf >= 0.4', 'six'], + install_requires=["django-appconf >= 0.4"], ) diff --git a/tox.ini b/tox.ini index 3173f59..97e108a 100644 --- a/tox.ini +++ b/tox.ini @@ -3,18 +3,26 @@ skipsdist = True usedevelop = True minversion = 1.8 envlist = - flake8-py{27,37}, - twine-check-py{27,37}, - py{27,35,36}-dj111 + flake8 + py{35,36}-dj111 py{35,36,37}-dj21 - py{35,36,37}-dj22 + py{35,36,37,38,39}-dj22 + +[gh-actions] +python = + 3.5: py36 + 3.6: py36 + 3.7: py37 + 3.8: py38, flake8 + 3.9: py39 [testenv] basepython = - py27: python2.7 py35: python3.5 py36: python3.6 py37: python3.7 + py38: python3.8 + py39: python3.9 usedevelop = true setenv = DJANGO_SETTINGS_MODULE = dbtemplates.test_settings @@ -30,24 +38,10 @@ commands = python --version coverage run {envbindir}/django-admin.py test -v2 {posargs:dbtemplates} coverage report + coverage xml -[testenv:twine-check-py27] -commands = - python setup.py sdist bdist_wheel - twine check dist/* -deps = twine - -[testenv:twine-check-py37] -commands = - python setup.py sdist bdist_wheel - twine check dist/* -deps = twine - -[testenv:flake8-py27] -commands = flake8 dbtemplates -deps = flake8 - -[testenv:flake8-py37] +[testenv:flake8] +basepython = python3.8 commands = flake8 dbtemplates deps = flake8