@task
def patch_version(vs, path=pjoin(here, '..')):
 v = parse_vs(vs)
 version_py = pjoin(path, 'jupyterhub', 'version.py')
 print ('patching %s with %s' % (version_py, vs))
 with open(version_py) as f:
  pre_lines = []
  post_lines = []
  for line in f:
   pre_lines.append(line)
   if line.startswith('version_info'):
    break
  for line in f:
   if line.startswith(')'):
    post_lines.append(line)
    break
  for line in f:
   post_lines.append(line)
 with open(version_py, 'w') as f:
  for line in pre_lines:
   f.write(line)
  for part in v:
   f.write(('    %r,\n' % part))
  for line in post_lines:
   f.write(line)
 ns = {}
 with open(version_py) as f:
  exec f.read() in {}, ns
 assert (ns['__version__'] == vs), ('%r != %r' % (ns['__version__'], vs))

@ task def patch_version ( vs , path = pjoin ( here , '..' ) ) : v = parse_vs ( vs ) version_py = pjoin ( path , 'jupyterhub' , 'version.py' ) print ( 'patching %s with %s' % ( version_py , vs ) ) with open ( version_py ) as f : pre_lines = [ ] post_lines = [ ] for line in f : pre_lines . append ( line ) if line . startswith ( 'version_info' ) : break for line in f : if line . startswith ( ')' ) : post_lines . append ( line ) break for line in f : post_lines . append ( line ) with open ( version_py , 'w' ) as f : for line in pre_lines : f . write ( line ) for part in v : f . write ( ( '    %r,\n' % part ) ) for line in post_lines : f . write ( line ) ns = { } with open ( version_py ) as f : exec f . read ( ) in { } , ns assert ( ns [ '__version__' ] == vs ) , ( '%r != %r' % ( ns [ '__version__' ] , vs ) )
patch zmq/sugar/version .