Skip to content

Commit

Permalink
Merge pull request #555 from PacificGilly/jamesgilmore/fix-version-id…
Browse files Browse the repository at this point in the history
…entifier

Fix displaying the installed version of Django-Jazzmin in the UI.
  • Loading branch information
PacificGilly authored Mar 30, 2024
2 parents 5a22e0a + ed8d3ba commit 7e353f5
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 31 deletions.
15 changes: 14 additions & 1 deletion jazzmin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import django
import sys

# We automatically grab the version of `django-jazzmin` from the package manager instead of
# hard coding it. The method for determining the version changed since PY3.8. N.B. For
# development versions of `django-jazzmin`, the version will be 0.0.0 (see pyproject.toml) as it's
# not technically installed.
if sys.version_info >= (3, 8):
from importlib.metadata import version as package_version

version = package_version("django-jazzmin")
else:
import pkg_resources

version = pkg_resources.get_distribution("django-jazzmin").version

version = "2.6.1"

if django.VERSION < (3, 2):
default_app_config = "jazzmin.apps.JazzminConfig"
56 changes: 31 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@ exclude = ["tests", "docs"]
python = ">=3.7"
django = ">=3"

[tool.poetry.group.dev.dependencies]
pytest-cov = "^4.1.0"

[tool.black]
line-length = 120
target-version = ['py310']

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
django-debug-toolbar = "^3.2.4" # unparallelled debugging in django
Werkzeug = "^2.0.2" # support for werkzeug debugger in runserver_plus
django-extensions = "^3.1.5" # Django Sugar for development
Expand All @@ -65,7 +62,7 @@ factory-boy = "^3.2.1" # Factory generation
mypy = "^0.931" # Type checking
click = "^8.0.3" # Framework for building cli's
ipdb = "^0.13.9" # ipython breakpoints
black = "^21.12b0" # Code formatting and linting (with pyproject.toml support)
black = "^22.3.0" # Code formatting and linting (with pyproject.toml support)

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/farridav/django-jazzmin/issues"
Expand Down Expand Up @@ -120,6 +117,7 @@ commands =
{envpython} -m flake8 jazzmin --max-line-length 120
{envpython} -m pytest
deps =
django-jazzmin # Installing self to allow automatic getting of `version` which needs `django-jazzmin` to be install to get information about the package.
flake9
pytest
pytest-django
Expand All @@ -146,3 +144,10 @@ commands =
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"


[[tool.mypy.overrides]]
module = [
"pkg_resources.*",
]
ignore_missing_imports = true
8 changes: 8 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import jazzmin


def test_version():
"""
Tests getting the version of the installed package in all versions of Python we support.
"""
assert jazzmin.version >= "0.0.0"

0 comments on commit 7e353f5

Please sign in to comment.