Skip to content

Commit 5b55f0d

Browse files
committed
Merge branch 'pull80'
2 parents 9d79682 + 1701a89 commit 5b55f0d

2 files changed

Lines changed: 50 additions & 17 deletions

File tree

README.markdown

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ I also added a lot caching throughout the underlying Rope library which improved
1414
Configuration
1515
-------------
1616

17+
## Python location
18+
1719
The only necessary configuration is pointing SublimePythonIDE at the correct Python interpreter to use.
1820
There are four mechanisms for detecting Python that are used in the following order:
1921

@@ -40,6 +42,13 @@ The option "python_interpreter" can be set in the projects settings (Project->Ed
4042

4143
This is also the way to select a virtualenv (point it to the interpreter in the venv) and thus get the completions/definitions for you project working.
4244

45+
To suppress the "Could not find Python dialog", save the following setting:
46+
47+
"suppress_python_not_found_error": false,
48+
49+
50+
## Imports location
51+
4352
SublimePythonIDE will also look up imports relative to the project root directory (the top directory of your project).
4453

4554
In cases where the project directory is outside of your root python module, you may optionally set a custom source root directory in the project settings:

sublime_python.py

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -358,24 +358,48 @@ def proxy_for(view):
358358

359359

360360
def show_python_not_found_error(python_detectors):
361-
if LAST_ERROR_TIME is None or (time.time() - LAST_ERROR_TIME > 10.0):
362-
do_not_show_again = sublime.ok_cancel_dialog("""
363-
Could not detect python, please set the python_interpreter (see README) using an absolute path or make sure a
364-
system python is installed and is reachable on the PATH. Here is the order in which paths are tried:
365-
366-
- By "python_interpreter" Sublime settings: %r
367-
- By auto-detecting venv: %r
368-
- By #! (shebang) line in this file: %r
369-
- By auto-detecting system Python: %r
370-
371-
We use the first non-None value and ensure that the path exists before proceeding.
372-
""" % tuple(d() for d in python_detectors), "Do not show again")
373-
374-
global LAST_ERROR_TIME
375-
if do_not_show_again:
361+
global LAST_ERROR_TIME
362+
if LAST_ERROR_TIME is not None and (time.time() < LAST_ERROR_TIME + 10.0):
363+
return
364+
LAST_ERROR_TIME = time.time()
365+
366+
msg = (
367+
"SublimePythonIDE: Could not find Python.\n"
368+
"Make sure Python is accessible via one of these methods:\n"
369+
"\n"
370+
" \xb7 From SublimePythonIDE settings:\n"
371+
" %r\n"
372+
" \xb7 From venv settings:\n"
373+
" %r\n"
374+
" \xb7 From #! (shebang) line in this file:\n"
375+
" %r\n"
376+
" \xb7 From system Python (via $PATH):\n"
377+
" %r\n"
378+
"\n"
379+
"We use the first non-None value and ensure that the path exists before proceeding.\n"
380+
% tuple(d() for d in python_detectors)
381+
)
382+
383+
if not get_setting("suppress_python_not_found_error", False):
384+
result = sublime.yes_no_cancel_dialog(
385+
msg +
386+
"\n"
387+
"\"Do Not Show Again\" suppresses this dialog until next launch. "
388+
"\"More Info\" shows help for configuring Python or permanently suppressing this dialog."
389+
, "More Info", "Do Not Show Again"
390+
)
391+
# In case the user takes more than 10 seconds to react to the dialog
392+
LAST_ERROR_TIME = time.time()
393+
if result == sublime.DIALOG_YES:
394+
import webbrowser
395+
webbrowser.open("https://github.com/JulianEberius/SublimePythonIDE#configuration")
396+
elif result == sublime.DIALOG_NO:
376397
LAST_ERROR_TIME = float("inf")
377-
else:
378-
LAST_ERROR_TIME = time.time()
398+
399+
raise OSError(
400+
msg +
401+
"More info: https://github.com/JulianEberius/SublimePythonIDE#configuration"
402+
)
379403

380404

381405
def root_folder_for(view):

0 commit comments

Comments
 (0)