Skip to content

Commit 21d4601

Browse files
cookiecutter template to use import metadata to retrieve the version
1 parent fd56690 commit 21d4601

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

{{cookiecutter.package_name}}/docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-e .
12
linkify-it-py
23
myst-parser
34
nbsphinx

{{cookiecutter.package_name}}/docs/source/conf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import sys
1111

12-
import setuptools_scm
12+
from importlib.metadata import version as get_version
1313

1414
# Used when building API docs, put the dependencies
1515
# of any class you are documenting here
@@ -24,7 +24,9 @@
2424
copyright = "2022, {{cookiecutter.full_name}}"
2525
author = "{{cookiecutter.full_name}}"
2626
try:
27-
release = setuptools_scm.get_version(root="../..", relative_to=__file__)
27+
full_version = get_version(project)
28+
# Splitting the release on '+' to remove the commit hash
29+
release = full_version.split('+', 1)[0]
2830
except LookupError:
2931
# if git is not initialised, still allow local build
3032
# with a dummy version

0 commit comments

Comments
 (0)