<s> from __future__ import print_function <EOL> import os <EOL> import sys <EOL> import shutil <EOL> from subprocess import check_call <EOL> from glob import glob <EOL> v = sys . version_info <EOL> if v [ : <NUM_LIT:2> ] < ( <NUM_LIT:3> , <NUM_LIT:3> ) : <EOL> error = "<STR_LIT>" <EOL> print ( error , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def mtime ( path ) : <EOL> """<STR_LIT>""" <EOL> return os . stat ( path ) . st_mtime <EOL> if os . name in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> error = "<STR_LIT>" <EOL> print ( error , file = sys . stderr ) <EOL> from distutils . core import setup <EOL> pjoin = os . path . join <EOL> here = os . path . abspath ( os . path . dirname ( __file__ ) ) <EOL> from distutils . cmd import Command <EOL> from distutils . command . build_py import build_py <EOL> from distutils . command . sdist import sdist <EOL> npm_path = '<STR_LIT::>' . join ( [ <EOL> pjoin ( here , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> os . environ . get ( "<STR_LIT>" , os . defpath ) , <EOL> ] ) <EOL> here = os . path . abspath ( os . path . dirname ( __file__ ) ) <EOL> share = pjoin ( here , '<STR_LIT>' ) <EOL> static = pjoin ( share , '<STR_LIT>' ) <EOL> class BaseCommand ( Command ) : <EOL> """<STR_LIT>""" <EOL> user_options = [ ] <EOL> def initialize_options ( self ) : <EOL> pass <EOL> def finalize_options ( self ) : <EOL> pass <EOL> def get_inputs ( self ) : <EOL> return [ ] <EOL> def get_outputs ( self ) : <EOL> return [ ] <EOL> class Bower ( BaseCommand ) : <EOL> description = "<STR_LIT>" <EOL> user_options = [ ] <EOL> bower_dir = pjoin ( static , '<STR_LIT>' ) <EOL> node_modules = pjoin ( here , '<STR_LIT>' ) <EOL> def should_run ( self ) : <EOL> if not os . path . exists ( self . bower_dir ) : <EOL> return True <EOL> return mtime ( self . bower_dir ) < mtime ( pjoin ( here , '<STR_LIT>' ) ) <EOL> def should_run_npm ( self ) : <EOL> if not shutil . which ( '<STR_LIT>' ) : <EOL> print ( "<STR_LIT>" , file = sys . stderr ) <EOL> return False <EOL> if not os . path . exists ( self . node_modules ) : <EOL> return True <EOL> return mtime ( self . node_modules ) < mtime ( pjoin ( here , '<STR_LIT>' ) ) <EOL> def run ( self ) : <EOL> if not self . should_run ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> return <EOL> if self . should_run_npm ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> check_call ( [ '<STR_LIT>' , '<STR_LIT>' ] , cwd = here ) <EOL> os . utime ( self . node_modules ) <EOL> env = os . environ . copy ( ) <EOL> env [ '<STR_LIT>' ] = npm_path <EOL> try : <EOL> check_call ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> cwd = here , <EOL> env = env , <EOL> ) <EOL> except OSError as e : <EOL> print ( "<STR_LIT>" % e , file = sys . stderr ) <EOL> print ( "<STR_LIT>" , file = sys . stderr ) <EOL> raise <EOL> os . utime ( self . bower_dir ) <EOL> self . distribution . data_files = get_data_files ( ) <EOL> class CSS ( BaseCommand ) : <EOL> description = "<STR_LIT>" <EOL> def should_run ( self ) : <EOL> """<STR_LIT>""" <EOL> css_targets = [ pjoin ( static , '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> css_maps = [ t + '<STR_LIT>' for t in css_targets ] <EOL> targets = css_targets + css_maps <EOL> if not all ( os . path . exists ( t ) for t in targets ) : <EOL> return True <EOL> earliest_target = sorted ( mtime ( t ) for t in targets ) [ <NUM_LIT:0> ] <EOL> for ( dirpath , dirnames , filenames ) in os . walk ( static ) : <EOL> for f in filenames : <EOL> if f . endswith ( '<STR_LIT>' ) : <EOL> path = pjoin ( static , dirpath , f ) <EOL> timestamp = mtime ( path ) <EOL> if timestamp > earliest_target : <EOL> return True <EOL> return False <EOL> def run ( self ) : <EOL> if not self . should_run ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> return <EOL> self . run_command ( '<STR_LIT>' ) <EOL> style_less = pjoin ( static , '<STR_LIT>' , '<STR_LIT>' ) <EOL> style_css = pjoin ( static , '<STR_LIT>' , '<STR_LIT>' ) <EOL> sourcemap = style_css + '<STR_LIT>' <EOL> env = os . environ . copy ( ) <EOL> env [ '<STR_LIT>' ] = npm_path <EOL> try : <EOL> check_call ( [ <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' . format ( static ) , <EOL> '<STR_LIT>' . format ( sourcemap ) , <EOL> '<STR_LIT>' , <EOL> style_less , style_css , <EOL> ] , cwd = here , env = env ) <EOL> except OSError as e : <EOL> print ( "<STR_LIT>" % e , file = sys . stderr ) <EOL> print ( "<STR_LIT>" , file = sys . stderr ) <EOL> raise <EOL> self . distribution . data_files = get_data_files ( ) <EOL> def get_data_files ( ) : <EOL> """<STR_LIT>""" <EOL> data_files = [ ] <EOL> ntrim = len ( here ) + <NUM_LIT:1> <EOL> for ( d , dirs , filenames ) in os . walk ( static ) : <EOL> data_files . append ( ( <EOL> d [ ntrim : ] , <EOL> [ pjoin ( d , f ) for f in filenames ] <EOL> ) ) <EOL> return data_files <EOL> setup_args = dict ( <EOL> name = '<STR_LIT>' , <EOL> packages = [ '<STR_LIT>' ] , <EOL> scripts = glob ( pjoin ( '<STR_LIT>' , '<STR_LIT:*>' ) ) , <EOL> version = '<STR_LIT>' , <EOL> description = """<STR_LIT>""" , <EOL> long_description = "<STR_LIT>" , <EOL> author = "<STR_LIT>" , <EOL> author_email = "<STR_LIT>" , <EOL> url = "<STR_LIT>" , <EOL> license = "<STR_LIT>" , <EOL> platforms = "<STR_LIT>" , <EOL> keywords = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> classifiers = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> ) <EOL> setup_args [ '<STR_LIT>' ] = { '<STR_LIT>' : Bower , '<STR_LIT>' : CSS } <EOL> if '<STR_LIT>' in sys . modules : <EOL> setup_args [ '<STR_LIT>' ] = install_requires = [ ] <EOL> with open ( '<STR_LIT>' ) as f : <EOL> for line in f . readlines ( ) : <EOL> req = line . strip ( ) <EOL> if not req or req . startswith ( ( '<STR_LIT>' , '<STR_LIT:#>' ) ) : <EOL> continue <EOL> install_requires . append ( req ) <EOL> def main ( ) : <EOL> setup ( ** setup_args ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
