<s> import os <EOL> import platform <EOL> import re <EOL> import subprocess <EOL> import sys <EOL> import warnings <EOL> try : <EOL> import multiprocessing <EOL> except ImportError : <EOL> pass <EOL> try : <EOL> from setuptools import setup <EOL> except ImportError : <EOL> from ez_setup import use_setuptools <EOL> use_setuptools ( ) <EOL> from setuptools import setup <EOL> from distutils . cmd import Command <EOL> from distutils . command . build_ext import build_ext <EOL> from distutils . errors import CCompilerError , DistutilsOptionError <EOL> from distutils . errors import DistutilsPlatformError , DistutilsExecError <EOL> from distutils . core import Extension <EOL> version = "<STR_LIT>" <EOL> f = open ( "<STR_LIT>" ) <EOL> try : <EOL> try : <EOL> readme_content = f . read ( ) <EOL> except : <EOL> readme_content = "<STR_LIT>" <EOL> finally : <EOL> f . close ( ) <EOL> if sys . platform == '<STR_LIT>' and '<STR_LIT>' in platform . python_compiler ( ) . lower ( ) : <EOL> from distutils . sysconfig import get_config_vars <EOL> res = get_config_vars ( ) <EOL> for key in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if key in res : <EOL> flags = res [ key ] <EOL> flags = re . sub ( '<STR_LIT>' , '<STR_LIT>' , flags ) <EOL> res [ key ] = flags <EOL> class test ( Command ) : <EOL> description = "<STR_LIT>" <EOL> user_options = [ <EOL> ( "<STR_LIT>" , "<STR_LIT:m>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:s>" , <EOL> "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:f>" , "<STR_LIT>" ) <EOL> ] <EOL> def initialize_options ( self ) : <EOL> self . test_module = None <EOL> self . test_suite = None <EOL> self . failfast = False <EOL> def finalize_options ( self ) : <EOL> if self . test_suite is None and self . test_module is None : <EOL> self . test_module = '<STR_LIT:test>' <EOL> elif self . test_module is not None and self . test_suite is not None : <EOL> raise DistutilsOptionError ( <EOL> "<STR_LIT>" <EOL> ) <EOL> def run ( self ) : <EOL> if self . distribution . install_requires : <EOL> self . distribution . fetch_build_eggs ( <EOL> self . distribution . install_requires ) <EOL> if self . distribution . tests_require : <EOL> self . distribution . fetch_build_eggs ( self . distribution . tests_require ) <EOL> self . run_command ( '<STR_LIT>' ) <EOL> build_ext_cmd = self . reinitialize_command ( '<STR_LIT>' ) <EOL> build_ext_cmd . inplace = <NUM_LIT:1> <EOL> self . run_command ( '<STR_LIT>' ) <EOL> from test import unittest , PymongoTestRunner , test_cases <EOL> if self . test_suite is None : <EOL> all_tests = unittest . defaultTestLoader . discover ( self . test_module ) <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTests ( sorted ( test_cases ( all_tests ) , <EOL> key = lambda x : x . __module__ ) ) <EOL> else : <EOL> suite = unittest . defaultTestLoader . loadTestsFromName ( <EOL> self . test_suite ) <EOL> result = PymongoTestRunner ( verbosity = <NUM_LIT:2> , <EOL> failfast = self . failfast ) . run ( suite ) <EOL> sys . exit ( not result . wasSuccessful ( ) ) <EOL> class doc ( Command ) : <EOL> description = "<STR_LIT>" <EOL> user_options = [ ( "<STR_LIT:test>" , "<STR_LIT:t>" , <EOL> "<STR_LIT>" ) ] <EOL> boolean_options = [ "<STR_LIT:test>" ] <EOL> def initialize_options ( self ) : <EOL> self . test = False <EOL> def finalize_options ( self ) : <EOL> pass <EOL> def run ( self ) : <EOL> if self . test : <EOL> path = "<STR_LIT>" <EOL> mode = "<STR_LIT>" <EOL> else : <EOL> path = "<STR_LIT>" % version <EOL> mode = "<STR_LIT:html>" <EOL> try : <EOL> os . makedirs ( path ) <EOL> except : <EOL> pass <EOL> status = subprocess . call ( [ "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , mode , "<STR_LIT>" , path ] ) <EOL> if status : <EOL> raise RuntimeError ( "<STR_LIT>" % ( mode , ) ) <EOL> sys . stdout . write ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( mode , path ) ) <EOL> if sys . platform == '<STR_LIT:win32>' and sys . version_info > ( <NUM_LIT:2> , <NUM_LIT:6> ) : <EOL> build_errors = ( CCompilerError , DistutilsExecError , <EOL> DistutilsPlatformError , IOError ) <EOL> else : <EOL> build_errors = ( CCompilerError , DistutilsExecError , DistutilsPlatformError ) <EOL> class custom_build_ext ( build_ext ) : <EOL> """<STR_LIT>""" <EOL> warning_message = """<STR_LIT>""" <EOL> def run ( self ) : <EOL> try : <EOL> build_ext . run ( self ) <EOL> except DistutilsPlatformError : <EOL> e = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> sys . stdout . write ( '<STR_LIT>' % str ( e ) ) <EOL> warnings . warn ( self . warning_message % ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> def build_extension ( self , ext ) : <EOL> name = ext . name <EOL> if sys . version_info [ : <NUM_LIT:3> ] >= ( <NUM_LIT:2> , <NUM_LIT:6> , <NUM_LIT:0> ) : <EOL> try : <EOL> build_ext . build_extension ( self , ext ) <EOL> except build_errors : <EOL> e = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> sys . stdout . write ( '<STR_LIT>' % str ( e ) ) <EOL> warnings . warn ( self . warning_message % ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( name , ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> else : <EOL> warnings . warn ( self . warning_message % ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( name , ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> ext_modules = [ Extension ( '<STR_LIT>' , <EOL> include_dirs = [ '<STR_LIT>' ] , <EOL> sources = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) , <EOL> Extension ( '<STR_LIT>' , <EOL> include_dirs = [ '<STR_LIT>' ] , <EOL> sources = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) ] <EOL> extra_opts = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> } <EOL> if sys . version_info [ : <NUM_LIT:2> ] == ( <NUM_LIT:2> , <NUM_LIT:6> ) : <EOL> extra_opts [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> if "<STR_LIT>" in sys . argv : <EOL> sys . argv . remove ( "<STR_LIT>" ) <EOL> elif ( sys . platform . startswith ( "<STR_LIT>" ) or <EOL> sys . platform == "<STR_LIT>" or <EOL> "<STR_LIT>" in sys . version ) : <EOL> sys . stdout . write ( """<STR_LIT>""" ) <EOL> elif sys . byteorder == "<STR_LIT>" : <EOL> sys . stdout . write ( """<STR_LIT>""" ) <EOL> else : <EOL> extra_opts [ '<STR_LIT>' ] = ext_modules <EOL> setup ( <EOL> name = "<STR_LIT>" , <EOL> version = version , <EOL> description = "<STR_LIT>" , <EOL> long_description = readme_content , <EOL> author = "<STR_LIT>" , <EOL> author_email = "<STR_LIT>" , <EOL> maintainer = "<STR_LIT>" , <EOL> maintainer_email = "<STR_LIT>" , <EOL> url = "<STR_LIT>" , <EOL> keywords = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> install_requires = [ ] , <EOL> license = "<STR_LIT>" , <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> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] , <EOL> cmdclass = { "<STR_LIT>" : custom_build_ext , <EOL> "<STR_LIT>" : doc , <EOL> "<STR_LIT:test>" : test } , <EOL> ** extra_opts <EOL> ) </s>
