+ minv = _wxPackageInfo(minVersion)
+
+ # check the default version first
+ defaultPath = _find_default()
+ if defaultPath:
+ defv = _wxPackageInfo(defaultPath, True)
+ if defv >= minv and minv.CheckOptions(defv, optionsRequired):
+ bestMatch = defv
+
+ # if still no match then check look at all installed versions
+ if bestMatch is None:
+ installed = _find_installed()
+ # The list is in reverse sorted order, so find the first
+ # one that is big enough and optionally matches the
+ # options
+ for inst in installed:
+ if inst >= minv and minv.CheckOptions(inst, optionsRequired):
+ bestMatch = inst
+ break
+
+ # if still no match then prompt the user
+ if bestMatch is None:
+ if _EM_DEBUG: # We'll do it this way just for the test code below
+ raise VersionError("Requested version of wxPython not found")
+
+ import wx, webbrowser
+ versions = "\n".join([" "+ver for ver in getInstalled()])
+ app = wx.PySimpleApp()
+ result = wx.MessageBox("This application requires a version of wxPython "
+ "greater than or equal to %s, but a matching version "
+ "was not found.\n\n"
+ "You currently have these version(s) installed:\n%s\n\n"
+ "Would you like to download a new version of wxPython?\n"
+ % (minVersion, versions),
+ "wxPython Upgrade Needed", style=wx.YES_NO)
+ if result == wx.YES:
+ webbrowser.open(UPDATE_URL)
+ app.MainLoop()
+ sys.exit()
+
+ sys.path.insert(0, bestMatch.pathname)
+ # q.v. Bug #1409256
+ path64 = re.sub('/lib/','/lib64/',bestMatch.pathname)
+ if os.path.isdir(path64):
+ sys.path.insert(0, path64)
+ global _selected
+ _selected = bestMatch
+
+
+#----------------------------------------------------------------------
+
+def checkInstalled(versions, optionsRequired=False):
+ """
+ Check if there is a version of wxPython installed that matches one
+ of the versions given. Returns True if so, False if not. This
+ can be used to determine if calling `select` will succeed or not.
+
+ :param versions: Same as in `select`, either a string or a list
+ of strings specifying the version(s) to check for.
+
+ :param optionsRequired: Same as in `select`.
+ """
+