3
3
import subprocess
4
4
import sys
5
5
from pathlib import Path
6
+ import subprocess
6
7
7
8
8
- def install (name ):
9
- if not Path (f"plugins/{ name } " ).exists ():
10
- print (f"No such plugin: { name } " )
11
- exit (- 1 )
12
-
9
+ def get_plugins_path ():
13
10
if "TEXMACS_HOME_PATH" in os .environ .keys ():
14
11
texmacs_home_path = Path (os .environ .get ("TEXMACS_HOME_PATH" ))
15
12
plugins = texmacs_home_path .joinpath ("plugins" )
16
13
else :
17
14
plugins = Path .home ().joinpath (".TeXmacs" , "plugins" )
15
+ return plugins
16
+
17
+
18
+ def install_win (name ):
19
+ plugins = get_plugins_path ()
20
+ plugin = plugins .joinpath (name )
21
+ binary = plugin .joinpath ("bin" )
22
+ pex = binary .joinpath (name + ".pex" )
23
+ entry = binary .joinpath ("plugins" ).joinpath (name + ".py" )
24
+ os .chdir (binary )
25
+ subprocess .call (["tar" , "xzvf" , pex ])
26
+ os .remove (binary .joinpath ("PEX-INFO" ))
27
+ os .remove (binary .joinpath ("__main__.py" ))
28
+ os .remove (pex )
29
+ shutil .rmtree (binary .joinpath ("__pex__" ))
30
+ shutil .rmtree (binary .joinpath (".bootstrap" ))
31
+ shutil .move (entry , pex )
32
+
33
+
34
+ def install (name ):
35
+ if not Path (f"plugins/{ name } " ).exists ():
36
+ print (f"No such plugin: { name } " )
37
+ exit (- 1 )
18
38
39
+ plugins = get_plugins_path ()
19
40
plugin = plugins .joinpath (name )
20
41
binary = plugin .joinpath ("bin" )
21
42
if plugin .exists ():
@@ -35,3 +56,5 @@ def install(name):
35
56
36
57
if __name__ == "__main__" :
37
58
install (sys .argv [1 ])
59
+ if len (sys .argv ) == 3 and sys .argv [2 ] == "win" :
60
+ install_win (sys .argv [1 ])
0 commit comments