Skip to content

Commit

Permalink
:update: simplify the use of __version__
Browse files Browse the repository at this point in the history
  • Loading branch information
b3j0f committed Sep 30, 2015
1 parent 60beab6 commit abe6d9d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
5 changes: 1 addition & 4 deletions b3j0f/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,4 @@

__all__ = ['__version_info__', '__version__']

#: project version info
__version_info__ = 0, 10, 3, "beta", 0
#: project version
__version__ = ".".join(str(v) for v in __version_info__[:3])
from .version import __version__, __version_info__
13 changes: 13 additions & 0 deletions b3j0f/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,25 @@
from platform import python_implementation

__all__ = [
'__version_info__', '__version__', # lib version
'PY3', 'PY2', 'PY26', 'PY27', # python versions
'PYPY', 'CPYTHON', 'JYTHON', 'IRONPYTHON', # python runtime types
'basestring', 'getcallargs', 'OrderedDict', # python2.7 objects
'range', 'raw_input', 'xrange'
]

# Store the version here so:
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into the utils module
# thanks to https://github.com/pycontribs/jira/blob/master/jira/version.py

#: project version info
__version_info__ = 0, 10, 3, 'beta', 0
#: project version
__version__ = '0.10.3'


PY3 = version_info[0] == 3 #: python3
PY2 = version_info[0] == 2 #: python2
PY26 = PY2 and version_info[1] == 6 #: python2.6
Expand Down
26 changes: 22 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,26 @@

from os.path import abspath, dirname, join

from re import compile as re_compile, re_S

NAME = 'b3j0f.utils' # library name

_namepath = NAME.replace('.', '/')

_base_path = dirname(abspath(__file__))

# get long description from setup directory abspath
with open(join(dirname(abspath(__file__)), 'README.rst')) as f:
with open(join(_base_path, 'README.rst')) as f:
DESC = f.read()

# Get the version - do not use normal import because it does break coverage
# thanks to the python jira project
# (https://github.com/pycontribs/jira/blob/master/setup.py)
with open(join(_base_path, _namepath, 'version.py')) as f:
stream = f.read()
regex = r".*__version__ = '(.*?)'"
VERSION = re_compile(regex, re_S).match(stream).group(1)

KEYWORDS = [
'utils', 'chaining', 'iterable', 'tools', 'path', 'property', 'dynamic',
'reflection', 'reflect', 'runtime', 'unittest', 'unit test', 'version',
Expand All @@ -47,17 +63,19 @@

DESCRIPTION = 'Set of tools and utilities useful in python projects'

URL = 'https://github.com/{0}'.format(_namepath)

setup(
name='b3j0f.utils',
version='0.10.3',
name=NAME,
version=VERSION,
packages=find_packages(exclude=['test.*', '*.test.*']),
author='b3j0f',
author_email='jlabejof@yahoo.fr',
install_requires=DEPENDENCIES,
description=DESCRIPTION,
long_description=DESC,
include_package_data=True,
url='https://github.com/b3j0f/utils/',
url=URL,
license='MIT License',
classifiers=[
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit abe6d9d

Please sign in to comment.