File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818from subprocess import check_call
1919
2020from 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
3924REPO_ROOT = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
4025sys .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
4429os .environ ['DJANGO_SETTINGS_MODULE' ] = 'test_settings'
4530django_setup ()
You can’t perform that action at this time.
0 commit comments