Skip to content

Commit 9a5f019

Browse files
humitosagjohnson
authored andcommitted
Make get_version usable from a specified path (readthedocs#4376)
* Make `get_version` usable from a specified path * Adapt analytics code to get the version from __version__
1 parent 1b43ee4 commit 9a5f019

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

readthedocs/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
from readthedocs.worker import app # noqa
1010

1111

12-
def get_version():
12+
def get_version(setupcfg_path):
1313
"""Return package version from setup.cfg."""
14-
setupcfg_path = os.path.abspath(
15-
os.path.join(os.path.dirname(__file__), '..', 'setup.cfg'),
16-
)
1714
config = RawConfigParser()
1815
config.read(setupcfg_path)
1916
return config.get('metadata', 'version')
2017

2118

22-
__version__ = get_version()
19+
__version__ = get_version(
20+
os.path.abspath(
21+
os.path.join(os.path.dirname(__file__), '..', 'setup.cfg'),
22+
),
23+
)

readthedocs/analytics/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from django.conf import settings
66

7-
from readthedocs import get_version
7+
import readthedocs
88
from readthedocs.worker import app
99

1010
from .utils import send_to_analytics
@@ -21,7 +21,7 @@
2121

2222
# Application info
2323
'an': 'Read the Docs',
24-
'av': get_version(), # App version
24+
'av': readthedocs.__version__, # App version
2525
}
2626

2727

0 commit comments

Comments
 (0)