<s> """<STR_LIT>""" <EOL> import subprocess <EOL> import os , sys <EOL> import platform <EOL> import argparse <EOL> import re <EOL> import shutil <EOL> BITS = platform . architecture ( ) [ <NUM_LIT:0> ] <EOL> assert ( BITS == "<STR_LIT>" or BITS == "<STR_LIT>" ) <EOL> ARCHITECTURE = "<STR_LIT>" if ( BITS == "<STR_LIT>" ) else "<STR_LIT>" <EOL> if BITS == "<STR_LIT>" : <EOL> LINUX_BITS = "<STR_LIT>" <EOL> else : <EOL> LINUX_BITS = "<STR_LIT>" <EOL> PACKAGE_NAME = "<STR_LIT>" <EOL> PYTHON_NAME = "<STR_LIT>" <EOL> HOMEPAGE = "<STR_LIT>" <EOL> MAINTAINER = "<STR_LIT>" <EOL> DESCRIPTION_EXTENDED = """<STR_LIT>""" <EOL> COPYRIGHT = """<STR_LIT>""" % ( MAINTAINER , HOMEPAGE ) <EOL> PYTHON_VERSION_WITH_DOT = ( str ( sys . version_info . major ) + "<STR_LIT:.>" <EOL> + str ( sys . version_info . minor ) ) <EOL> VERSION = None <EOL> INSTALLER = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> DISTUTILS_SETUP = None <EOL> DEB_DIST = None <EOL> DEB_DIST_PACKAGE = None <EOL> DEBIAN = None <EOL> DEBIAN_PACKAGE = None <EOL> def log ( msg ) : <EOL> print ( "<STR_LIT>" % msg ) <EOL> def replace_in_file ( f_path , s_what , s_with ) : <EOL> contents = "<STR_LIT>" <EOL> with open ( f_path , "<STR_LIT:r>" ) as f : <EOL> contents = f . read ( ) <EOL> assert contents , ( "<STR_LIT>" % f_path ) <EOL> contents = contents . replace ( s_what , s_with ) <EOL> with open ( f_path , "<STR_LIT:w>" ) as f : <EOL> f . write ( contents ) <EOL> def remove_directories_from_previous_run ( ) : <EOL> if os . path . exists ( DISTUTILS_SETUP ) : <EOL> log ( "<STR_LIT>" ) <EOL> shutil . rmtree ( DISTUTILS_SETUP ) <EOL> if os . path . exists ( INSTALLER + "<STR_LIT>" ) : <EOL> log ( "<STR_LIT>" ) <EOL> shutil . rmtree ( INSTALLER + "<STR_LIT>" ) <EOL> if os . path . exists ( INSTALLER + "<STR_LIT>" ) : <EOL> log ( "<STR_LIT>" ) <EOL> shutil . rmtree ( INSTALLER + "<STR_LIT>" ) <EOL> def create_distutils_setup_package ( ) : <EOL> log ( "<STR_LIT>" ) <EOL> subprocess . call ( "<STR_LIT>" % ( sys . executable , INSTALLER , VERSION ) , shell = True ) <EOL> assert os . path . exists ( DISTUTILS_SETUP ) , "<STR_LIT>" <EOL> def modify_control_file ( ) : <EOL> log ( "<STR_LIT>" ) <EOL> control_file = DEBIAN + "<STR_LIT>" <EOL> with open ( control_file , "<STR_LIT:r>" ) as f : <EOL> contents = f . read ( ) <EOL> contents = contents . replace ( "<STR_LIT>" , <EOL> "<STR_LIT>" % ARCHITECTURE ) <EOL> contents = re . sub ( "<STR_LIT>" , "<STR_LIT>" , contents ) <EOL> contents += "<STR_LIT:\n>" <EOL> description = DESCRIPTION_EXTENDED <EOL> description = re . sub ( "<STR_LIT>" , "<STR_LIT:\n>" , description ) <EOL> description = re . sub ( "<STR_LIT>" , "<STR_LIT>" , description ) <EOL> contents += "<STR_LIT>" % description <EOL> contents += "<STR_LIT>" % VERSION <EOL> contents += "<STR_LIT>" % MAINTAINER <EOL> contents += "<STR_LIT>" % HOMEPAGE <EOL> contents += "<STR_LIT:\n>" <EOL> with open ( control_file , "<STR_LIT:w>" ) as f : <EOL> f . write ( contents ) <EOL> def create_copyright_file ( ) : <EOL> log ( "<STR_LIT>" ) <EOL> copyright = COPYRIGHT <EOL> copyright = re . sub ( "<STR_LIT>" , "<STR_LIT:\n>" , copyright ) <EOL> copyright += "<STR_LIT:\n>" <EOL> copyright += "<STR_LIT>" <EOL> with open ( INSTALLER + "<STR_LIT>" , "<STR_LIT:r>" ) as f : <EOL> license = f . readlines ( ) <EOL> for line in license : <EOL> if not len ( re . sub ( "<STR_LIT>" , "<STR_LIT>" , line ) ) : <EOL> copyright += "<STR_LIT>" <EOL> else : <EOL> copyright += "<STR_LIT:U+0020>" + line . rstrip ( ) + "<STR_LIT:\n>" <EOL> copyright += "<STR_LIT:\n>" <EOL> with open ( DEBIAN + "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( copyright ) <EOL> def copy_postinst_script ( ) : <EOL> log ( "<STR_LIT>" ) <EOL> shutil . copy ( INSTALLER + "<STR_LIT>" , <EOL> DEBIAN + "<STR_LIT>" % ( PACKAGE_NAME ) ) <EOL> def create_debian_source_package ( ) : <EOL> log ( "<STR_LIT>" ) <EOL> os . chdir ( DISTUTILS_SETUP ) <EOL> shutil . copy ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> stdeb_cfg_add_deps ( "<STR_LIT>" ) <EOL> subprocess . call ( "<STR_LIT>" % ( sys . executable , ) , shell = True ) <EOL> def stdeb_cfg_add_deps ( stdeb_cfg ) : <EOL> log ( "<STR_LIT>" ) <EOL> with open ( INSTALLER + "<STR_LIT>" , "<STR_LIT:r>" ) as f : <EOL> deps = f . read ( ) <EOL> deps = deps . strip ( ) <EOL> deps = deps . splitlines ( ) <EOL> for i , dep in enumerate ( deps ) : <EOL> deps [ i ] = dep . strip ( ) <EOL> deps = "<STR_LIT:U+002CU+0020>" . join ( deps ) <EOL> with open ( stdeb_cfg , "<STR_LIT:a>" ) as f : <EOL> f . write ( "<STR_LIT>" % deps ) <EOL> def deb_dist_cleanup ( ) : <EOL> log ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" % ( DISTUTILS_SETUP + "<STR_LIT>" , INSTALLER + "<STR_LIT>" ) ) <EOL> os . system ( "<STR_LIT>" % DISTUTILS_SETUP ) <EOL> global DEB_DIST , DEB_DIST_PACKAGE , DEBIAN , DEBIAN_PACKAGE <EOL> DEB_DIST = INSTALLER + "<STR_LIT>" <EOL> DEB_DIST_PACKAGE = DEB_DIST + "<STR_LIT:/>" + PACKAGE_NAME + "<STR_LIT:->" + VERSION <EOL> DEBIAN = DEB_DIST_PACKAGE + "<STR_LIT>" <EOL> DEBIAN_PACKAGE = DEBIAN + "<STR_LIT>" + PACKAGE_NAME <EOL> os . chdir ( DEB_DIST ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> def create_debian_binary_package ( ) : <EOL> os . chdir ( DEB_DIST_PACKAGE ) <EOL> subprocess . call ( "<STR_LIT>" , shell = True ) <EOL> def modify_deb_archive ( ) : <EOL> log ( "<STR_LIT>" ) <EOL> deb_archive_name = "<STR_LIT>" % ( PACKAGE_NAME , VERSION , ARCHITECTURE ) <EOL> deb_archive_dir = INSTALLER + "<STR_LIT>" <EOL> log ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" % deb_archive_dir ) <EOL> os . system ( "<STR_LIT>" % ( DEB_DIST + "<STR_LIT:/>" + deb_archive_name , deb_archive_dir + "<STR_LIT:/>" + deb_archive_name ) ) <EOL> os . system ( "<STR_LIT>" % DEB_DIST ) <EOL> log ( "<STR_LIT>" ) <EOL> os . chdir ( deb_archive_dir ) <EOL> os . system ( "<STR_LIT>" % deb_archive_name ) <EOL> os . system ( "<STR_LIT>" % deb_archive_name ) <EOL> os . system ( "<STR_LIT>" % deb_archive_name ) <EOL> log ( "<STR_LIT>" ) <EOL> lib_pyshared = "<STR_LIT>" % ( PYTHON_NAME , PACKAGE_NAME ) <EOL> share_pyshared = "<STR_LIT>" % PACKAGE_NAME <EOL> os . system ( "<STR_LIT>" % ( lib_pyshared , share_pyshared ) ) <EOL> os . system ( "<STR_LIT>" ) <EOL> log ( "<STR_LIT>" ) <EOL> old_path = "<STR_LIT>" % ( PYTHON_NAME , PACKAGE_NAME ) <EOL> new_path = "<STR_LIT>" % PACKAGE_NAME <EOL> md5sums_file = "<STR_LIT>" <EOL> cefpython3_public_file = "<STR_LIT>" % PACKAGE_NAME <EOL> old_md5sum = subprocess . check_output ( "<STR_LIT>" % cefpython3_public_file , shell = True ) . strip ( ) <EOL> replace_in_file ( md5sums_file , old_path , new_path ) <EOL> replace_in_file ( cefpython3_public_file , old_path , new_path ) <EOL> new_md5sum = subprocess . check_output ( "<STR_LIT>" % cefpython3_public_file , shell = True ) . strip ( ) <EOL> replace_in_file ( md5sums_file , old_md5sum , new_md5sum ) <EOL> log ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" % deb_archive_name ) <EOL> def main ( ) : <EOL> parser = argparse . ArgumentParser ( usage = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = "<STR_LIT>" , <EOL> required = True ) <EOL> args = parser . parse_args ( ) <EOL> assert re . search ( r"<STR_LIT>" , args . version ) , ( <EOL> "<STR_LIT>" ) <EOL> global VERSION <EOL> VERSION = args . version <EOL> global DISTUTILS_SETUP <EOL> DISTUTILS_SETUP = INSTALLER + "<STR_LIT:/>" + PACKAGE_NAME + "<STR_LIT:->" + args . version + "<STR_LIT:->" + LINUX_BITS + "<STR_LIT>" <EOL> remove_directories_from_previous_run ( ) <EOL> create_distutils_setup_package ( ) <EOL> create_debian_source_package ( ) <EOL> deb_dist_cleanup ( ) <EOL> modify_control_file ( ) <EOL> create_copyright_file ( ) <EOL> copy_postinst_script ( ) <EOL> create_debian_binary_package ( ) <EOL> modify_deb_archive ( ) <EOL> log ( "<STR_LIT>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
