File tree 2 files changed +16
-1
lines changed
Filter options
2 files changed +16
-1
lines changed
Original file line number Diff line number Diff line change 20
20
21
21
__all__ = ["HTMLParser" , "parse" , "parseFragment" , "getTreeBuilder" ,
22
22
"getTreeWalker" , "serialize" ]
23
+
24
+ # this has to be at the top level, see how setup.py parses this
23
25
__version__ = "0.999999-dev"
Original file line number Diff line number Diff line change 1
1
from distutils .core import setup
2
+ import ast
2
3
import os
3
4
import codecs
4
5
29
30
with codecs .open (os .path .join (current_dir , 'CHANGES.rst' ), 'r' , 'utf8' ) as changes_file :
30
31
long_description = readme_file .read () + '\n ' + changes_file .read ()
31
32
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
+
32
45
setup (name = 'html5lib' ,
33
- version = '0.999999-dev' ,
46
+ version = version ,
34
47
url = 'https://github.com/html5lib/html5lib-python' ,
35
48
license = "MIT License" ,
36
49
description = 'HTML parser based on the WHATWG HTML specification' ,
You can’t perform that action at this time.
0 commit comments