<s> from __future__ import print_function <EOL> import os <EOL> import io <EOL> import sys <EOL> import json <EOL> import glob <EOL> import subprocess <EOL> sys . path . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> import xdress . version <EOL> sys . path . pop ( <NUM_LIT:0> ) <EOL> if sys . version_info [ <NUM_LIT:0> ] >= <NUM_LIT:3> : <EOL> def decode ( s ) : <EOL> return s if isinstance ( s , str ) else bytes . decode ( s ) <EOL> import distutils . spawn <EOL> old_spawn_posix = distutils . spawn . _spawn_posix <EOL> def hack_spawn_posix ( cmd , search_path = <NUM_LIT:1> , verbose = <NUM_LIT:0> , dry_run = <NUM_LIT:0> ) : <EOL> return old_spawn_posix ( list ( map ( decode , cmd ) ) , search_path , verbose , dry_run ) <EOL> distutils . spawn . _spawn_posix = hack_spawn_posix <EOL> try : <EOL> from subprocess import DEVNULL <EOL> except ImportError : <EOL> DEVNULL = open ( os . devnull , '<STR_LIT:wb>' ) <EOL> INFO = { <EOL> '<STR_LIT:version>' : xdress . version . xdress_version , <EOL> } <EOL> def main ( ) : <EOL> "<STR_LIT>" <EOL> if len ( sys . argv ) <= <NUM_LIT:1> : <EOL> raise SystemExit ( "<STR_LIT>" ) <EOL> cmds = sys . argv [ <NUM_LIT:1> : ] <EOL> if '<STR_LIT>' in cmds or '<STR_LIT>' in cmds : <EOL> msg = "<STR_LIT>" + sys . argv [ <NUM_LIT:0> ] + "<STR_LIT>" <EOL> raise SystemExit ( msg ) <EOL> glbs = globals ( ) <EOL> for cmd in cmds : <EOL> if cmd not in glbs : <EOL> raise SystemExit ( cmd + "<STR_LIT>" ) <EOL> for cmd in cmds : <EOL> if callable ( glbs [ cmd ] ) : <EOL> glbs [ cmd ] ( ) <EOL> else : <EOL> raise SystemExit ( cmd + "<STR_LIT>" ) <EOL> def metadata ( path = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> md = { } <EOL> md . update ( INFO ) <EOL> with open ( path , '<STR_LIT:w>' ) as f : <EOL> json . dump ( md , f , indent = <NUM_LIT:2> ) <EOL> return md <EOL> dir_name = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> fname = os . path . join ( dir_name , '<STR_LIT>' , '<STR_LIT>' ) <EOL> with io . open ( fname , '<STR_LIT:r>' ) as f : <EOL> long_desc = f . read ( ) <EOL> long_desc = "<STR_LIT:\n>" . join ( [ l for l in long_desc . splitlines ( ) if "<STR_LIT>" not in l ] ) <EOL> long_desc = "<STR_LIT:\n>" . join ( [ l for l in long_desc . splitlines ( ) <EOL> if "<STR_LIT>" not in l ] ) <EOL> long_desc = "<STR_LIT:\n>" . join ( [ l for l in long_desc . splitlines ( ) <EOL> if "<STR_LIT>" not in l ] ) <EOL> def setup ( ) : <EOL> try : <EOL> from setuptools import setup as setup_ , Extension <EOL> except ImportError : <EOL> from distutils . core import setup as setup_ , Extension <EOL> from distutils . spawn import find_executable <EOL> from distutils . sysconfig import get_config_vars <EOL> scripts_dir = os . path . join ( dir_name , '<STR_LIT>' ) <EOL> if os . name == '<STR_LIT>' : <EOL> scripts = [ os . path . join ( scripts_dir , f ) <EOL> for f in os . listdir ( scripts_dir ) ] <EOL> else : <EOL> scripts = [ os . path . join ( scripts_dir , f ) <EOL> for f in os . listdir ( scripts_dir ) <EOL> if not f . endswith ( '<STR_LIT>' ) ] <EOL> packages = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> pack_dir = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> pack_data = { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } <EOL> if '<STR_LIT>' in os . environ and '<STR_LIT>' in os . environ : <EOL> llvm_config = True <EOL> else : <EOL> if '<STR_LIT>' in os . environ : <EOL> llvm_config = os . environ [ '<STR_LIT>' ] <EOL> else : <EOL> options = '<STR_LIT>' . split ( ) <EOL> for p in options : <EOL> p = find_executable ( p ) <EOL> if p is not None : <EOL> print ( '<STR_LIT>' % p ) <EOL> llvm_config = p <EOL> break <EOL> else : <EOL> print ( '<STR_LIT>' % '<STR_LIT:U+002CU+0020>' . join ( options ) ) <EOL> print ( '<STR_LIT>' ) <EOL> llvm_config = None <EOL> version = <NUM_LIT:0> , <EOL> if llvm_config is not None : <EOL> try : <EOL> llvm_cppflags = ( os . environ . get ( '<STR_LIT>' ) <EOL> or subprocess . check_output ( [ llvm_config , '<STR_LIT>' ] ) ) . split ( ) <EOL> try : <EOL> llvm_ldflags = os . environ [ '<STR_LIT>' ] . split ( ) <EOL> except KeyError : <EOL> llvm_ldflags = subprocess . check_output ( [ llvm_config , '<STR_LIT>' , '<STR_LIT>' ] ) . split ( ) <EOL> try : <EOL> llvm_ldflags . extend ( subprocess . check_output ( [ llvm_config , '<STR_LIT>' ] , stderr = DEVNULL ) . split ( ) ) <EOL> except subprocess . CalledProcessError : <EOL> pass <EOL> version = subprocess . check_output ( [ llvm_config , '<STR_LIT>' ] ) <EOL> except OSError as e : <EOL> raise OSError ( "<STR_LIT>" % ( llvm_config , e ) ) <EOL> version = tuple ( int ( part ) for part in version . decode ( ) . strip ( ) . split ( '<STR_LIT:.>' ) ) <EOL> clang_dir = os . path . join ( dir_name , '<STR_LIT>' , '<STR_LIT>' ) <EOL> clang_src_dir = os . path . join ( clang_dir , '<STR_LIT:src>' ) <EOL> clang_libs = ( os . environ . get ( '<STR_LIT>' ) <EOL> or '''<STR_LIT>''' ) . split ( ) <EOL> if '<STR_LIT>' in os . environ : <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' % clang_dir + os . environ [ '<STR_LIT>' ] <EOL> opt , = get_config_vars ( '<STR_LIT>' ) <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT:U+0020>' . join ( f for f in opt . split ( ) if f != '<STR_LIT>' ) <EOL> modules = [ Extension ( '<STR_LIT>' , <EOL> sources = glob . glob ( os . path . join ( clang_src_dir , '<STR_LIT>' ) ) , <EOL> define_macros = [ ( '<STR_LIT>' , <NUM_LIT:1> ) ] , <EOL> include_dirs = [ clang_dir ] , <EOL> extra_compile_args = llvm_cppflags + [ '<STR_LIT>' ] + [ '<STR_LIT>' ] * ( version > ( <NUM_LIT:3> , <NUM_LIT:4> ) ) , <EOL> extra_link_args = llvm_ldflags , <EOL> libraries = clang_libs , <EOL> language = '<STR_LIT>' ) ] <EOL> else : <EOL> modules = ( ) <EOL> setup_kwargs = { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:version>" : INFO [ '<STR_LIT:version>' ] , <EOL> "<STR_LIT:description>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT:url>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : packages , <EOL> "<STR_LIT>" : pack_dir , <EOL> "<STR_LIT>" : pack_data , <EOL> "<STR_LIT>" : modules , <EOL> "<STR_LIT>" : scripts , <EOL> "<STR_LIT:description>" : ( "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> "<STR_LIT>" : long_desc , <EOL> "<STR_LIT>" : ( "<STR_LIT>" <EOL> "<STR_LIT>" ) . format ( * xdress . version . xdress_version [ : <NUM_LIT:2> ] ) , <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] , <EOL> } <EOL> cwd = os . getcwd ( ) <EOL> os . chdir ( dir_name ) <EOL> setup_ ( ** setup_kwargs ) <EOL> os . chdir ( cwd ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
