Add __version__ to mopidy module

This commit is contained in:
Stein Magnus Jodal 2012-03-04 23:26:24 +01:00
parent 42d41d6fe7
commit ee0c7c1af5
5 changed files with 26 additions and 18 deletions

View File

@ -4,8 +4,8 @@ Changes
This change log is used to track all major changes to Mopidy.
v0.8.0 (in development)
=======================
v0.8 (in development)
=====================
**Important changes**
@ -13,7 +13,8 @@ v0.8.0 (in development)
**Changes**
- Nothing so far
- Change from version tuple at :attr:`mopidy.VERSION` to :pep:`386` compliant
version string at :attr:`mopidy.__version__` to conform to :pep:`396`.
v0.7.0 (2012-02-25)

View File

@ -11,7 +11,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
import os
import re
import sys
class Mock(object):
def __init__(self, *args, **kwargs):
@ -49,6 +51,11 @@ MOCK_MODULES = [
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = Mock()
def get_version():
init_py = open('../mopidy/__init__.py').read()
metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", init_py))
return metadata['version']
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
@ -87,8 +94,7 @@ copyright = u'2010-2012, Stein Magnus Jodal and contributors'
# built documents.
#
# The full version, including alpha/beta/rc tags.
import mopidy
release = mopidy.get_version()
release = get_version()
# The short X.Y version.
version = '.'.join(release.split('.')[:2])

View File

@ -1,14 +1,14 @@
import platform
import sys
if not (2, 6) <= sys.version_info < (3,):
sys.exit(u'Mopidy requires Python >= 2.6, < 3')
import glib
import os
import platform
from subprocess import PIPE, Popen
VERSION = (0, 8, 0)
import glib
__version__ = '0.8'
DATA_PATH = os.path.join(str(glib.get_user_data_dir()), 'mopidy')
CACHE_PATH = os.path.join(str(glib.get_user_cache_dir()), 'mopidy')
@ -30,9 +30,6 @@ def get_git_version():
version = version[1:]
return version
def get_plain_version():
return '.'.join(map(str, VERSION))
def get_platform():
return platform.platform()

View File

@ -6,9 +6,13 @@ from distutils.core import setup
from distutils.command.install_data import install_data
from distutils.command.install import INSTALL_SCHEMES
import os
import re
import sys
from mopidy import get_version
def get_version():
init_py = open('mopidy/__init__.py').read()
metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", init_py))
return metadata['version']
class osx_install_data(install_data):
# On MacOS, the platform-specific lib dir is

View File

@ -1,14 +1,14 @@
from distutils.version import StrictVersion as SV
import platform
from mopidy import get_plain_version, get_platform, get_python
from mopidy import __version__, get_platform, get_python
from tests import unittest
class VersionTest(unittest.TestCase):
def test_current_version_is_parsable_as_a_strict_version_number(self):
SV(get_plain_version())
SV(__version__)
def test_versions_can_be_strictly_ordered(self):
self.assert_(SV('0.1.0a0') < SV('0.1.0a1'))
@ -25,8 +25,8 @@ class VersionTest(unittest.TestCase):
self.assert_(SV('0.5.0') < SV('0.6.0'))
self.assert_(SV('0.6.0') < SV('0.6.1'))
self.assert_(SV('0.6.1') < SV('0.7.0'))
self.assert_(SV('0.7.0') < SV(get_plain_version()))
self.assert_(SV(get_plain_version()) < SV('0.8.1'))
self.assert_(SV('0.7.0') < SV(__version__))
self.assert_(SV(__version__) < SV('0.8.1'))
def test_get_platform_contains_platform(self):
self.assert_(platform.platform() in get_platform())