Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from setup.cfg to pyproject.toml #11

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12']
django-version: ['3.2','4.0','4.1','4.2','5.0','main']
exclude:
# https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django
# Python 3.12 is not supported by Django < 4.0
- python-version: '3.12'
django-version: '3.2'
- python-version: '3.11'
django-version: '3.2'

steps:
- uses: actions/checkout@v3
Expand All @@ -26,11 +34,13 @@ jobs:


- name: Install tox
run: python -m pip install tox-gh>=1.2
run: python -m pip install tox tox-gh-actions
- name: Setup test suite
run: tox -vv --notest
- name: Run test suite
run: tox --skip-pkg-install
env:
DJANGO: ${{ matrix.django-version }}

lint:
name: Run black
Expand All @@ -42,7 +52,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.10'

- name: Install black
run: |
Expand Down
3 changes: 2 additions & 1 deletion django_group_role/management/commands/populate_roles.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.management.base import BaseCommand
from ...roles import registry, load_roles, BadRoleException
from ...exceptions import BadRoleException
from ...roles import registry, load_roles


def _fuzzy_search(rolenames):
Expand Down
8 changes: 2 additions & 6 deletions django_group_role/roles.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import inspect
from contextlib import nullcontext, suppress
from functools import partialmethod, reduce
from importlib import import_module

from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import cached_property

from .exceptions import BadRoleException
from .signals import post_role_setup, pre_role_setup
from .utils import get_permission, map_permissions

Expand Down Expand Up @@ -73,13 +71,11 @@ def group(self):
return group

@classmethod
def iter_perms(cls, catch=False):
context = suppress(BadRoleException) if catch else nullcontext()
def iter_perms(cls):
for app_label, app_perms in cls._permissions.items():
for modelname, perms in app_perms.items():
for perm in sorted(perms):
with context:
yield get_permission(perm, app_label, modelname)
yield get_permission(perm, app_label, modelname)

def setup_permissions(self, clear=False):
"""Assignes declared permissions to this role group.
Expand Down
3 changes: 2 additions & 1 deletion django_group_role/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.test import override_settings
from .roles import load_roles, registry, BadRoleException
from .exceptions import BadRoleException
from .roles import load_roles, registry


class RoleEnabledTestMixin:
Expand Down
110 changes: 110 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
version = "0.7.2"
authors = [
{"name"= "Davide Setti"},
]
description = "Django Group-based roles"
name = "django-group-role"
requires-python = ">=3.10"
dependencies = [
"django>=3.2,<5.1",
]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
]
dynamic = ["readme"]


[project.optional-dependencies]
tests = [
"coverage[toml]",
"pytest",
"pytest-django",
"pytest-cov",
"django-guardian~=2.4.0",
]

[project.urls]
"Homepage" = "https://github.com/certego/django-group-role"
"Bug Tracker" = "https://github.com/certego/django-group-role/issues"


[tool.setuptools]
packages = ["django_group_role"]

[tool.setuptools.dynamic]
readme = {file = ["README.md"]}

[tool.coverage.run]
omit = [
"*/migrations/*",
# do not check for templates
"*/templates/*",
# skip statics
"*/static/*",
"*/apps.py",
]

branch = true

source = [
"django_group_role",
]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "tests.example_project.settings"
django_find_project = false
pythonpath = "."

[tool.tox]
legacy_tox_ini = """
[tox]
envlist =
py{310}-django32
py{310,311,312}-django{40,41,42,50,main}

[gh]
python =
3.12 = py312
3.11 = py311
3.10 = py310

[gh-actions:env]
DJANGO =
3.2: dj32
4.0: dj40
4.1: dj41
4.2: dj42
5.0: dj50
main: djmain

[testenv]
package = editable
extras = tests
whitelist_externals = py.test
commands = py.test
deps=
django32: Django>=3.2,<3.3
django40: Django>=4.0,<4.1
django41: Django>=4.1,<4.2
django42: Django>=4.2,<4.3
django50: Django>=5.0a,<5.1
djmain: https://github.com/django/django/archive/main.tar.gz
"""
97 changes: 0 additions & 97 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

Loading