From db64b2f37aa0208eb45b0a129126bd3de7ee2e02 Mon Sep 17 00:00:00 2001 From: doyle Date: Tue, 31 Jan 2023 23:07:01 +1100 Subject: [PATCH] Add eyes-thanks, rclone, make python script shorter --- devenver.py | 2 +- win_devenver_manifest.py | 68 +++++++++++++++++++---- win_install.py | 117 ++++++++++++++++++--------------------- 3 files changed, 113 insertions(+), 74 deletions(-) diff --git a/devenver.py b/devenver.py index 2145e2f..d241ce7 100644 --- a/devenver.py +++ b/devenver.py @@ -698,7 +698,7 @@ def run(user_app_list, global devenv_script_buffer devenv_script_buffer += "set PATH=%~dp0Symlinks;%PATH%\n" - devenv_script_name = "devenv.bat" if IS_WINDOWS else "devenv.sh" + devenv_script_name = "dev_env.bat" if IS_WINDOWS else "dev_env.sh" devenv_script_path = pathlib.Path(install_dir, devenv_script_name) lprint(f"Writing script to augment the environment with installed applications: {devenv_script_path}") with open(devenv_script_path, 'w') as file: diff --git a/win_devenver_manifest.py b/win_devenver_manifest.py index 29494e3..4de6b39 100644 --- a/win_devenver_manifest.py +++ b/win_devenver_manifest.py @@ -625,7 +625,7 @@ def get_manifest(): version = "1.4.13" git_hash = "0066c6" result.append({ - "label": "clink", + "label": "Clink", "manifests": [ { "download_url": f"https://github.com/chrisant996/clink/releases/download/v{version}/clink.{version}.{git_hash}.zip", @@ -694,7 +694,7 @@ def get_manifest(): version = "0.37.0" result.append({ - "label": "fzf", + "label": "FZF", "manifests": [ { "download_url": f"https://github.com/junegunn/fzf/releases/download/{version}/fzf-{version}-windows_amd64.zip", @@ -703,8 +703,8 @@ def get_manifest(): "executables": [ { "path": "fzf.exe", - "symlink": [], - "add_to_devenv_path": True, + "symlink": ["fzf.exe"], + "add_to_devenv_path": False, "checksum": "c0f4b20d0602977ff3e592cac8eadf86473abed0d24e2def81239bd2e76047e8", } ], @@ -717,7 +717,7 @@ def get_manifest(): version = "1.1.42" result.append({ - "label": "jpegview", + "label": "JPEGView", "manifests": [ { "download_url": f"https://github.com/sylikc/jpegview/releases/download/v{version}/JPEGView_{version}.7z", @@ -740,7 +740,7 @@ def get_manifest(): version = "22.02" result.append({ - "label": "mpc-qt", + "label": "MPC-Qt", "manifests": [ { "download_url": f"https://github.com/mpc-qt/mpc-qt/releases/download/v{version}/mpc-qt-win-x64-{version.replace('.', '')}.zip", @@ -763,7 +763,7 @@ def get_manifest(): version = "0.8.2" result.append({ - "label": "nvim", + "label": "NVim", "manifests": [ { "download_url": f"https://github.com/neovim/neovim/releases/download/v{version}/nvim-win64.zip", @@ -786,7 +786,7 @@ def get_manifest(): version = "0.10.3" result.append({ - "label": "neovide", + "label": "Neovide", "manifests": [ { "download_url": f"https://github.com/neovide/neovide/releases/download/{version}/neovide-windows.zip", @@ -878,7 +878,7 @@ def get_manifest(): version = "13.0.0" result.append({ - "label": "ripgrep", + "label": "Ripgrep", "manifests": [ { "download_url": f"https://github.com/BurntSushi/ripgrep/releases/download/{version}/ripgrep-{version}-x86_64-pc-windows-msvc.zip", @@ -901,7 +901,7 @@ def get_manifest(): version = "2.0.0" result.append({ - "label": "sioyek", + "label": "Sioyek", "manifests": [ { "download_url": f"https://github.com/ahrm/sioyek/releases/download/v{version}/sioyek-release-windows-portable.zip", @@ -924,7 +924,7 @@ def get_manifest(): version = "8.6.0" result.append({ - "label": "fd", + "label": "Fd", "manifests": [ { "download_url": f"https://github.com/sharkdp/fd/releases/download/v{version}/fd-v{version}-x86_64-pc-windows-msvc.zip", @@ -971,4 +971,50 @@ def get_manifest(): # -------------------------------------------------------------------------- + version = "1.61.1" + result.append({ + "label": "RClone", + "manifests": [ + { + "download_url": f"https://github.com/rclone/rclone/releases/download/v{version}/rclone-v{version}-windows-amd64.zip", + "download_checksum": "99daaa95867cdf0758ec1d5d7f2ebdb3bf74c8c8602e2aaf888e637163d2ebdd", + "version": version, + "executables": [ + { + "path": "rclone.exe", + "symlink": [], + "add_to_devenv_path": False, + "checksum": "e94901809ff7cc5168c1e857d4ac9cbb339ca1f6e21dcce95dfb8e28df799961", + } + ], + "add_to_devenv_script": [], + } + ], + }) + + # -------------------------------------------------------------------------- + + version = "1.5.3" + result.append({ + "label": "Eyes-Thanks", + "manifests": [ + { + "download_url": f"https://github.com/yalov/eyes-thanks/releases/download/{version}/EyesThanks_v{version}.zip", + "download_checksum": "6ab2b20730f56aa54263eb942be8849f52f9cba26438aee3c1b01103069411cc", + "version": version, + "executables": [ + { + "path": "Eyes' Thanks.exe", + "symlink": [], + "add_to_devenv_path": False, + "checksum": "48d232bd4a302b11378791eee844b42a2e30fe3553acf17a3b9e8ee0fcf27766", + } + ], + "add_to_devenv_script": [], + } + ], + }) + + # -------------------------------------------------------------------------- + return result diff --git a/win_install.py b/win_install.py index f2c1581..563e352 100644 --- a/win_install.py +++ b/win_install.py @@ -121,11 +121,11 @@ git_exe = installed_apps["Git"][0]['exe_path'] # Clink # ------------------------------------------------------------------------------ -clink_install_dir = installed_apps["clink"][0]['install_dir'] +clink_install_dir = installed_apps["Clink"][0]['install_dir'] clink_base_dir = clink_install_dir.parent # Gizmos -clink_gizmo_git_hash = "fb2edd9" +clink_gizmo_git_hash = "fb2edd9" clink_gizmo_install_dir = clink_base_dir / "clink-gizmos" git_clone(install_dir=clink_gizmo_install_dir, git_exe=git_exe, @@ -133,7 +133,7 @@ git_clone(install_dir=clink_gizmo_install_dir, commit_hash=clink_gizmo_git_hash) # Completions -clink_completions_git_hash = "86b6f07" +clink_completions_git_hash = "86b6f07" clink_completions_install_dir = clink_base_dir / "clink-completions" git_clone(install_dir=clink_completions_install_dir, git_exe=git_exe, @@ -161,8 +161,8 @@ git_clone(install_dir=odin_install_dir, devenver.print_header("Install configuration files") # Copy init.vim to NVIM directory -internal_dir = pathlib.Path(os.path.dirname(os.path.abspath(__file__)), "Internal") -nvim_init_dir = pathlib.Path(os.path.expanduser("~"), "AppData", "Local", "nvim") +internal_dir = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) / "Internal" +nvim_init_dir = pathlib.Path(os.path.expanduser("~")) / "AppData" / "Local" / "nvim" nvim_config_dest_path = nvim_init_dir / "init.vim" nvim_config_src_path = internal_dir / "os_nvim_init.vim" @@ -181,11 +181,12 @@ if not os.path.exists(nvim_plug_vim_path): # Install clink configuration # ------------------------------------------------------------------------------ -clink_profile_dir = clink_base_dir / "profile" - +clink_profile_dir = clink_base_dir / "profile" clink_settings_path = clink_profile_dir / "clink_settings" -clink_settings = f""" -# When this file is named "default_settings" and is in the binaries +devenver.lprint(f"Installing clink_settings to: {clink_settings_path}") + +clink_settings_path.parent.mkdir(exist_ok=True) +clink_settings_path.write_text(f"""# When this file is named "default_settings" and is in the binaries # directory or profile directory, it provides enhanced default settings. # Override built-in default settings with ones that provide a more @@ -221,26 +222,18 @@ match.substring = True clink.path = {clink_completions_install_dir};{clink_gizmo_install_dir} fzf.default_bindings = True -""" - -devenver.lprint(f"Installing clink_settings to: {clink_settings_path}") -clink_settings_path.parent.mkdir(exist_ok=True) -with open(clink_settings_path, "w+") as file: - file.write(clink_settings) +""") # Install wezterm configuration # ------------------------------------------------------------------------------ -wezterm_install_dir = installed_apps["WezTerm"][0]["install_dir"] -wezterm_exe_path = installed_apps["WezTerm"][0]["exe_path"] -wezterm_config_dest_path = wezterm_install_dir / "wezterm.lua" - +wezterm_config_dest_path = installed_apps["WezTerm"][0]["install_dir"] / "wezterm.lua" devenver.lprint(f"Installing WezTerm config to {wezterm_config_dest_path}") -clink_exe_path = clink_install_dir.relative_to(install_dir) / "clink_x64.exe" -clink_exe_path_for_wezterm = str(clink_exe_path).replace("\\", "\\\\") +clink_exe_path = clink_install_dir.relative_to(install_dir) / "clink_x64.exe" +clink_exe_path_for_wezterm = str(clink_exe_path).replace("\\", "\\\\") clink_profile_path_for_wezterm = str(clink_profile_dir.relative_to(install_dir)).replace("\\", "\\\\") -wezterm_lua_buffer = f"""local wezterm = require 'wezterm'; +wezterm_config_dest_path.write_text(f"""local wezterm = require 'wezterm'; local default_prog local set_environment_variables = {{}} @@ -248,7 +241,7 @@ local set_environment_variables = {{}} if wezterm.target_triple == "x86_64-pc-windows-msvc" then clink_exe = string.format("%s\\\\..\\\\..\\\\{clink_exe_path_for_wezterm}", wezterm.executable_dir) - devenv_bat = string.format("%s\\\\..\\\\..\\\\devenv.bat", wezterm.executable_dir) + devenv_bat = string.format("%s\\\\..\\\\..\\\\dev_env.bat", wezterm.executable_dir) msvc_bat = string.format("%s\\\\..\\\\..\\\\msvc\\\\msvc-{msvc_version}.bat", wezterm.executable_dir) win10_sdk_bat = string.format("%s\\\\..\\\\..\\\\msvc\\\\win-sdk-{win10_sdk_version}.bat", wezterm.executable_dir) clink_profile = string.format("%s\\\\..\\\\..\\\\{clink_profile_path_for_wezterm}", wezterm.executable_dir) @@ -271,15 +264,14 @@ return {{ default_prog = default_prog, set_environment_variables = set_environment_variables, }} -""" - -with open(wezterm_config_dest_path, "w") as file: - file.write(wezterm_lua_buffer) +""") # Wezterm super terminal -wezterm_exe_rel_path = pathlib.Path(wezterm_exe_path).relative_to(install_dir) -wezterm_terminal_script_path = pathlib.Path(install_dir, "win_terminal.bat") -wezterm_terminal_script = f"""@echo off +# ------------------------------------------------------------------------------ +wezterm_terminal_script_path = install_dir / "dev_terminal.bat" +devenver.lprint(f"Installing WezTerm terminal script to {wezterm_terminal_script_path}") + +wezterm_terminal_script_path.write_text(f"""@echo off setlocal EnableDelayedExpansion set working_dir= @@ -288,16 +280,18 @@ if "%~1" neq "" ( set working_dir=!working_dir:\=/! ) -call \"{msvc_install_dir}\\msvc-{msvc_version}.bat\" -call \"{msvc_install_dir}\\win-sdk-{win10_sdk_version}.bat\" +start "" /MAX "%~dp0{installed_apps["WezTerm"][0]["exe_path"].relative_to(install_dir)}" !working_dir! +""") -if exist "%~dp0win_terminal_user_config.bat" call "%~dp0win_terminal_user_config.bat" -start "" /MAX "%~dp0{wezterm_exe_rel_path}" !working_dir! -""" +# Run background scripts helper +# ------------------------------------------------------------------------------ +background_apps_script_path = pathlib.Path(install_dir, "dev_run_background_apps.bat") +devenver.lprint(f"Installing run background script (helper) to {background_apps_script_path}") -devenver.lprint(f"Installing WezTerm terminal script to {wezterm_terminal_script_path}") -with open(wezterm_terminal_script_path, "w") as file: - file.write(wezterm_terminal_script) +background_apps_script_path.write_text(f"""@echo off +start "" "%~dp0{installed_apps["Everything"][0]["exe_path"].relative_to(install_dir)}" +start "" "%~dp0{installed_apps["Eyes-Thanks"][0]["exe_path"].relative_to(install_dir)}" +""") # Create Odin work-around scripts # ------------------------------------------------------------------------------ @@ -305,17 +299,6 @@ with open(wezterm_terminal_script_path, "w") as file: # registry. Here we inject the registry entry that the SDK locator checks for # finding our portable MSVC installation. win10_sdk_find_test_dir_reg_path = str(win10_sdk_find_test_dir).replace("\\", "\\\\") -odin_msvc_install_script = f"""Windows Registry Editor Version 5.00 - -[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots] -"KitsRoot10"="{win10_sdk_find_test_dir_reg_path}" -""" - -odin_msvc_uninstall_script = f"""Windows Registry Editor Version 5.00 - -[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots] -"KitsRoot10"=- -""" odin_msvc_install_script_path = install_dir / "odin_msvc_install_workaround.reg" odin_msvc_uninstall_script_path = install_dir / "odin_msvc_uninstall_workaround.reg" @@ -324,27 +307,37 @@ devenver.lprint(f"Installing Odin MSVC workaround scripts", level=0) devenver.lprint(f" - {odin_msvc_install_script_path}", level=1) devenver.lprint(f" - {odin_msvc_uninstall_script_path}", level=1) -with open(odin_msvc_install_script_path, "w") as file: - file.write(odin_msvc_install_script) +odin_msvc_install_script_path.write_text(f"""Windows Registry Editor Version 5.00 -with open(odin_msvc_uninstall_script_path, "w") as file: - file.write(odin_msvc_uninstall_script) +[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots] +"KitsRoot10"="{win10_sdk_find_test_dir_reg_path}" +""") -# Add python-update bootstrap script +odin_msvc_uninstall_script_path.write_text(f"""Windows Registry Editor Version 5.00 + +[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots] +"KitsRoot10"=- +""") + +# Python # ------------------------------------------------------------------------------ # TODO: If I'm using the terminal that this script generates it will lock the # executable and Python cannot open the file for verifying the SHA256. -python_exe = pathlib.Path(installed_apps["Python"][0]['exe_path']).relative_to(install_dir) -python_install_dir = pathlib.Path(installed_apps["Python"][0]['exe_path']).parent.relative_to(install_dir) +python_exe_path = pathlib.Path(installed_apps["Python"][0]['exe_path']) + +# PyNvim +devenver.lprint(f"Installing PyNVIM") +subprocess.run(f"{python_exe_path} -m pip install pynvim") + +# Add update script +python_rel_exe_path = pathlib.Path(python_exe_path).relative_to(install_dir) +python_install_dir = pathlib.Path(python_exe_path).parent.relative_to(install_dir) win_setup_script_path = pathlib.Path(devenver.script_dir, "win_install.py") -bootstrap_setup_script = f"""@echo off +(install_dir / "dev_env_update.bat").write_text(f"""@echo off setlocal EnableDelayedExpansion set PYTHONHOME=%~dp0{python_install_dir} -%~dp0{python_exe} {win_setup_script_path} +%~dp0{python_rel_exe_path} {win_setup_script_path} pause -""" - -with open(install_dir / "upgrade_bootstrap.bat", "w") as file: - file.write(bootstrap_setup_script) +""")