1
1
#!/usr/bin/env python
2
2
3
- import os , base64 , tempfile , StringIO
3
+ import os , base64 , tempfile
4
4
from distutils .core import setup , Command
5
5
from distutils .command .build_scripts import build_scripts
6
6
@@ -23,29 +23,29 @@ def generate_versioneer():
23
23
vcs = "git"
24
24
if vcs not in ("git" ,):
25
25
raise ValueError ("Unhandled revision-control system '%s'" % vcs )
26
- f = StringIO . StringIO ()
27
- f . write (readme (ver (get ("src/header.py" ))))
28
- f . write ('VCS = "%s"\n ' % vcs )
29
- f . write ("\n \n " )
26
+ out = []
27
+ out . append (readme (ver (get ("src/header.py" ))))
28
+ out . append ('VCS = "%s"\n ' % vcs )
29
+ out . append ("\n \n " )
30
30
for line in open ("src/%s/long-version.py" % vcs , "r" ).readlines ():
31
31
if line .startswith ("#### START" ):
32
- f . write ("LONG_VERSION_PY = '''\n " )
32
+ out . append ("LONG_VERSION_PY = '''\n " )
33
33
elif line .startswith ("#### SUBPROCESS_HELPER" ):
34
- f . write (unquote (get ("src/subprocess_helper.py" )))
34
+ out . append (unquote (get ("src/subprocess_helper.py" )))
35
35
elif line .startswith ("#### MIDDLE" ):
36
- f . write (unquote (get ("src/%s/middle.py" % vcs )))
36
+ out . append (unquote (get ("src/%s/middle.py" % vcs )))
37
37
elif line .startswith ("#### PARENTDIR" ):
38
- f . write (unquote (get ("src/parentdir.py" )))
38
+ out . append (unquote (get ("src/parentdir.py" )))
39
39
elif line .startswith ("#### END" ):
40
- f . write ("'''\n " )
40
+ out . append ("'''\n " )
41
41
else :
42
- f . write (ver (line ))
43
- f . write (get ("src/subprocess_helper.py" ))
44
- f . write (get ("src/%s/middle.py" % vcs ))
45
- f . write (get ("src/parentdir.py" ))
46
- f . write (get ("src/%s/install.py" % vcs ))
47
- f . write (ver (get ("src/trailer.py" )))
48
- return f . getvalue ( )
42
+ out . append (ver (line ))
43
+ out . append (get ("src/subprocess_helper.py" ))
44
+ out . append (get ("src/%s/middle.py" % vcs ))
45
+ out . append (get ("src/parentdir.py" ))
46
+ out . append (get ("src/%s/install.py" % vcs ))
47
+ out . append (ver (get ("src/trailer.py" )))
48
+ return ( "" . join ( out )). encode ( "utf-8" )
49
49
50
50
51
51
class make_versioneer (Command ):
@@ -64,7 +64,7 @@ def run(self):
64
64
class my_build_scripts (build_scripts ):
65
65
def run (self ):
66
66
v = generate_versioneer ()
67
- v_b64 = base64 .b64encode (v )
67
+ v_b64 = base64 .b64encode (v ). decode ( "ascii" )
68
68
lines = [v_b64 [i :i + 60 ] for i in range (0 , len (v_b64 ), 60 )]
69
69
v_b64 = "\n " .join (lines )+ "\n "
70
70
0 commit comments