scrapeboard/OPEN-GAME

47 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python
from os import environ, execvp, chdir, getcwd
from os.path import exists, join, dirname
from sys import version_info, argv, maxint
def can_import(module_name):
try:
__import__(module_name)
except ImportError:
return False
else:
return True
def is_python_3():
return version_info[0] >= 3
def is_current_version(file_name):
version = map(int, file_name.replace("python", "").split("."))
return version == list(version_info)[:2]
def launch_alternative(alternatives):
for alternative in alternatives:
if not is_current_version(alternative):
for root in environ["PATH"].split(":"):
if exists(join(root, alternative)):
execvp(alternative, [alternative] + argv)
def move_to_executable():
chdir(dirname(argv[0]))
if is_python_3():
launch_alternative(["python2", "python2.7", "python2.6"])
if maxint >> 33:
launch_alternative(["python-32", "python2-32", "python2.7-32", "python2.6-32"])
if not can_import("pygame"):
launch_alternative(["python2.7", "python2.6"])
if "--go-to-dir" in argv:
move_to_executable()
from NS import NS
NS().run()