Merge pull request #5621 from minggo/install

use terminal to input for all platforms
This commit is contained in:
minggo 2014-03-07 16:17:01 +08:00
commit 60b309ce8e
1 changed files with 50 additions and 55 deletions

105
setup.py
View File

@ -159,67 +159,69 @@ class SetEnvVar(object):
def _get_input_value(self, sys_var): def _get_input_value(self, sys_var):
# python on linux doesn't include Tkinter model, so let user input in terminal return raw_input('Couldn\'t find the "%s" envrironment variable. Please enter its path: ' % sys_var)
if self._isLinux():
input_value = raw_input('Couldn\'t find the "%s" envrironment variable. Please enter it: ' % sys_var)
else:
# pop up a window to let user select path for ndk root # # python on linux doesn't include Tkinter model, so let user input in terminal
import Tkinter # if self._isLinux():
import tkFileDialog # input_value = raw_input('Couldn\'t find the "%s" envrironment variable. Please enter it: ' % sys_var)
# else:
self.tmp_input_value = None # # pop up a window to let user select path for ndk root
# import Tkinter
# import tkFileDialog
root = Tkinter.Tk() # self.tmp_input_value = None
if sys_var == NDK_ROOT: # root = Tkinter.Tk()
root.wm_title('Set NDK_ROOT')
else:
root.wm_title('Set ANDROID_SDK_ROOT')
def callback(): # if sys_var == NDK_ROOT:
self.tmp_input_value = tkFileDialog.askdirectory() # root.wm_title('Set NDK_ROOT')
root.destroy() # else:
# root.wm_title('Set ANDROID_SDK_ROOT')
if sys_var == NDK_ROOT: # def callback():
label_content = 'Select path for Android NDK:' # self.tmp_input_value = tkFileDialog.askdirectory()
label_help = """ # root.destroy()
The Android NDK is needed to develop games for Android.
For further information, go to:
http://developer.android.com/tools/sdk/ndk/index.html.
You can safely skip this step now. You can set the NDK_ROOT later. # if sys_var == NDK_ROOT:
""" # label_content = 'Select path for Android NDK:'
# label_help = """
# The Android NDK is needed to develop games for Android.
# For further information, go to:
# http://developer.android.com/tools/sdk/ndk/index.html.
if sys_var == ANDROID_SDK_ROOT: # You can safely skip this step now. You can set the NDK_ROOT later.
label_content = 'Select path for Android SDK' # """
label_help = """
The Android SDK is needed to develop games for Android.
For further information, go to:
https://developer.android.com/tools/sdk/ndk/index.html.
You can safely skip this step now. You can set the ANDROID_SDK_ROOT later. # if sys_var == ANDROID_SDK_ROOT:
""" # label_content = 'Select path for Android SDK'
# label_help = """
# The Android SDK is needed to develop games for Android.
# For further information, go to:
# https://developer.android.com/tools/sdk/ndk/index.html.
Tkinter.Label(root, text=label_help).pack() # You can safely skip this step now. You can set the ANDROID_SDK_ROOT later.
Tkinter.Button(root, text=label_content, command=callback).pack() # """
self._center(root)
root.mainloop()
input_value = self.tmp_input_value # Tkinter.Label(root, text=label_help).pack()
self.tmp_input_value = None # Tkinter.Button(root, text=label_content, command=callback).pack()
# self._center(root)
# root.mainloop()
return input_value # input_value = self.tmp_input_value
# self.tmp_input_value = None
# display a window in center and put it on top # return input_value
def _center(self, win):
win.update_idletasks() # # display a window in center and put it on top
width = win.winfo_width() # def _center(self, win):
height = win.winfo_height() # win.update_idletasks()
x = (win.winfo_screenwidth() / 2) - (width / 2) # width = win.winfo_width()
y = (win.winfo_screenheight() / 2) - (height / 2) # height = win.winfo_height()
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) # x = (win.winfo_screenwidth() / 2) - (width / 2)
win.wm_attributes('-topmost', 1) # y = (win.winfo_screenheight() / 2) - (height / 2)
# win.geometry('{}x{}+{}+{}'.format(width, height, x, y))
# win.wm_attributes('-topmost', 1)
def _is_ndk_root_valid(self, ndk_root): def _is_ndk_root_valid(self, ndk_root):
if not ndk_root: if not ndk_root:
@ -322,13 +324,6 @@ if __name__ == '__main__':
parser.add_option('-a', '--androidsdkroot', dest='android_sdk_root', help='directory of android sdk root') parser.add_option('-a', '--androidsdkroot', dest='android_sdk_root', help='directory of android sdk root')
opts, args = parser.parse_args() opts, args = parser.parse_args()
# ndk_root is passed in
if opts.ndk_root:
os.environ[NDK_ROOT] = opts.ndk_root
if opts.android_sdk_root:
os.environ[ANDROID_SDK_ROOT] = opts.android_sdk_root
# set environment variables # set environment variables
env = SetEnvVar() env = SetEnvVar()
env.set_environment_variables(opts.ndk_root, opts.android_sdk_root) env.set_environment_variables(opts.ndk_root, opts.android_sdk_root)