Bootstrap - Copy - Py
Bootstrap - Copy - Py
us>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
reload(sys)
sys.setdefaultencoding(FSENCODING) # @UndefinedVariable
sys.stdout = old_stdout
sys.stderr = old_stderr
import renpy.error
def extra_imports():
import datetime; datetime
import encodings.ascii; encodings.ascii
import encodings.utf_8; encodings.utf_8
import encodings.zlib_codec; encodings.zlib_codec
import encodings.unicode_escape; encodings.unicode_escape
import encodings.string_escape; encodings.string_escape
import encodings.raw_unicode_escape; encodings.raw_unicode_escape
import encodings.mbcs; encodings.mbcs
import encodings.utf_16; encodings.utf_16
import encodings.utf_16_be; encodings.utf_16_be
import encodings.utf_16_le; encodings.utf_16_le
import encodings.utf_32_be; encodings.utf_32_be
import encodings.latin_1; encodings.latin_1
import encodings.hex_codec; encodings.hex_codec
import encodings.base64_codec; encodings.base64_codec
import encodings.idna; encodings.idna
import math; math
import glob; glob
import pickle; pickle
import difflib; difflib
import shutil; shutil
import tarfile; tarfile
import bz2; bz2 # @UnresolvedImport
import webbrowser; webbrowser
import posixpath; posixpath
import ctypes; ctypes
import ctypes.wintypes; ctypes.wintypes
import argparse; argparse
import compiler; compiler
import textwrap; textwrap
import copy; copy
import urllib; urllib
import urllib2; urllib2
import codecs; codecs
import rsa; rsa
import decimal; decimal
import plistlib; plistlib
import _renpysteam; _renpysteam
import compileall; compileall
import cProfile; cProfile
import pstats; pstats
import _ssl; _ssl
import SimpleHTTPServer; SimpleHTTPServer
# Used by requests.
import cgi; cgi
import Cookie; Cookie
import hmac; hmac
import Queue; Queue
import uuid; uuid
class NullFile(io.IOBase):
"""
This file raises an error on input, and IOError on read.
"""
def null_files():
try:
if sys.stderr.fileno() < 0:
sys.stderr = NullFile()
if sys.stdout.fileno() < 0:
sys.stdout = NullFile()
except:
pass
null_files()
trace_file = None
trace_local = None
def enable_trace(level):
global trace_file
global trace_local
if level > 1:
trace_local = trace_function
else:
trace_local = None
sys.settrace(trace_function)
def mac_start(fn):
os.system("open " + fn)
def bootstrap(renpy_base):
if os.path.exists(alt_path + "/environment.txt"):
evars = { }
execfile(alt_path + "/environment.txt", evars)
for k, v in evars.iteritems():
if k not in os.environ:
os.environ[k] = str(v)
if name.find(".") != -1:
name = name[:name.find(".")]
if args.trace:
enable_trace(args.trace)
if args.basedir:
basedir = os.path.abspath(args.basedir).decode(FSENCODING)
else:
basedir = renpy_base
if not os.path.exists(basedir):
sys.stderr.write("Base directory %r does not exist. Giving up.\n" %
(basedir,))
sys.exit(1)
gamedirs = [ name ]
game_name = name
while game_name:
prefix = game_name[0]
game_name = game_name[1:]
for i in gamedirs:
if i == "renpy":
continue
if renpy.macintosh:
# If we're on a mac, install our own os.start.
os.startfile = mac_start
# Check that we have installed pygame properly. This also deals with
# weird cases on Windows and Linux where we can't import modules. (On
# windows ";" is a directory separator in PATH, so if it's in a parent
# directory, we won't get the libraries in the PATH, and hence pygame
# won't import.)
try:
import pygame_sdl2
if not ("pygame" in sys.modules):
pygame_sdl2.import_as_pygame()
except:
print("""\
Could not import pygame_sdl2. Please ensure that this program has been built
and unpacked properly. Also, make sure that the directories containing
this program do not contain : or ; in their names.
raise
renpy.loader.init_importer()
exit_status = None
try:
while exit_status is None:
exit_status = 1
try:
renpy.game.args = args
renpy.config.renpy_base = renpy_base
renpy.config.basedir = basedir
renpy.config.gamedir = gamedir
renpy.config.args = [ ]
if renpy.android:
renpy.config.logdir = os.environ['ANDROID_PUBLIC']
else:
renpy.config.logdir = basedir
if not os.path.exists(renpy.config.logdir):
os.makedirs(renpy.config.logdir, 0o777)
renpy.main.main()
exit_status = 0
except KeyboardInterrupt:
raise
except renpy.game.UtterRestartException:
exit_status = None
except renpy.game.QuitException as e:
exit_status = e.status
if e.relaunch:
if hasattr(sys, "renpy_executable"):
subprocess.Popen([sys.renpy_executable] + sys.argv[1:])
else:
subprocess.Popen([sys.executable, "-EO"] + sys.argv)
except renpy.game.ParseErrorException:
pass
except Exception as e:
renpy.error.report_exception(e)
pass
sys.exit(exit_status)
finally:
if "RENPY_SHUTDOWN_TRACE" in os.environ:
enable_trace(int(os.environ["RENPY_SHUTDOWN_TRACE"]))
renpy.display.im.cache.quit()
if renpy.display.draw:
renpy.display.draw.quit()
renpy.audio.audio.quit()