Skip to content

Commit c05ec00

Browse files
committed
fixup! build: Invert version fetching.
1 parent dbdad01 commit c05ec00

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

backend/docs/conf.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,13 @@
1818
from subprocess import check_call
1919

2020
from django import setup as django_setup
21-
22-
23-
def get_version(*file_paths):
24-
"""
25-
Extract the version string from the file.
26-
27-
Input:
28-
- file_paths: relative path fragments to file with
29-
version string
30-
"""
31-
filename = os.path.join(os.path.dirname(__file__), *file_paths)
32-
version_file = open(filename, encoding="utf8").read()
33-
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
34-
if version_match:
35-
return version_match.group(1)
36-
raise RuntimeError('Unable to find version string.')
21+
from importlib.metadata import version as get_version
3722

3823

3924
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4025
sys.path.append(REPO_ROOT)
4126

42-
VERSION = get_version('../sample_plugin', '__init__.py')
27+
VERSION = get_version('openedx-sample-plugin')
4328
# Configure Django for autodoc usage
4429
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'
4530
django_setup()

0 commit comments

Comments
 (0)