<s> import os <EOL> import sys <EOL> import distutils . spawn <EOL> from vex . run import run <EOL> from vex import exceptions <EOL> PYDOC_SCRIPT = """<STR_LIT>""" . encode ( '<STR_LIT:ascii>' ) <EOL> PYDOC_BATCH = """<STR_LIT>""" . encode ( '<STR_LIT:ascii>' ) <EOL> def handle_make ( environ , options , make_path ) : <EOL> if os . path . exists ( make_path ) : <EOL> raise exceptions . VirtualenvAlreadyMade ( <EOL> "<STR_LIT>" . format ( make_path ) <EOL> ) <EOL> ve_base = os . path . dirname ( make_path ) <EOL> if not os . path . exists ( ve_base ) : <EOL> os . mkdir ( ve_base ) <EOL> elif not os . path . isdir ( ve_base ) : <EOL> raise exceptions . VirtualenvNotMade ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( ve_base ) <EOL> ) <EOL> if os . name == '<STR_LIT>' and not os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> ve = os . path . join ( <EOL> os . path . dirname ( sys . executable ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> else : <EOL> ve = '<STR_LIT>' <EOL> args = [ ve , make_path ] <EOL> if options . python : <EOL> if os . name == '<STR_LIT>' : <EOL> python = distutils . spawn . find_executable ( options . python ) <EOL> if python : <EOL> options . python = python <EOL> args += [ '<STR_LIT>' , options . python ] <EOL> if options . site_packages : <EOL> args += [ '<STR_LIT>' ] <EOL> if options . always_copy : <EOL> args += [ '<STR_LIT>' ] <EOL> returncode = run ( args , env = environ , cwd = ve_base ) <EOL> if returncode != <NUM_LIT:0> : <EOL> raise exceptions . VirtualenvNotMade ( "<STR_LIT>" ) <EOL> if os . name != '<STR_LIT>' : <EOL> pydoc_path = os . path . join ( make_path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> with open ( pydoc_path , '<STR_LIT:wb>' ) as out : <EOL> out . write ( PYDOC_SCRIPT ) <EOL> perms = os . stat ( pydoc_path ) . st_mode <EOL> os . chmod ( pydoc_path , perms | <NUM_LIT> ) <EOL> else : <EOL> pydoc_path = os . path . join ( make_path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> with open ( pydoc_path , '<STR_LIT:wb>' ) as out : <EOL> out . write ( PYDOC_BATCH ) </s>
