<s> from distutils . command . clean import clean as _clean <EOL> from distutils . dir_util import remove_tree <EOL> from distutils import log <EOL> from setuptools import setup , find_packages , Distribution <EOL> from setuptools . command . test import test as _test <EOL> import os <EOL> import os . path <EOL> import sys <EOL> VERSION = "<STR_LIT>" <EOL> HERE = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> PYROBUF_LIST_PXD = "<STR_LIT>" <EOL> PYROBUF_LIST_PYX = "<STR_LIT>" <EOL> class clean ( _clean ) : <EOL> def __clean_tree ( self , tree ) : <EOL> for dirpath , dirnames , filenames in os . walk ( tree ) : <EOL> for dirname in dirnames : <EOL> if dirname in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> remove_tree ( os . path . join ( dirpath , dirname ) , verbose = self . verbose , dry_run = self . dry_run ) <EOL> for dirpath , dirnames , filenames in os . walk ( tree ) : <EOL> for filename in filenames : <EOL> if any ( filename . endswith ( suffix ) for suffix in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> self . __remove_file ( os . path . join ( dirpath , filename ) ) <EOL> continue <EOL> extension = os . path . splitext ( filename ) [ <NUM_LIT:1> ] <EOL> if extension in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> pyx_file = str . replace ( filename , extension , '<STR_LIT>' ) <EOL> if os . path . exists ( os . path . join ( dirpath , pyx_file ) ) : <EOL> self . __remove_file ( os . path . join ( dirpath , filename ) ) <EOL> def __remove_file ( self , full_path ) : <EOL> if os . path . exists ( full_path ) : <EOL> if not self . dry_run : <EOL> os . unlink ( full_path ) <EOL> if self . verbose >= <NUM_LIT:1> : <EOL> log . info ( "<STR_LIT>" % full_path ) <EOL> def run ( self ) : <EOL> _clean . run ( self ) <EOL> self . __clean_tree ( os . path . join ( HERE , '<STR_LIT>' ) ) <EOL> self . __clean_tree ( os . path . join ( HERE , '<STR_LIT>' ) ) <EOL> tests_out = os . path . join ( HERE , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if os . path . isdir ( tests_out ) : <EOL> remove_tree ( tests_out , verbose = self . verbose , dry_run = self . dry_run ) <EOL> self . __remove_file ( os . path . join ( HERE , '<STR_LIT>' , '<STR_LIT:src>' , PYROBUF_LIST_PXD ) ) <EOL> self . __remove_file ( os . path . join ( HERE , '<STR_LIT>' , '<STR_LIT:src>' , PYROBUF_LIST_PYX ) ) <EOL> for filename in os . listdir ( HERE ) : <EOL> for prefix in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> for suffix in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if filename . startswith ( prefix ) and filename . endswith ( suffix ) : <EOL> self . __remove_file ( os . path . join ( HERE , filename ) ) <EOL> class test ( _test ) : <EOL> def initialize_options ( self ) : <EOL> _test . initialize_options ( self ) <EOL> self . pytest_args = [ ] <EOL> def run_tests ( self ) : <EOL> import pytest <EOL> errno = pytest . main ( self . pytest_args ) <EOL> sys . exit ( errno ) <EOL> class PyrobufDistribution ( Distribution ) : <EOL> def run_commands ( self ) : <EOL> if not self . ext_modules : <EOL> self . ext_modules = list ( ) <EOL> self . ext_modules . extend ( self . pyrobufize_builtins ( ) ) <EOL> Distribution . run_commands ( self ) <EOL> def pyrobufize_builtins ( self ) : <EOL> from jinja2 import Environment , PackageLoader <EOL> from Cython . Build import cythonize <EOL> env = Environment ( loader = PackageLoader ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> templ_pyx = env . get_template ( '<STR_LIT>' ) <EOL> templ_pxd = env . get_template ( '<STR_LIT>' ) <EOL> listdict = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:float>' , <EOL> '<STR_LIT>' : '<STR_LIT:int>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> format_map = { <EOL> '<STR_LIT>' : '<STR_LIT:d>' , <EOL> '<STR_LIT:float>' : '<STR_LIT:f>' , <EOL> '<STR_LIT:int>' : '<STR_LIT:i>' , <EOL> '<STR_LIT>' : '<STR_LIT:i>' , <EOL> '<STR_LIT>' : '<STR_LIT:I>' , <EOL> '<STR_LIT>' : '<STR_LIT:L>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:c>' , <EOL> } <EOL> path = os . path . join ( HERE , '<STR_LIT>' , '<STR_LIT:src>' , PYROBUF_LIST_PYX ) <EOL> if not self . dry_run : <EOL> with open ( path , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( templ_pyx . render ( <EOL> { '<STR_LIT>' : listdict , '<STR_LIT>' : sys . version_info . major , '<STR_LIT>' : format_map } <EOL> ) ) <EOL> if self . verbose >= <NUM_LIT:1> : <EOL> log . info ( "<STR_LIT>" % ( PYROBUF_LIST_PYX , templ_pyx . filename ) ) <EOL> path = os . path . join ( HERE , '<STR_LIT>' , '<STR_LIT:src>' , PYROBUF_LIST_PXD ) <EOL> if not self . dry_run : <EOL> with open ( path , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( templ_pxd . render ( <EOL> { '<STR_LIT>' : listdict , '<STR_LIT>' : sys . version_info . major , '<STR_LIT>' : format_map } <EOL> ) ) <EOL> if self . verbose >= <NUM_LIT:1> : <EOL> log . info ( "<STR_LIT>" % ( PYROBUF_LIST_PXD , templ_pxd . filename ) ) <EOL> return cythonize ( [ '<STR_LIT>' ] , <EOL> include_path = [ '<STR_LIT>' ] ) <EOL> setup ( <EOL> distclass = PyrobufDistribution , <EOL> name = "<STR_LIT>" , <EOL> version = VERSION , <EOL> packages = find_packages ( ) , <EOL> include_package_data = True , <EOL> cmdclass = { '<STR_LIT>' : clean , '<STR_LIT:test>' : test } , <EOL> entry_points = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> ] , <EOL> } , <EOL> description = '<STR_LIT>' , <EOL> long_description = open ( os . path . join ( HERE , '<STR_LIT>' ) ) . read ( ) , <EOL> url = '<STR_LIT>' , <EOL> author = '<STR_LIT>' , <EOL> tests_require = [ '<STR_LIT>' ] + ( [ '<STR_LIT>' ] if sys . version_info . major == <NUM_LIT:2> else [ ] ) , <EOL> setup_requires = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> install_requires = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> zip_safe = False , <EOL> ) </s>
