Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9e91591

Browse filesBrowse files
committed
Fix #187: store the version at a single place in the tree.
1 parent 5e3d432 commit 9e91591
Copy full SHA for 9e91591

File tree

2 files changed

+16
-1
lines changed
Filter options

2 files changed

+16
-1
lines changed

‎html5lib/__init__.py

Copy file name to clipboardExpand all lines: html5lib/__init__.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020

2121
__all__ = ["HTMLParser", "parse", "parseFragment", "getTreeBuilder",
2222
"getTreeWalker", "serialize"]
23+
24+
# this has to be at the top level, see how setup.py parses this
2325
__version__ = "0.999999-dev"

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from distutils.core import setup
2+
import ast
23
import os
34
import codecs
45

@@ -29,8 +30,20 @@
2930
with codecs.open(os.path.join(current_dir, 'CHANGES.rst'), 'r', 'utf8') as changes_file:
3031
long_description = readme_file.read() + '\n' + changes_file.read()
3132

33+
version = None
34+
with open(os.path.join("html5lib", "__init__.py"), "rb") as init_file:
35+
t = ast.parse(init_file.read(), filename="__init__.py", mode="exec")
36+
assert isinstance(t, ast.Module)
37+
assignments = filter(lambda x: isinstance(x, ast.Assign), t.body)
38+
for a in assignments:
39+
if (len(a.targets) == 1 and
40+
isinstance(a.targets[0], ast.Name) and
41+
a.targets[0].id == "__version__" and
42+
isinstance(a.value, ast.Str)):
43+
version = a.value.s
44+
3245
setup(name='html5lib',
33-
version='0.999999-dev',
46+
version=version,
3447
url='https://github.com/html5lib/html5lib-python',
3548
license="MIT License",
3649
description='HTML parser based on the WHATWG HTML specification',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.