<s> from distutils . command . install_scripts import install_scripts as _install_scripts <EOL> from pkg_resources import Distribution , PathMetadata , ensure_directory <EOL> import os <EOL> from distutils import log <EOL> class install_scripts ( _install_scripts ) : <EOL> """<STR_LIT>""" <EOL> def initialize_options ( self ) : <EOL> _install_scripts . initialize_options ( self ) <EOL> self . no_ep = False <EOL> def run ( self ) : <EOL> from setuptools . command . easy_install import get_script_args <EOL> from setuptools . command . easy_install import sys_executable <EOL> self . run_command ( "<STR_LIT>" ) <EOL> if self . distribution . scripts : <EOL> _install_scripts . run ( self ) <EOL> else : <EOL> self . outfiles = [ ] <EOL> if self . no_ep : <EOL> return <EOL> ei_cmd = self . get_finalized_command ( "<STR_LIT>" ) <EOL> dist = Distribution ( <EOL> ei_cmd . egg_base , PathMetadata ( ei_cmd . egg_base , ei_cmd . egg_info ) , <EOL> ei_cmd . egg_name , ei_cmd . egg_version , <EOL> ) <EOL> bs_cmd = self . get_finalized_command ( '<STR_LIT>' ) <EOL> executable = getattr ( bs_cmd , '<STR_LIT>' , sys_executable ) <EOL> is_wininst = getattr ( <EOL> self . get_finalized_command ( "<STR_LIT>" ) , '<STR_LIT>' , False <EOL> ) <EOL> for args in get_script_args ( dist , executable , is_wininst ) : <EOL> self . write_script ( * args ) <EOL> def write_script ( self , script_name , contents , mode = "<STR_LIT:t>" , * ignored ) : <EOL> """<STR_LIT>""" <EOL> from setuptools . command . easy_install import chmod , current_umask <EOL> log . info ( "<STR_LIT>" , script_name , self . install_dir ) <EOL> target = os . path . join ( self . install_dir , script_name ) <EOL> self . outfiles . append ( target ) <EOL> mask = current_umask ( ) <EOL> if not self . dry_run : <EOL> ensure_directory ( target ) <EOL> f = open ( target , "<STR_LIT:w>" + mode ) <EOL> f . write ( contents ) <EOL> f . close ( ) <EOL> chmod ( target , <NUM_LIT:0> <NUM_LIT> - mask ) </s>
