Skip to content

Commit f8be6fb

Browse files
committed
Optionally disable python 3.3 package creation
Python 3.3 plugin_host is optional as of ST4193. If disabled don't create py33 proxy package as it would otherwise just run on python 3.8 host likely causing issues.
1 parent 083af9a commit f8be6fb

File tree

1 file changed

+49
-42
lines changed

1 file changed

+49
-42
lines changed

plugin.py

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,62 +35,69 @@
3535

3636

3737
def plugin_loaded():
38-
if sys.version_info >= (3, 8):
39-
import json
40-
from textwrap import dedent
38+
if sys.version_info < (3, 8):
39+
return
4140

42-
UT33_CODE = dedent(
43-
"""
44-
from UnitTesting import plugin as ut38
41+
# python 3.3 plugin_host is optional in ST4193+
42+
settings = sublime.load_settings("Preferences.sublime-settings")
43+
if settings.get("disable_plugin_host_3.3", False):
44+
return
4545

46+
import json
47+
from textwrap import dedent
4648

47-
class UnitTesting33Command(ut38.UnitTestingCommand):
48-
\"\"\"Execute unit tests for python 3.3 plugins.\"\"\"
49-
pass
50-
"""
51-
).lstrip()
49+
UT33_CODE = dedent(
50+
"""
51+
from UnitTesting import plugin as ut38
5252
53-
UT33 = os.path.join(sublime.packages_path(), "UnitTesting33")
54-
os.makedirs(UT33, exist_ok=True)
5553
54+
class UnitTesting33Command(ut38.UnitTestingCommand):
55+
\"\"\"Execute unit tests for python 3.3 plugins.\"\"\"
56+
pass
57+
"""
58+
).lstrip()
59+
60+
UT33 = os.path.join(sublime.packages_path(), "UnitTesting33")
61+
os.makedirs(UT33, exist_ok=True)
62+
63+
try:
5664
try:
57-
try:
58-
with open(os.path.join(UT33, "plugin.py"), "x") as f:
59-
f.write(UT33_CODE)
60-
except FileExistsError:
61-
pass
62-
63-
try:
64-
with open(os.path.join(UT33, "dependencies.json"), "x") as f:
65-
f.write(
66-
json.dumps(
67-
{
68-
"linux-x32": {">3000": ["coverage"]},
69-
"linux-x64": {">3000": ["coverage"]},
70-
"osx-x32": {">3000": ["coverage"]},
71-
"osx-x64": {">3000": ["coverage"]},
72-
"windows-x32": {">3000": ["coverage"]},
73-
"windows-x64": {">3000": ["coverage"]},
74-
}
75-
)
65+
with open(os.path.join(UT33, "plugin.py"), "x") as f:
66+
f.write(UT33_CODE)
67+
except FileExistsError:
68+
pass
69+
70+
try:
71+
with open(os.path.join(UT33, "dependencies.json"), "x") as f:
72+
f.write(
73+
json.dumps(
74+
{
75+
"linux-x32": {">3000": ["coverage"]},
76+
"linux-x64": {">3000": ["coverage"]},
77+
"osx-x32": {">3000": ["coverage"]},
78+
"osx-x64": {">3000": ["coverage"]},
79+
"windows-x32": {">3000": ["coverage"]},
80+
"windows-x64": {">3000": ["coverage"]},
81+
}
7682
)
77-
except FileExistsError:
78-
pass
83+
)
84+
except FileExistsError:
85+
pass
7986

80-
try:
81-
# hide from Package Control quick panels
82-
open(os.path.join(UT33, ".hidden-sublime-package"), "x").close()
83-
except FileExistsError:
84-
pass
87+
try:
88+
# hide from Package Control quick panels
89+
open(os.path.join(UT33, ".hidden-sublime-package"), "x").close()
90+
except FileExistsError:
91+
pass
8592

86-
except OSError as e:
87-
print("UnitTesting: Error while creating python 3.3 module, since", str(e))
93+
except OSError as e:
94+
print("UnitTesting: Error while creating python 3.3 module, since", str(e))
8895

8996

9097
def plugin_unloaded():
9198
if sys.version_info >= (3, 8):
9299
UT33 = os.path.join(sublime.packages_path(), "UnitTesting33")
93100
try:
94101
shutil.rmtree(UT33)
95-
except Exception:
102+
except OSError:
96103
pass

0 commit comments

Comments
 (0)