diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 5c6ecbb..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[bumpversion] -commit = False -tag = False -current_version = 3.0.0 - -[bumpversion:file:setup.cfg] diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 13ba683..0000000 --- a/.coveragerc +++ /dev/null @@ -1,20 +0,0 @@ -[run] -branch = True -source = timeline_logger -omit = - demo/* - */migrations/* - */tests/* - -[report] -omit = - demo/* - */migrations/* - */tests/* - -exclude_lines = - pragma: no cover - noqa - -[html] -directory = cover diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..8810a6e --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length=88 +ignore=E501 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c280d0..9994249 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ['3.8', '3.9', '3.10', '3.11'] - django: ['3.2', '4.1', '4.2'] + python: ['3.10', '3.11', '3.12'] + django: ['3.2', '4.2'] exclude: - - python: '3.11' + - python: ['3.11', '3.12'] django: '3.2' services: @@ -35,8 +35,8 @@ jobs: name: Run the test suite (Python ${{ matrix.python }}, Django ${{ matrix.django }}) steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} @@ -54,7 +54,7 @@ jobs: PGHOST: localhost - name: Publish coverage report - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 publish: name: Publish package to PyPI @@ -64,18 +64,18 @@ jobs: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.10' - name: Build sdist and wheel run: | - pip install pip setuptools wheel --upgrade - python setup.py sdist bdist_wheel + pip install build --upgrade + python -m build - name: Publish a Python distribution to PyPI - uses: pypa/gh-action-pypi-publish@v1.4.1 + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index f9204e2..107cb27 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -7,6 +7,7 @@ on: - master - develop tags: + - '*' paths: - "**.py" pull_request: @@ -20,10 +21,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - toxenv: [isort, black, docs] + toxenv: [isort, black, flake8, docs] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install dependencies diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..14b81aa --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,20 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.10" + +sphinx: + configuration: docs/conf.py + +python: + install: + - method: pip + path: . + extra_requirements: + - docs diff --git a/demo/manage.py b/demo/manage.py index 021ff84..70d13e0 100755 --- a/demo/manage.py +++ b/demo/manage.py @@ -7,16 +7,10 @@ try: from django.core.management import execute_from_command_line except ImportError: - # The above import may fail for some other reason. Ensure that the - # issue is really that Django is missing to avoid masking other - # exceptions on Python 2. - try: - import django - except ImportError: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) - raise + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + execute_from_command_line(sys.argv) diff --git a/docs/conf.py b/docs/conf.py index 3145c4d..1c5f6af 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,9 +20,9 @@ # import os # import sys # sys.path.insert(0, os.path.abspath('.')) -from pkg_resources import get_distribution +from importlib.metadata import version as get_version -FULL_VERSION = get_distribution("django-timeline-logger").version +FULL_VERSION = get_version("django-timeline-logger") # -- General configuration ------------------------------------------------ @@ -53,7 +53,7 @@ # General information about the project. project = "Django Timeline Logger" -copyright = "2016-2018, Maykin Media" +copyright = "2016, Maykin Media" author = "Maykin Media" # The version info for the project you're documenting, acts as replacement for diff --git a/docs/contributing.rst b/docs/contributing.rst index 5cbad4e..cd4b8f7 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -25,7 +25,7 @@ To run the tests in your (virtual) environment, simple execute .. code-block:: sh - python setup.py test + pytest This will run the tests with the current python version and Django version installed in your virtual environment. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e1a6f4c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,121 @@ +[build-system] +requires = ["setuptools>=61.0.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "django-timeline-logger" +version = "3.0.0" +description = "Generic event logger for Django models." +authors = [ + {name = "Maykin Media", email = "support@maykinmedia.nl"} +] +readme = "README.rst" +license = {file = "LICENSE"} +keywords = ["django", "generic logging"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.2", + "Intended Audience :: Developers", + "Operating System :: Unix", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Libraries :: Python Modules", +] +requires-python = ">=3.10" +dependencies = [ + "django>=3.2", + "django-appconf", +] + +[project.urls] +Homepage = "https://github.com/maykinmedia/django-timeline-logger" +Documentation = "http://django-timeline-logger.readthedocs.io/en/latest/" +"Bug Tracker" = "https://github.com/maykinmedia/django-timeline-logger/issues" +"Source Code" = "https://github.com/maykinmedia/django-timeline-logger" +Changelog = "https://github.com/maykinmedia/django-timeline-logger/blob/master/docs/changelog.rst" + +[project.optional-dependencies] +tests = [ + "factory-boy", + "psycopg2", + "pytest", + "pytest-cov", + "pytest-django", + "pytest-pep8", + "pytest-pylint", + "pytest-pythonpath", + "pytest-runner", + "tox", + "black", + "isort", + "flake8", +] +coverage = [ + "pytest-cov", +] +docs = [ + "sphinx", + "sphinx-rtd-theme", +] +release = [ + "bump-my-version", + "twine", +] + +[tool.setuptools.packages.find] +include = ["timeline_logger*"] +namespaces = false + +[tool.isort] +profile = "black" +combine_as_imports = true +known_django = "django" +known_first_party="timeline_logger" +sections=["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +DJANGO_SETTINGS_MODULE = "tests.settings_pg" + +[tool.bumpversion] +current_version = "3.0.0" +files = [ + {filename = "pyproject.toml"}, + {filename = "README.rst"}, + {filename = "docs/changelog.rst"}, +] + +[tool.coverage.run] +branch = true +source = [ + "timeline_logger" +] +omit = [ + "demo/*", + "*/migrations/*", + "*/tests/*", +] + +[tool.coverage.report] +exclude_also = [ + "if (typing\\.)?TYPE_CHECKING:", + "@(typing\\.)?overload", + "class .*\\(.*Protocol.*\\):", + "@(abc\\.)?abstractmethod", + "raise NotImplementedError", + "\\.\\.\\.", + "pass", +] +omit = [ + "demo/*", + "*/migrations/*", + "*/tests/*", +] + +[tool.coverage.html] +directory = "cover" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 29f4a5f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,108 +0,0 @@ -[metadata] -name = django-timeline-logger -version = 3.0.0 -description = Generic event logger for Django models. -long_description = file: README.rst -url = https://github.com/maykinmedia/django-timeline-logger -project_urls = - Documentation = http://django-timeline-logger.readthedocs.io/en/latest/ - Changelog = https://github.com/maykinmedia/django-timeline-logger/blob/master/docs/changelog.rst - Bug Tracker = https://github.com/maykinmedia/django-timeline-logger/issues - Source Code = https://github.com/maykinmedia/django-timeline-logger -license = MIT -author = Maykin Media -author_email = support@maykinmedia.nl -keywords = django, generic logging -classifiers = - Development Status :: 5 - Production/Stable - Framework :: Django - Framework :: Django :: 3.2 - Framework :: Django :: 4.1 - Framework :: Django :: 4.2 - Intended Audience :: Developers - Operating System :: Unix - Operating System :: MacOS - Operating System :: Microsoft :: Windows - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Topic :: Software Development :: Libraries :: Python Modules - -[options] -zip_safe = False -include_package_data = True -packages = find: -install_requires = - django>=3.2 - django-appconf -tests_require = - factory-boy - psycopg2 - pytest - pytest-cov - pytest-django - pytest-pep8 - pytest-pylint - pytest-pythonpath - pytest-runner - tox - black - isort - -[options.packages.find] -include = - timeline_logger - timeline_logger.* - -[options.extras_require] -tests = - factory-boy - psycopg2 - pytest - pytest-cov - pytest-django - pytest-pep8 - pytest-pylint - pytest-pythonpath - pytest-runner - tox - black - isort -pep8 = flake8 -coverage = pytest-cov -docs = - sphinx - sphinx-rtd-theme -release = - bump2version - twine - -# 3rd party configuration - -[aliases] -test=pytest - -[isort] -combine_as_imports = true -default_section = THIRDPARTY -include_trailing_comma = true -line_length = 88 -multi_line_output = 3 -force_grid_wrap = 0 -use_parentheses = True -ensure_newline_before_comments = True -skip = env,.tox,.history,.eggs -known_django=django -known_first_party=timeline_logger -sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER - -[tool:pytest] -testpaths = tests -DJANGO_SETTINGS_MODULE = tests.settings_pg - -[pep8] -[flake8] -ignore=W293,W291,E501,E261 -max-line-length=88 -exclude=env,.tox,doc diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/timeline_logger/__init__.py b/timeline_logger/__init__.py index bb1d05c..493a638 100644 --- a/timeline_logger/__init__.py +++ b/timeline_logger/__init__.py @@ -1,5 +1,5 @@ -from pkg_resources import get_distribution +from importlib.metadata import version -__version__ = get_distribution("django-timeline-logger").version +__version__ = version("django-timeline-logger") default_app_config = "timeline_logger.apps.TimelineLoggerConfig" diff --git a/tox.ini b/tox.ini index f59b816..726a068 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,16 @@ [tox] envlist = - py{38,39,310}-django{32,41,42} - py{38,39,310,311}-django{41,42} + py{310}-django32 + py{310,311,312}-django{42} isort black + flake8 docs skip_missing_interpreters = true [gh-actions:env] DJANGO = 3.2: django32 - 4.1: django41 4.2: django42 [testenv] @@ -27,7 +27,6 @@ extras = coverage deps = django32: Django~=3.2.0 - django41: Django~=4.1.0 django42: Django~=4.2.0 commands = py.test tests \ @@ -43,7 +42,12 @@ commands = isort --check-only --diff . [testenv:black] extras = tests skipsdist = True -commands = black --check timeline_logger docs tests setup.py +commands = black --check timeline_logger docs tests + +[testenv:flake8] +extras = tests +skipsdist = True +commands = flake8 . [testenv:docs] basepython=python