mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 14:30:23 +00:00
Display correct version in docs
This commit is contained in:
parent
9c3bcbf247
commit
886c00c1a2
2 changed files with 18 additions and 6 deletions
|
|
@ -14,3 +14,5 @@ sphinx:
|
|||
python:
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
- method: pip
|
||||
path: .
|
||||
|
|
|
|||
22
docs/conf.py
22
docs/conf.py
|
|
@ -4,17 +4,27 @@
|
|||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def get_version():
|
||||
with open("../pyproject.toml") as f:
|
||||
for line in f:
|
||||
match = re.match(r'version = "(.*)"', line)
|
||||
if match:
|
||||
return match.group(1)
|
||||
# Try to get version from installed package metadata
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
|
||||
return version("django-constance")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Fall back to setuptools_scm generated version file
|
||||
try:
|
||||
from constance._version import __version__
|
||||
|
||||
return __version__
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
return "0.0.0"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue