Skip to content

Commit 1b92988

Browse files
authored
packager for windows
1 parent e3078d0 commit 1b92988

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Demo plugins:
1414
## Cheatsheat
1515
``` bash
1616
pants run cli:install -- pyminimal
17+
pants run cli:install -- pyminimal win
1718

1819
bin/lint
1920

cli/install.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,40 @@
33
import subprocess
44
import sys
55
from pathlib import Path
6+
import subprocess
67

78

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():
1310
if "TEXMACS_HOME_PATH" in os.environ.keys():
1411
texmacs_home_path = Path(os.environ.get("TEXMACS_HOME_PATH"))
1512
plugins = texmacs_home_path.joinpath("plugins")
1613
else:
1714
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)
1838

39+
plugins = get_plugins_path()
1940
plugin = plugins.joinpath(name)
2041
binary = plugin.joinpath("bin")
2142
if plugin.exists():
@@ -35,3 +56,5 @@ def install(name):
3556

3657
if __name__ == "__main__":
3758
install(sys.argv[1])
59+
if len(sys.argv) == 3 and sys.argv[2] == "win":
60+
install_win(sys.argv[1])

0 commit comments

Comments
 (0)