Skip to content

Commit

Permalink
packager for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii committed Dec 30, 2023
1 parent e3078d0 commit d0996b3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Demo plugins:
## Cheatsheat
``` bash
pants run cli:install -- pyminimal
pants run cli:install -- pyminimal win

bin/lint

Expand Down
33 changes: 28 additions & 5 deletions cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,40 @@
import subprocess
import sys
from pathlib import Path
import subprocess


def install(name):
if not Path(f"plugins/{name}").exists():
print(f"No such plugin: {name}")
exit(-1)

def get_plugins_path():
if "TEXMACS_HOME_PATH" in os.environ.keys():
texmacs_home_path = Path(os.environ.get("TEXMACS_HOME_PATH"))
plugins = texmacs_home_path.joinpath("plugins")
else:
plugins = Path.home().joinpath(".TeXmacs", "plugins")
return plugins


def install_win(name):
plugins = get_plugins_path()
plugin = plugins.joinpath(name)
binary = plugin.joinpath("bin")
pex = binary.joinpath(name + ".pex")
entry = binary.joinpath("plugins").joinpath(name + ".py")
os.chdir(binary)
subprocess.call(["tar", "xzvf", pex])
os.remove(binary.joinpath("PEX-INFO"))
os.remove(binary.joinpath("__main__.py"))
os.remove(pex)
shutil.rmtree(binary.joinpath("__pex__"))
shutil.rmtree(binary.joinpath(".bootstrap"))
shutil.move(entry, pex)


def install(name):
if not Path(f"plugins/{name}").exists():
print(f"No such plugin: {name}")
exit(-1)

plugins = get_plugins_path()
plugin = plugins.joinpath(name)
binary = plugin.joinpath("bin")
if plugin.exists():
Expand All @@ -35,3 +56,5 @@ def install(name):

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

0 comments on commit d0996b3

Please sign in to comment.