diff --git a/README.md b/README.md index 43d37bb..1d1122a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Demo plugins: ## Cheatsheat ``` bash pants run cli:install -- pyminimal +pants run cli:install -- pyminimal win bin/lint diff --git a/cli/install.py b/cli/install.py index b7ea4d3..97a8581 100644 --- a/cli/install.py +++ b/cli/install.py @@ -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(): @@ -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])