<s> import logging <EOL> import os <EOL> import pprint <EOL> import shutil <EOL> import subprocess <EOL> import sys <EOL> from setuptools import setup <EOL> from setuptools . extension import Extension <EOL> logging . basicConfig ( ) <EOL> log = logging . getLogger ( ) <EOL> def check_output ( cmd ) : <EOL> try : <EOL> out = subprocess . check_output ( cmd ) <EOL> return out . decode ( '<STR_LIT>' ) <EOL> except AttributeError : <EOL> p = subprocess . Popen ( cmd , stdout = subprocess . PIPE ) <EOL> out , err = p . communicate ( ) <EOL> return out <EOL> def copy_data_tree ( datadir , destdir ) : <EOL> try : <EOL> shutil . rmtree ( destdir ) <EOL> except OSError : <EOL> pass <EOL> shutil . copytree ( datadir , destdir ) <EOL> if '<STR_LIT:all>' in sys . warnoptions : <EOL> log . level = logging . DEBUG <EOL> with open ( '<STR_LIT>' ) as f : <EOL> for line in f : <EOL> if line . find ( "<STR_LIT>" ) >= <NUM_LIT:0> : <EOL> version = line . split ( "<STR_LIT:=>" ) [ <NUM_LIT:1> ] . strip ( ) <EOL> version = version . strip ( '<STR_LIT:">' ) <EOL> version = version . strip ( "<STR_LIT:'>" ) <EOL> continue <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( version ) <EOL> try : <EOL> from Cython . Build import cythonize <EOL> except ImportError : <EOL> cythonize = None <EOL> include_dirs = [ ] <EOL> library_dirs = [ ] <EOL> libraries = [ ] <EOL> extra_link_args = [ ] <EOL> gdal2plus = False <EOL> gdal_output = [ None ] * <NUM_LIT:4> <EOL> try : <EOL> import numpy <EOL> include_dirs . append ( numpy . get_include ( ) ) <EOL> except ImportError : <EOL> log . critical ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> try : <EOL> gdal_config = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> for i , flag in enumerate ( ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> gdal_output [ i ] = check_output ( [ gdal_config , flag ] ) . strip ( ) <EOL> for item in gdal_output [ <NUM_LIT:0> ] . split ( ) : <EOL> if item . startswith ( "<STR_LIT>" ) : <EOL> include_dirs . extend ( item [ <NUM_LIT:2> : ] . split ( "<STR_LIT::>" ) ) <EOL> for item in gdal_output [ <NUM_LIT:1> ] . split ( ) : <EOL> if item . startswith ( "<STR_LIT>" ) : <EOL> library_dirs . extend ( item [ <NUM_LIT:2> : ] . split ( "<STR_LIT::>" ) ) <EOL> elif item . startswith ( "<STR_LIT>" ) : <EOL> libraries . append ( item [ <NUM_LIT:2> : ] ) <EOL> else : <EOL> extra_link_args . append ( item ) <EOL> for item in gdal_output [ <NUM_LIT:3> ] . split ( ) : <EOL> gdal2plus = not item . startswith ( "<STR_LIT>" ) <EOL> except Exception as e : <EOL> if os . name == "<STR_LIT>" : <EOL> log . info ( ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> else : <EOL> log . warning ( "<STR_LIT>" , str ( e ) ) <EOL> if os . environ . get ( '<STR_LIT>' ) : <EOL> destdir = '<STR_LIT>' <EOL> if gdal_output [ <NUM_LIT:2> ] : <EOL> log . info ( "<STR_LIT>" % gdal_output [ <NUM_LIT:2> ] ) <EOL> copy_data_tree ( gdal_output [ <NUM_LIT:2> ] , destdir ) <EOL> else : <EOL> gdal_data = os . environ . get ( '<STR_LIT>' , None ) <EOL> if gdal_data : <EOL> log . info ( "<STR_LIT>" % gdal_data ) <EOL> copy_data_tree ( gdal_data , destdir ) <EOL> projdatadir = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if os . path . exists ( projdatadir ) : <EOL> log . info ( "<STR_LIT>" % projdatadir ) <EOL> copy_data_tree ( projdatadir , '<STR_LIT>' ) <EOL> ext_options = dict ( <EOL> include_dirs = include_dirs , <EOL> library_dirs = library_dirs , <EOL> libraries = libraries , <EOL> extra_link_args = extra_link_args ) <EOL> if not os . name == "<STR_LIT>" : <EOL> ext_options [ '<STR_LIT>' ] = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> cythonize_options = { } <EOL> if os . environ . get ( '<STR_LIT>' ) : <EOL> cythonize_options [ '<STR_LIT>' ] = { '<STR_LIT>' : True } <EOL> cythonize_options [ '<STR_LIT>' ] = True <EOL> ext_options [ '<STR_LIT>' ] = [ ( '<STR_LIT>' , '<STR_LIT:1>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:1>' ) ] <EOL> log . debug ( '<STR_LIT>' , pprint . pformat ( ext_options ) ) <EOL> if gdal2plus : <EOL> cython_fill = [ '<STR_LIT>' ] <EOL> sdist_fill = [ '<STR_LIT>' ] <EOL> else : <EOL> cython_fill = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> sdist_fill = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if os . path . exists ( "<STR_LIT>" ) and "<STR_LIT>" not in sys . argv : <EOL> log . info ( "<STR_LIT>" ) <EOL> if not cythonize : <EOL> log . critical ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> ext_modules = cythonize ( [ <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , cython_fill , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) ] , <EOL> quiet = True , ** cythonize_options ) <EOL> else : <EOL> ext_modules = [ <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , sdist_fill , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) , <EOL> Extension ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' ] , ** ext_options ) ] <EOL> with open ( '<STR_LIT>' ) as f : <EOL> readme = f . read ( ) <EOL> inst_reqs = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if sys . version_info < ( <NUM_LIT:3> , <NUM_LIT:4> ) : <EOL> inst_reqs . append ( '<STR_LIT>' ) <EOL> setup_args = dict ( <EOL> name = '<STR_LIT>' , <EOL> version = version , <EOL> description = "<STR_LIT>" , <EOL> long_description = readme , <EOL> classifiers = [ <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> keywords = '<STR_LIT>' , <EOL> author = '<STR_LIT>' , <EOL> author_email = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> license = '<STR_LIT>' , <EOL> package_dir = { '<STR_LIT>' : '<STR_LIT:.>' } , <EOL> packages = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> entry_points = '''<STR_LIT>''' , <EOL> include_package_data = True , <EOL> ext_modules = ext_modules , <EOL> zip_safe = False , <EOL> install_requires = inst_reqs , <EOL> extras_require = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:test>' : [ '<STR_LIT>' , '<STR_LIT>' ] } ) <EOL> if os . environ . get ( '<STR_LIT>' ) : <EOL> setup_args [ '<STR_LIT>' ] = { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } <EOL> setup ( ** setup_args ) </s>
