Skip to content

Commit

Permalink
Move to pyproject
Browse files Browse the repository at this point in the history
  • Loading branch information
sevdog committed Jul 31, 2024
1 parent 5e21e10 commit 09ed4fd
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 111 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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']

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -42,7 +42,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
102 changes: 102 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[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,master}
[gh]
python =
3.12 = py312
3.11 = py311
3.10 = py310
[testenv]
package = editable
extras = tests
whitelist_externals = py.test
commands = py.test
deps=
django32: Django>=3.2,<3.3
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
djangomaster: 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.

0 comments on commit 09ed4fd

Please sign in to comment.