Permalink
Browse files

Resolve import errors in Python3

The built-in interpreter in Sublime Text 3 raises 'ImportError'
exceptions if imports aren't relative to the 'Packages' directory.
The same issue doesn't occur in the standard Python3 interpreter.
Resolve the issue by hacking the path when running in Sublime Text.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
  • Loading branch information...
stephenfin committed Oct 19, 2014
1 parent cf8f0d7 commit 48f1cd3bcfb8928f4202f43954617029e09aad4c
Showing with 8 additions and 10 deletions.
  1. +8 −10 ctagsplugin.py
View
@@ -21,23 +21,21 @@
import sublime
import sublime_plugin
from sublime import status_message, error_message
+
+ # hack the system path to prevent the following issue in ST3
+ # ImportError: No module named 'ctags'
+ sys.path.append(os.path.dirname(os.path.realpath(__file__)))
except ImportError: # running tests
from tests.sublime_fake import sublime
from tests.sublime_fake import sublime_plugin
sys.modules['sublime'] = sublime
sys.modules['sublime_plugin'] = sublime_plugin
-if sys.version_info < (3, 0):
- import ctags
- from ctags import (FILENAME, parse_tag_lines, PATH_ORDER, SYMBOL,
- TagElements, TagFile)
- from helpers.edit import Edit
-else:
- from CTags import ctags
- from CTags.ctags import (FILENAME, parse_tag_lines, PATH_ORDER, SYMBOL,
- TagElements, TagFile)
- from CTags.helpers.edit import Edit
+import ctags
+from ctags import (FILENAME, parse_tag_lines, PATH_ORDER, SYMBOL,
+ TagElements, TagFile)
+from helpers.edit import Edit
#
# Contants

0 comments on commit 48f1cd3

Please sign in to comment.