mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +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:
|
python:
|
||||||
install:
|
install:
|
||||||
- requirements: docs/requirements.txt
|
- 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
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
with open("../pyproject.toml") as f:
|
# Try to get version from installed package metadata
|
||||||
for line in f:
|
try:
|
||||||
match = re.match(r'version = "(.*)"', line)
|
from importlib.metadata import version
|
||||||
if match:
|
|
||||||
return match.group(1)
|
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"
|
return "0.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue