Skip to content

Commit af05d66

Browse files
committed
Add __version__ to top level module. Closes hardbyte#142
Use same version within the setup script and documentation.
1 parent 8040b8c commit af05d66

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

can/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
can is an object-orient Controller Area Network interface module.
33
"""
44
import logging
5+
6+
__version__ = "2.0.0-alpha.2"
7+
58
log = logging.getLogger('can')
69

710
rc = dict()

can/util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ def load_file_config(path=None):
5454
interface = socketcan
5555
channel = can0
5656
57-
:param path: path to config file. If not specified, several sensible
58-
default locations are tried depending on platform.
57+
:param path:
58+
path to config file. If not specified, several sensible
59+
default locations are tried depending on platform.
60+
5961
"""
6062
config = ConfigParser()
6163
if path is None:

doc/conf.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
# General information about the project.
1111
project = u'python-can'
1212

13-
# The version info for the project you're documenting, acts as replacement for
14-
# |version| and |release|, also used in various other places throughout the
15-
# built documents.
16-
#
17-
# The short X.Y version.
18-
version = '2.0'
19-
# The full version, including alpha/beta/rc tags.
20-
release = '2.0.0-alpha.1'
21-
2213
# If extensions (or modules to document with autodoc) are in another directory,
2314
# add these directories to sys.path here. If the directory is relative to the
2415
# documentation root, use os.path.abspath to make it absolute, like shown here.
2516
sys.path.insert(0, os.path.abspath('..'))
2617

18+
import can
19+
# The version info for the project, acts as replacement for
20+
# |version| and |release|, also used in various other places throughout the
21+
# built documents.
22+
#
23+
# The short X.Y version.
24+
version = can.__version__.split('-')[0]
25+
release = can.__version__
26+
2727
# -- General configuration -----------------------------------------------------
2828

2929
# Add any Sphinx extension module names here, as strings. They can be extensions
@@ -102,15 +102,9 @@
102102
# The default autodoc directive flags
103103
autodoc_default_flags = ['members', 'show-inheritance']
104104

105-
# TODO: Enable links to python standard library docs
106-
#intersphinx_mapping = {}
107-
108105
# Keep cached intersphinx inventories indefinitely
109106
intersphinx_cache_limit = -1
110107

111-
# Include todos in the output
112-
todo_include_todos = True
113-
114108
# -- Options for HTML output --------------------------------------------------
115109

116110
# The theme to use for HTML and HTML Help pages. See the documentation for

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
"""
22
python-can requires the setuptools package to be installed.
33
"""
4-
4+
import re
55
import logging
66
from setuptools import setup, find_packages
77

8-
__version__ = "2.0.0-alpha.1"
8+
with open('can/__init__.py', 'r') as fd:
9+
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
10+
fd.read(), re.MULTILINE).group(1)
11+
912

1013
logging.basicConfig(level=logging.WARNING)
1114

1215
setup(
1316
name="python-can",
1417
url="https://github.com/hardbyte/python-can",
15-
version=__version__,
18+
version=version,
1619
packages=find_packages(),
1720
author="Brian Thorne",
1821
author_email="hardbyte@gmail.com",

0 commit comments

Comments
 (0)