<s> import os <EOL> import re <EOL> import sys <EOL> from glob import glob <EOL> from distutils . command . build import build <EOL> from distutils . core import Command <EOL> import textwrap <EOL> min_python = ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> my_python = sys . version_info <EOL> if my_python < min_python : <EOL> print ( "<STR_LIT>" % min_python ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> on_rtd = os . environ . get ( '<STR_LIT>' ) <EOL> install_requires = [ '<STR_LIT>' , ] <EOL> extras_require = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , ] , <EOL> } <EOL> from setuptools import setup , Extension <EOL> from setuptools . command . sdist import sdist <EOL> compress_source = '<STR_LIT>' <EOL> crypto_source = '<STR_LIT>' <EOL> chunker_source = '<STR_LIT>' <EOL> hashindex_source = '<STR_LIT>' <EOL> platform_linux_source = '<STR_LIT>' <EOL> platform_darwin_source = '<STR_LIT>' <EOL> platform_freebsd_source = '<STR_LIT>' <EOL> try : <EOL> from Cython . Distutils import build_ext <EOL> import Cython . Compiler . Main as cython_compiler <EOL> class Sdist ( sdist ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> for src in glob ( '<STR_LIT>' ) : <EOL> cython_compiler . compile ( src , cython_compiler . default_options ) <EOL> super ( ) . __init__ ( * args , ** kwargs ) <EOL> def make_distribution ( self ) : <EOL> self . filelist . extend ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> super ( ) . make_distribution ( ) <EOL> except ImportError : <EOL> class Sdist ( sdist ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> compress_source = compress_source . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> crypto_source = crypto_source . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> chunker_source = chunker_source . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> hashindex_source = hashindex_source . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> platform_linux_source = platform_linux_source . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> platform_freebsd_source = platform_freebsd_source . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> platform_darwin_source = platform_darwin_source . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> from distutils . command . build_ext import build_ext <EOL> if not on_rtd and not all ( os . path . exists ( path ) for path in [ <EOL> compress_source , crypto_source , chunker_source , hashindex_source , <EOL> platform_linux_source , platform_freebsd_source ] ) : <EOL> raise ImportError ( '<STR_LIT>' ) <EOL> def detect_openssl ( prefixes ) : <EOL> for prefix in prefixes : <EOL> filename = os . path . join ( prefix , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if os . path . exists ( filename ) : <EOL> with open ( filename , '<STR_LIT:r>' ) as fd : <EOL> if '<STR_LIT>' in fd . read ( ) : <EOL> return prefix <EOL> def detect_lz4 ( prefixes ) : <EOL> for prefix in prefixes : <EOL> filename = os . path . join ( prefix , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if os . path . exists ( filename ) : <EOL> with open ( filename , '<STR_LIT:r>' ) as fd : <EOL> if '<STR_LIT>' in fd . read ( ) : <EOL> return prefix <EOL> include_dirs = [ ] <EOL> library_dirs = [ ] <EOL> possible_openssl_prefixes = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if os . environ . get ( '<STR_LIT>' ) : <EOL> possible_openssl_prefixes . insert ( <NUM_LIT:0> , os . environ . get ( '<STR_LIT>' ) ) <EOL> ssl_prefix = detect_openssl ( possible_openssl_prefixes ) <EOL> if not ssl_prefix : <EOL> raise Exception ( '<STR_LIT>' . format ( '<STR_LIT:U+002CU+0020>' . join ( possible_openssl_prefixes ) ) ) <EOL> include_dirs . append ( os . path . join ( ssl_prefix , '<STR_LIT>' ) ) <EOL> library_dirs . append ( os . path . join ( ssl_prefix , '<STR_LIT>' ) ) <EOL> possible_lz4_prefixes = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if os . environ . get ( '<STR_LIT>' ) : <EOL> possible_lz4_prefixes . insert ( <NUM_LIT:0> , os . environ . get ( '<STR_LIT>' ) ) <EOL> lz4_prefix = detect_lz4 ( possible_lz4_prefixes ) <EOL> if lz4_prefix : <EOL> include_dirs . append ( os . path . join ( lz4_prefix , '<STR_LIT>' ) ) <EOL> library_dirs . append ( os . path . join ( lz4_prefix , '<STR_LIT>' ) ) <EOL> elif not on_rtd : <EOL> raise Exception ( '<STR_LIT>' . format ( '<STR_LIT:U+002CU+0020>' . join ( possible_lz4_prefixes ) ) ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:r>' ) as fd : <EOL> long_description = fd . read ( ) <EOL> class build_usage ( Command ) : <EOL> description = "<STR_LIT>" <EOL> user_options = [ <EOL> ( '<STR_LIT>' , '<STR_LIT:O>' , '<STR_LIT>' ) , <EOL> ] <EOL> def initialize_options ( self ) : <EOL> pass <EOL> def finalize_options ( self ) : <EOL> pass <EOL> def run ( self ) : <EOL> print ( '<STR_LIT>' ) <EOL> from borg . archiver import Archiver <EOL> parser = Archiver ( ) . build_parser ( prog = '<STR_LIT>' ) <EOL> choices = { } <EOL> for action in parser . _actions : <EOL> if action . choices is not None : <EOL> choices . update ( action . choices ) <EOL> print ( '<STR_LIT>' % list ( choices . keys ( ) ) ) <EOL> if not os . path . exists ( '<STR_LIT>' ) : <EOL> os . mkdir ( '<STR_LIT>' ) <EOL> for command , parser in choices . items ( ) : <EOL> print ( '<STR_LIT>' % command ) <EOL> with open ( '<STR_LIT>' % command , '<STR_LIT:w>' ) as doc : <EOL> if command == '<STR_LIT>' : <EOL> for topic in Archiver . helptext : <EOL> params = { "<STR_LIT>" : topic , <EOL> "<STR_LIT>" : '<STR_LIT>' * len ( '<STR_LIT>' + topic ) } <EOL> doc . write ( "<STR_LIT>" . format ( ** params ) ) <EOL> doc . write ( "<STR_LIT>" . format ( ** params ) ) <EOL> doc . write ( Archiver . helptext [ topic ] ) <EOL> else : <EOL> params = { "<STR_LIT>" : command , <EOL> "<STR_LIT>" : '<STR_LIT:->' * len ( '<STR_LIT>' + command ) } <EOL> doc . write ( "<STR_LIT>" . format ( ** params ) ) <EOL> doc . write ( "<STR_LIT>" . format ( ** params ) ) <EOL> self . write_usage ( parser , doc ) <EOL> epilog = parser . epilog <EOL> parser . epilog = None <EOL> self . write_options ( parser , doc ) <EOL> doc . write ( "<STR_LIT>" ) <EOL> doc . write ( epilog ) <EOL> common_options = [ group for group in choices [ '<STR_LIT>' ] . _action_groups if group . title == '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as doc : <EOL> self . write_options_group ( common_options , doc , False ) <EOL> def write_usage ( self , parser , fp ) : <EOL> if any ( len ( o . option_strings ) for o in parser . _actions ) : <EOL> fp . write ( '<STR_LIT>' ) <EOL> for option in parser . _actions : <EOL> if option . option_strings : <EOL> continue <EOL> fp . write ( '<STR_LIT:U+0020>' + option . metavar ) <EOL> def write_options ( self , parser , fp ) : <EOL> for group in parser . _action_groups : <EOL> if group . title == '<STR_LIT>' : <EOL> fp . write ( '<STR_LIT>' ) <EOL> fp . write ( '<STR_LIT>' ) <EOL> else : <EOL> self . write_options_group ( group , fp ) <EOL> def write_options_group ( self , group , fp , with_title = True ) : <EOL> def is_positional_group ( group ) : <EOL> return any ( not o . option_strings for o in group . _group_actions ) <EOL> def get_help ( option ) : <EOL> text = textwrap . dedent ( ( option . help or '<STR_LIT>' ) % option . __dict__ ) <EOL> return '<STR_LIT:\n>' . join ( '<STR_LIT>' + line for line in text . splitlines ( ) ) <EOL> def shipout ( text ) : <EOL> fp . write ( textwrap . indent ( '<STR_LIT:\n>' . join ( text ) , '<STR_LIT:U+0020>' * <NUM_LIT:4> ) ) <EOL> if not group . _group_actions : <EOL> return <EOL> if with_title : <EOL> fp . write ( '<STR_LIT>' ) <EOL> fp . write ( group . title + '<STR_LIT:\n>' ) <EOL> text = [ ] <EOL> if is_positional_group ( group ) : <EOL> for option in group . _group_actions : <EOL> text . append ( option . metavar ) <EOL> text . append ( textwrap . indent ( option . help or '<STR_LIT>' , '<STR_LIT:U+0020>' * <NUM_LIT:4> ) ) <EOL> shipout ( text ) <EOL> return <EOL> options = [ ] <EOL> for option in group . _group_actions : <EOL> if option . metavar : <EOL> option_fmt = '<STR_LIT>' % option . metavar <EOL> else : <EOL> option_fmt = '<STR_LIT>' <EOL> option_str = '<STR_LIT:U+002CU+0020>' . join ( option_fmt % s for s in option . option_strings ) <EOL> options . append ( ( option_str , option ) ) <EOL> for option_str , option in options : <EOL> help = textwrap . indent ( get_help ( option ) , '<STR_LIT:U+0020>' * <NUM_LIT:4> ) <EOL> text . append ( option_str ) <EOL> text . append ( help ) <EOL> shipout ( text ) <EOL> class build_api ( Command ) : <EOL> description = "<STR_LIT>" <EOL> user_options = [ <EOL> ( '<STR_LIT>' , '<STR_LIT:O>' , '<STR_LIT>' ) , <EOL> ] <EOL> def initialize_options ( self ) : <EOL> pass <EOL> def finalize_options ( self ) : <EOL> pass <EOL> def run ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as doc : <EOL> doc . write ( """<STR_LIT>""" ) <EOL> for mod in glob ( '<STR_LIT>' ) + glob ( '<STR_LIT>' ) : <EOL> print ( "<STR_LIT>" % mod ) <EOL> mod = mod . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT:/>' , '<STR_LIT:.>' ) <EOL> if "<STR_LIT>" not in mod : <EOL> doc . write ( """<STR_LIT>""" % mod ) <EOL> cmdclass = { <EOL> '<STR_LIT>' : build_ext , <EOL> '<STR_LIT>' : build_api , <EOL> '<STR_LIT>' : build_usage , <EOL> '<STR_LIT>' : Sdist <EOL> } <EOL> ext_modules = [ ] <EOL> if not on_rtd : <EOL> ext_modules += [ <EOL> Extension ( '<STR_LIT>' , [ compress_source ] , libraries = [ '<STR_LIT>' ] , include_dirs = include_dirs , library_dirs = library_dirs ) , <EOL> Extension ( '<STR_LIT>' , [ crypto_source ] , libraries = [ '<STR_LIT>' ] , include_dirs = include_dirs , library_dirs = library_dirs ) , <EOL> Extension ( '<STR_LIT>' , [ chunker_source ] ) , <EOL> Extension ( '<STR_LIT>' , [ hashindex_source ] ) <EOL> ] <EOL> if sys . platform == '<STR_LIT>' : <EOL> ext_modules . append ( Extension ( '<STR_LIT>' , [ platform_linux_source ] , libraries = [ '<STR_LIT>' ] ) ) <EOL> elif sys . platform . startswith ( '<STR_LIT>' ) : <EOL> ext_modules . append ( Extension ( '<STR_LIT>' , [ platform_freebsd_source ] ) ) <EOL> elif sys . platform == '<STR_LIT>' : <EOL> ext_modules . append ( Extension ( '<STR_LIT>' , [ platform_darwin_source ] ) ) <EOL> setup ( <EOL> name = '<STR_LIT>' , <EOL> use_scm_version = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> author = '<STR_LIT>' , <EOL> author_email = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> description = '<STR_LIT>' , <EOL> long_description = long_description , <EOL> license = '<STR_LIT>' , <EOL> platforms = [ '<STR_LIT>' , '<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> '<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> packages = [ '<STR_LIT>' , '<STR_LIT>' , ] , <EOL> entry_points = { <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> } , <EOL> cmdclass = cmdclass , <EOL> ext_modules = ext_modules , <EOL> setup_requires = [ '<STR_LIT>' ] , <EOL> install_requires = install_requires , <EOL> extras_require = extras_require , <EOL> ) </s>
