Make `get_version` usable from a specified path (#4376)

* Make `get_version` usable from a specified path

* Adapt analytics code to get the version from __version__
humitos/git/unicode-branches
Manuel Kaufmann 2018-07-19 22:23:41 -03:00 committed by Anthony
parent 1b43ee4a7d
commit 9a5f019a4c
2 changed files with 8 additions and 7 deletions

View File

@ -9,14 +9,15 @@ from future.moves.configparser import RawConfigParser
from readthedocs.worker import app # noqa
def get_version():
def get_version(setupcfg_path):
"""Return package version from setup.cfg."""
setupcfg_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', 'setup.cfg'),
)
config = RawConfigParser()
config.read(setupcfg_path)
return config.get('metadata', 'version')
__version__ = get_version()
__version__ = get_version(
os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', 'setup.cfg'),
),
)

View File

@ -4,7 +4,7 @@ from __future__ import absolute_import
from django.conf import settings
from readthedocs import get_version
import readthedocs
from readthedocs.worker import app
from .utils import send_to_analytics
@ -21,7 +21,7 @@ DEFAULT_PARAMETERS = {
# Application info
'an': 'Read the Docs',
'av': get_version(), # App version
'av': readthedocs.__version__, # App version
}