<s> import sys <EOL> from os . path import join , basename , dirname , splitext <EOL> from glob import glob <EOL> from numpy . distutils import log <EOL> from distutils . dep_util import newer <EOL> def configuration ( parent_package = '<STR_LIT>' , top_path = None ) : <EOL> from numpy . distutils . misc_util import Configuration <EOL> package_name = '<STR_LIT>' <EOL> config = Configuration ( package_name , parent_package , top_path ) <EOL> bitarray_path = '<STR_LIT>' <EOL> config . add_subpackage ( '<STR_LIT>' , bitarray_path ) <EOL> config . add_extension ( '<STR_LIT>' , join ( bitarray_path , '<STR_LIT>' ) ) <EOL> config . add_extension ( '<STR_LIT>' , join ( '<STR_LIT:src>' , '<STR_LIT>' ) ) <EOL> config . add_extension ( '<STR_LIT>' , join ( '<STR_LIT:src>' , '<STR_LIT>' ) ) <EOL> config . make_svn_version_py ( ) <EOL> wininst = '<STR_LIT>' in sys . argv <EOL> scripts = glob ( join ( config . local_path , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> scripts += glob ( join ( config . local_path , '<STR_LIT:*>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> for script in scripts : <EOL> if basename ( script ) . startswith ( package_name ) : <EOL> config . add_scripts ( script ) <EOL> continue <EOL> def generate_a_script ( build_dir , script = script , config = config ) : <EOL> dist = config . get_distribution ( ) <EOL> install_lib = dist . get_command_obj ( '<STR_LIT>' ) <EOL> if not install_lib . finalized : <EOL> install_lib . finalize_options ( ) <EOL> script_replace_text = '<STR_LIT>' <EOL> install_lib = install_lib . install_dir <EOL> if install_lib is not None : <EOL> script_replace_text = '''<STR_LIT>''' % dict ( d = install_lib ) <EOL> start_mark = '<STR_LIT>' <EOL> end_mark = '<STR_LIT>' <EOL> name = basename ( script ) <EOL> if name . startswith ( package_name ) : <EOL> target_name = name <EOL> elif wininst : <EOL> target_name = package_name + '<STR_LIT:_>' + name <EOL> else : <EOL> target_name = package_name + '<STR_LIT:.>' + splitext ( name ) [ <NUM_LIT:0> ] <EOL> target = join ( build_dir , target_name ) <EOL> if newer ( script , target ) or <NUM_LIT:1> : <EOL> log . info ( '<STR_LIT>' , target ) <EOL> f = open ( script , '<STR_LIT:r>' ) <EOL> text = f . read ( ) <EOL> f . close ( ) <EOL> i = text . find ( start_mark ) <EOL> if i != - <NUM_LIT:1> : <EOL> j = text . find ( end_mark ) <EOL> if j == - <NUM_LIT:1> : <EOL> log . warn ( "<STR_LIT>" , script , start_mark ) <EOL> new_text = text [ : i + len ( start_mark ) ] + script_replace_text + text [ j : ] <EOL> else : <EOL> new_text = text <EOL> f = open ( target , '<STR_LIT:w>' ) <EOL> f . write ( new_text ) <EOL> f . close ( ) <EOL> config . add_scripts ( generate_a_script ) <EOL> return config <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from numpy . distutils . core import setup <EOL> setup ( configuration = configuration ) </s>
