Add user apps

This commit is contained in:
doyle 2023-02-07 21:45:29 +11:00
parent 82611b2d3b
commit abc33563a4
5 changed files with 335 additions and 225 deletions

6
.gitignore vendored
View File

@ -1,4 +1,4 @@
Docs
Downloads Downloads
Home __pycache__
Tools Win
Docs

View File

@ -321,15 +321,21 @@ def download_and_install_archive(download_url,
# We call this an intermediate zip file, we will extract that file # We call this an intermediate zip file, we will extract that file
# with 7zip. After we're done, we will delete that _intermediate_ # with 7zip. After we're done, we will delete that _intermediate_
# file to cleanup our install directory. # file to cleanup our install directory.
if archive_path.suffix == '.zst': if archive_path.suffix == '.zst' or archive_path.suffix == '.xz':
archive_without_suffix = pathlib.Path(str(archive_path)[:-len(archive_path.suffix)]).name archive_without_suffix = pathlib.Path(str(archive_path)[:-len(archive_path.suffix)]).name
next_archive_path = pathlib.Path(exe_install_dir, archive_without_suffix) next_archive_path = pathlib.Path(exe_install_dir, archive_without_suffix)
if os.path.exists(next_archive_path) == False: if os.path.exists(next_archive_path) == False:
command = f'"{zstd_exe}" --output-dir-flat "{exe_install_dir}" -d "{archive_path}"' if archive_path.suffix == '.zst':
lprint(f'- zstd unzip {label} to: {exe_install_dir}', level=1) command = f'"{zstd_exe}" --output-dir-flat "{exe_install_dir}" -d "{archive_path}"'
lprint(f' Command: {command}', level=1) lprint(f'- zstd unzip {label} to: {exe_install_dir}', level=1)
lprint(f' Command: {command}', level=1)
else:
command = f'"{zip7_exe}" x -aoa -spe -bso0 "{archive_path}" -o"{exe_install_dir}"'
command = command.replace('\\', '/')
lprint(f'- 7z unzip install {label} to: {exe_install_dir}', level=1)
lprint(f' Command: {command}', level=1)
os.makedirs(exe_install_dir) os.makedirs(exe_install_dir)
subprocess.run(command) subprocess.run(command)
@ -541,9 +547,7 @@ def validate_app_list(app_list):
return result return result
devenv_script_buffer = """@echo off devenv_script_buffer = ""
"""
def install_app_list(app_list, download_dir, install_dir): def install_app_list(app_list, download_dir, install_dir):
title = "Internal Apps" if app_list is internal_app_list else "User Apps" title = "Internal Apps" if app_list is internal_app_list else "User Apps"
print_header(title) print_header(title)
@ -631,15 +635,16 @@ def install_app_list(app_list, download_dir, install_dir):
return result return result
script_dir = os.path.dirname(os.path.abspath(__file__)) script_dir = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))
default_base_dir = script_dir default_base_dir = script_dir
default_base_downloads_dir = os.path.join(default_base_dir, 'Downloads') default_base_downloads_dir = default_base_dir / 'Downloads'
default_base_install_dir = os.path.join(default_base_dir, 'Install') default_base_install_dir = default_base_dir / 'Install'
base_downloads_dir = default_base_downloads_dir base_downloads_dir = default_base_downloads_dir
base_install_dir = default_base_install_dir base_install_dir = default_base_install_dir
def run(user_app_list, def run(user_app_list,
devenv_script_name,
download_dir=base_downloads_dir, download_dir=base_downloads_dir,
install_dir=base_install_dir): install_dir=base_install_dir):
""" Download and install the given user app list at the specified """ Download and install the given user app list at the specified
@ -688,6 +693,11 @@ def run(user_app_list,
if not os.path.isdir(path): if not os.path.isdir(path):
exit(f'Path "{path}" is not a directory, script can not proceed. Exiting.') exit(f'Path "{path}" is not a directory, script can not proceed. Exiting.')
global devenv_script_buffer
devenv_script_buffer = """@echo off
"""
# Validate all the manifests before starting # Validate all the manifests before starting
internal_app_validate_result = validate_app_list(internal_app_list) internal_app_validate_result = validate_app_list(internal_app_list)
user_app_validate_result = validate_app_list(user_app_list) user_app_validate_result = validate_app_list(user_app_list)
@ -702,10 +712,9 @@ def run(user_app_list,
install_dir=install_dir) install_dir=install_dir)
# Write the devenv script with environment variables # Write the devenv script with environment variables
global devenv_script_buffer
devenv_script_buffer += "set PATH=%~dp0Symlinks;%PATH%\n" devenv_script_buffer += "set PATH=%~dp0Symlinks;%PATH%\n"
devenv_script_name = "dev_env.bat" if IS_WINDOWS else "dev_env.sh" devenv_script_name = f"{devenv_script_name}.bat" if IS_WINDOWS else f"{devenv_script_name}dev_env.sh"
devenv_script_path = pathlib.Path(install_dir, devenv_script_name) devenv_script_path = pathlib.Path(install_dir, devenv_script_name)
lprint(f"Writing script to augment the environment with installed applications: {devenv_script_path}") lprint(f"Writing script to augment the environment with installed applications: {devenv_script_path}")
with open(devenv_script_path, 'w') as file: with open(devenv_script_path, 'w') as file:
@ -721,29 +730,3 @@ def run(user_app_list,
result[key] += value result[key] += value
return result return result
if __name__ == '__main__':
# Arguments
# ------------------------------------------------------------------------------
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--downloads-dir',
help=f'Set the directory where downloaded files are cached (default: {default_base_downloads_dir})',
default=default_base_downloads_dir,
type=pathlib.Path)
arg_parser.add_argument('--install-dir',
help=f'Set the directory where downloaded files are installed (default: {default_base_install_dir})',
default=default_base_install_dir,
type=pathlib.Path)
arg_parser.add_argument('--version',
action='version',
version='DEVenver v1')
args = arg_parser.parse_args()
base_downloads_dir = args.base_install_dir
base_install_dir = args.install_dir
run()

View File

@ -1109,4 +1109,27 @@ def get_manifest():
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
version = "2.7.4"
result.append({
"label": "KeePassXC",
"manifests": [
{
"download_url": f"https://github.com/keepassxreboot/keepassxc/releases/download/{version}/KeePassXC-{version}-Win64.zip",
"download_checksum": "2ffb7a3289d008d3cd3ad0efffc3238d10a0ce176217d5e7bc34e1b59bcc644a",
"version": version,
"executables": [
{
"path": "KeePassXC.exe",
"symlink": [],
"add_to_devenv_path": False,
"checksum": "3102bb194dbc60e9ab4ba6c0024129893c8d845c1acf576aab0c05e607ef47ad",
}
],
"add_to_devenv_script": [],
}
],
})
# --------------------------------------------------------------------------
return result return result

52
win_app_manifest_user.py Normal file
View File

@ -0,0 +1,52 @@
def get_manifest():
result = []
# --------------------------------------------------------------------------
version = "7.9.0"
result.append({
"label": "digiKam",
"manifests": [
{
"download_url": f"https://download.kde.org/stable/digikam/{version}/digiKam-{version}-Win64.tar.xz",
"download_checksum": "810476996461dc9275e97f1aa0438c77d0fe49f6ae5f6ae36fca983022dafe71",
"version": version,
"executables": [
{
"path": "digikam.exe",
"symlink": [],
"add_to_devenv_path": False,
"checksum": "aebabac51581c4a0a8fd6950c728d5b8a2306b7251e5f9b1987a437f3576d2c8",
}
],
"add_to_devenv_script": [],
}
],
})
# --------------------------------------------------------------------------
version = "0.25.0"
result.append({
"label": "PicoTorrent",
"manifests": [
{
"download_url": f"https://github.com/picotorrent/picotorrent/releases/download/v{version}/PicoTorrent-{version}-x64.zip",
"download_checksum": "375c2445db76b7d51b7cd351b1c5b40f895fb15b502da6073e19aaf6cb08cd76",
"version": version,
"executables": [
{
"path": "picotorrent.exe",
"symlink": [],
"add_to_devenv_path": False,
"checksum": "135adefb184d6a28d75b18fefebcd23e62005246664ff12f8af5687823630829",
}
],
"add_to_devenv_script": [],
}
],
})
# --------------------------------------------------------------------------
return result

View File

@ -6,9 +6,12 @@ import pathlib
import os import os
import shutil import shutil
import tempfile import tempfile
import win_devenver_manifest import argparse
import urllib.request import urllib.request
import win_app_manifest_dev
import win_app_manifest_user
def git_clone(install_dir, git_exe, url, commit_hash): def git_clone(install_dir, git_exe, url, commit_hash):
devenver.lprint(f"Git clone {url} to {install_dir}", level=0) devenver.lprint(f"Git clone {url} to {install_dir}", level=0)
# Clone repository if it does not exist # Clone repository if it does not exist
@ -28,165 +31,198 @@ def git_clone(install_dir, git_exe, url, commit_hash):
subprocess.run(f"{git_exe} pull origin master", cwd=install_dir) subprocess.run(f"{git_exe} pull origin master", cwd=install_dir)
subprocess.run(f"{git_exe} checkout {commit_hash}", cwd=install_dir) subprocess.run(f"{git_exe} checkout {commit_hash}", cwd=install_dir)
# Run DEVenver, installing the portable apps # Arguments
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
download_dir = pathlib.Path(os.path.join(devenver.script_dir, 'Downloads')) default_download_dir = devenver.script_dir / 'Downloads'
install_dir = pathlib.Path(os.path.join(devenver.script_dir, 'Win')) default_install_dir = devenver.script_dir / 'Win'
user_app_list = win_devenver_manifest.get_manifest() arg_parser = argparse.ArgumentParser()
installed_apps = devenver.run(user_app_list=user_app_list, arg_parser.add_argument('--download-dir',
download_dir=download_dir, help=f'Set the directory where downloaded files are cached (default: {default_download_dir})',
install_dir=install_dir) default=default_download_dir,
type=pathlib.Path)
# Install MSVC arg_parser.add_argument('--install-dir',
help=f'Set the directory where downloaded files are installed (default: {default_install_dir})',
default=default_install_dir,
type=pathlib.Path)
arg_parser.add_argument('--with-dev-apps',
help=f'Download and install apps from the developer manifest',
const=True,
action="store_const")
arg_parser.add_argument('--with-user-apps',
help=f'Download and install apps from the user manifest',
const=True,
action="store_const")
args = arg_parser.parse_args()
download_dir = args.download_dir
install_dir = args.install_dir
# Install development apps
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
devenver.print_header("Install MSVC & Windows 10 SDK") if args.with_dev_apps:
msvc_script = pathlib.Path(devenver.script_dir, "win_portable_msvc.py") # Run DEVenver, installing the portable apps
msvc_version = "14.34" # --------------------------------------------------------------------------
win10_sdk_version = "22621" dev_env_script_name = "dev_env"
app_list = win_app_manifest_dev.get_manifest()
installed_dev_apps = devenver.run(user_app_list=app_list,
download_dir=download_dir,
install_dir=install_dir,
devenv_script_name=dev_env_script_name)
msvc_install_dir = install_dir / "msvc"
# Basic heuristic to see if we"ve already installed the MSVC/SDK version # Install MSVC
msvc_installed = False # --------------------------------------------------------------------------
win10_sdk_installed = False devenver.print_header("Install MSVC & Windows 10 SDK")
msvc_script = devenver.script_dir / "win_portable_msvc.py"
msvc_version = "14.34"
win10_sdk_version = "22621"
msvc_find_test_dir = msvc_install_dir / "VC/Tools/MSVC" msvc_install_dir = install_dir / "msvc"
win10_sdk_find_test_dir = msvc_install_dir / "Windows Kits/10"
if os.path.exists(msvc_find_test_dir): # Basic heuristic to see if we"ve already installed the MSVC/SDK version
for file_name in os.listdir(msvc_find_test_dir): msvc_installed = False
msvc_installed = file_name.startswith(msvc_version) win10_sdk_installed = False
if msvc_installed == True:
devenver.lprint(f"MSVC {msvc_version} install detected (skip download) in {msvc_find_test_dir}\\{file_name}")
break
if not msvc_installed:
devenver.lprint(f"MSVC {msvc_version} install not detected (need to download) in {msvc_find_test_dir}")
if os.path.exists(win10_sdk_find_test_dir): msvc_find_test_dir = msvc_install_dir / "VC/Tools/MSVC"
for file_name in os.listdir(win10_sdk_find_test_dir / "bin"): win10_sdk_find_test_dir = msvc_install_dir / "Windows Kits/10"
# Check if directory contains version substring, 22621, e.g. "10.0.22621.0"
win10_sdk_installed = file_name.count(win10_sdk_version) > 0
if win10_sdk_installed == True:
install_locations = f"{win10_sdk_find_test_dir}\\*\\{file_name}"
devenver.lprint(f"Windows 10 SDK {win10_sdk_version} install detected (skip download) in {install_locations}")
break
if not win10_sdk_installed:
devenver.lprint(f"Windows 10 SDK {win10_sdk_version} not detected (need to download) in {win10_sdk_find_test_dir}")
# Install MSVC if os.path.exists(msvc_find_test_dir):
if msvc_installed == False or win10_sdk_installed == False: for file_name in os.listdir(msvc_find_test_dir):
with tempfile.TemporaryDirectory() as temp_dir: msvc_installed = file_name.startswith(msvc_version)
if msvc_installed == True:
devenver.lprint(f"MSVC {msvc_version} install detected (skip download) in {msvc_find_test_dir}\\{file_name}")
break
if not msvc_installed:
devenver.lprint(f"MSVC {msvc_version} install not detected (need to download) in {msvc_find_test_dir}")
# Invoke the MSVC script to download MSVC to disk if os.path.exists(win10_sdk_find_test_dir):
command = f"\"{sys.executable}\" \"{msvc_script}\" --accept-license" for file_name in os.listdir(win10_sdk_find_test_dir / "bin"):
line = "Invoking MSVC script to install" # Check if directory contains version substring, 22621, e.g. "10.0.22621.0"
if msvc_installed: win10_sdk_installed = file_name.count(win10_sdk_version) > 0
command += " --no-msvc" if win10_sdk_installed == True:
else: install_locations = f"{win10_sdk_find_test_dir}\\*\\{file_name}"
command += f" --msvc-version {msvc_version}" devenver.lprint(f"Windows 10 SDK {win10_sdk_version} install detected (skip download) in {install_locations}")
line += f" MSVC {msvc_version}" break
if not win10_sdk_installed:
devenver.lprint(f"Windows 10 SDK {win10_sdk_version} not detected (need to download) in {win10_sdk_find_test_dir}")
if win10_sdk_installed: # Install MSVC
command += " --no-sdk" if msvc_installed == False or win10_sdk_installed == False:
else: with tempfile.TemporaryDirectory() as temp_dir:
command += f" --sdk-version {win10_sdk_version}"
line += f" Windows 10 SDK {win10_sdk_version}"
devenver.lprint(line) # Invoke the MSVC script to download MSVC to disk
devenver.lprint(f"Command: {command}") command = f"\"{sys.executable}\" \"{msvc_script}\" --accept-license"
subprocess.run(command, cwd=temp_dir) line = "Invoking MSVC script to install"
if msvc_installed:
command += " --no-msvc"
else:
command += f" --msvc-version {msvc_version}"
line += f" MSVC {msvc_version}"
# Merge the download MSVC installation to our unified install dir if win10_sdk_installed:
temp_msvc_dir = pathlib.Path(temp_dir, "msvc") command += " --no-sdk"
for src_dir, dirs, files in os.walk(temp_msvc_dir): else:
install_dir = src_dir.replace(str(temp_msvc_dir), str(msvc_install_dir), 1) command += f" --sdk-version {win10_sdk_version}"
if not os.path.exists(install_dir): line += f" Windows 10 SDK {win10_sdk_version}"
os.makedirs(install_dir)
for file_ in files:
src = os.path.join(src_dir, file_)
dest = os.path.join(install_dir, file_)
if os.path.exists(dest):
if os.path.samefile(src, dest):
continue
os.remove(dest)
shutil.move(src, install_dir)
devenver.lprint(f"MSVC {msvc_version} Windows 10 SDK {win10_sdk_version} installed: {msvc_install_dir}") devenver.lprint(line)
devenver.lprint(f"Command: {command}")
subprocess.run(command, cwd=temp_dir)
# Install apps dependent on Git # Merge the download MSVC installation to our unified install dir
# ------------------------------------------------------------------------------ temp_msvc_dir = pathlib.Path(temp_dir, "msvc")
devenver.print_header("Install apps that rely on Git") for src_dir, dirs, files in os.walk(temp_msvc_dir):
git_exe = installed_apps["Git"][0]['exe_path'] install_dir = src_dir.replace(str(temp_msvc_dir), str(msvc_install_dir), 1)
if not os.path.exists(install_dir):
os.makedirs(install_dir)
for file_ in files:
src = os.path.join(src_dir, file_)
dest = os.path.join(install_dir, file_)
if os.path.exists(dest):
if os.path.samefile(src, dest):
continue
os.remove(dest)
shutil.move(src, install_dir)
# Clink devenver.lprint(f"MSVC {msvc_version} Windows 10 SDK {win10_sdk_version} installed: {msvc_install_dir}")
# ------------------------------------------------------------------------------
clink_install_dir = installed_apps["Clink"][0]['install_dir']
clink_base_dir = clink_install_dir.parent
# Gizmos # Install apps dependent on Git
clink_gizmo_git_hash = "fb2edd9" # --------------------------------------------------------------------------
clink_gizmo_install_dir = clink_base_dir / "clink-gizmos" devenver.print_header("Install apps that rely on Git")
git_clone(install_dir=clink_gizmo_install_dir, git_exe = installed_dev_apps["Git"][0]['exe_path']
git_exe=git_exe,
url="https://github.com/chrisant996/clink-gizmos",
commit_hash=clink_gizmo_git_hash)
# Completions # Clink
clink_completions_git_hash = "86b6f07" # --------------------------------------------------------------------------
clink_completions_install_dir = clink_base_dir / "clink-completions" clink_install_dir = installed_dev_apps["Clink"][0]['install_dir']
git_clone(install_dir=clink_completions_install_dir, clink_base_dir = clink_install_dir.parent
git_exe=git_exe,
url="https://github.com/vladimir-kotikov/clink-completions",
commit_hash=clink_completions_git_hash)
# Odin # Gizmos
# ------------------------------------------------------------------------------ clink_gizmo_git_hash = "fb2edd9"
odin_git_hash = "9ae1bfb6" clink_gizmo_install_dir = clink_base_dir / "clink-gizmos"
odin_install_dir = pathlib.Path(install_dir, "Odin") git_clone(install_dir=clink_gizmo_install_dir,
git_clone(install_dir=odin_install_dir, git_exe=git_exe,
git_exe=git_exe, url="https://github.com/chrisant996/clink-gizmos",
url="https://github.com/odin-lang/odin.git", commit_hash=clink_gizmo_git_hash)
commit_hash=odin_git_hash)
# TODO: We can't do this yet because the odin build requires a registry hack so # Completions
# that it knows where to find MSVC. 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,
url="https://github.com/vladimir-kotikov/clink-completions",
commit_hash=clink_completions_git_hash)
# Build Odin # Odin
# subprocess.run(f"{git_exe} checkout {odin_git_hash}", # --------------------------------------------------------------------------
# cwd=odin_install_dir) odin_git_hash = "9ae1bfb6"
odin_install_dir = install_dir / "Odin"
git_clone(install_dir=odin_install_dir,
git_exe=git_exe,
url="https://github.com/odin-lang/odin.git",
commit_hash=odin_git_hash)
# Install left-overs # TODO: We can't do this yet because the odin build requires a registry hack so
# ------------------------------------------------------------------------------ # that it knows where to find MSVC.
devenver.print_header("Install configuration files")
# Copy init.vim to NVIM directory # Build Odin
internal_dir = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) / "Internal" # subprocess.run(f"{git_exe} checkout {odin_git_hash}",
nvim_init_dir = pathlib.Path(os.path.expanduser("~")) / "AppData" / "Local" / "nvim" # cwd=odin_install_dir)
nvim_config_dest_path = nvim_init_dir / "init.vim"
nvim_config_src_path = internal_dir / "os_nvim_init.vim"
devenver.lprint(f"Installing NVIM config to {nvim_config_dest_path}") # Install left-overs
nvim_init_dir.mkdir(parents=True, exist_ok=True) # --------------------------------------------------------------------------
shutil.copy(nvim_config_src_path, nvim_config_dest_path) devenver.print_header("Install configuration files")
# Download vim.plug to NVIM init directory # Copy init.vim to NVIM directory
nvim_plug_vim_dir = nvim_init_dir / "autoload" internal_dir = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) / "Internal"
nvim_plug_vim_path = nvim_plug_vim_dir / "plug.vim" nvim_init_dir = pathlib.Path(os.path.expanduser("~")) / "AppData" / "Local" / "nvim"
nvim_plug_vim_dir.mkdir(parents=True, exist_ok=True) nvim_config_dest_path = nvim_init_dir / "init.vim"
if not os.path.exists(nvim_plug_vim_path): nvim_config_src_path = internal_dir / "os_nvim_init.vim"
devenver.lprint(f"Installing NVIM plugin manager to {nvim_plug_vim_path}")
urllib.request.urlretrieve("https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim",
nvim_plug_vim_path)
# Install clink configuration devenver.lprint(f"Installing NVIM config to {nvim_config_dest_path}")
# ------------------------------------------------------------------------------ nvim_init_dir.mkdir(parents=True, exist_ok=True)
clink_profile_dir = clink_base_dir / "profile" shutil.copy(nvim_config_src_path, nvim_config_dest_path)
clink_settings_path = clink_profile_dir / "clink_settings"
devenver.lprint(f"Installing clink_settings to: {clink_settings_path}")
clink_settings_path.parent.mkdir(exist_ok=True) # Download vim.plug to NVIM init directory
clink_settings_path.write_text(f"""# When this file is named "default_settings" and is in the binaries nvim_plug_vim_dir = nvim_init_dir / "autoload"
nvim_plug_vim_path = nvim_plug_vim_dir / "plug.vim"
nvim_plug_vim_dir.mkdir(parents=True, exist_ok=True)
if not os.path.exists(nvim_plug_vim_path):
devenver.lprint(f"Installing NVIM plugin manager to {nvim_plug_vim_path}")
urllib.request.urlretrieve("https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim",
nvim_plug_vim_path)
# Install clink configuration
# --------------------------------------------------------------------------
clink_profile_dir = clink_base_dir / "profile"
clink_settings_path = clink_profile_dir / "clink_settings"
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. # directory or profile directory, it provides enhanced default settings.
# Override built-in default settings with ones that provide a more # Override built-in default settings with ones that provide a more
@ -224,16 +260,16 @@ clink.path = {clink_completions_install_dir};{clink_gizmo
fzf.default_bindings = True fzf.default_bindings = True
""") """)
# Install wezterm configuration # Install wezterm configuration
# ------------------------------------------------------------------------------ # --------------------------------------------------------------------------
wezterm_config_dest_path = installed_apps["WezTerm"][0]["install_dir"] / "wezterm.lua" wezterm_config_dest_path = installed_dev_apps["WezTerm"][0]["install_dir"] / "wezterm.lua"
devenver.lprint(f"Installing WezTerm config to {wezterm_config_dest_path}") 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 = clink_install_dir.relative_to(install_dir) / "clink_x64.exe"
clink_exe_path_for_wezterm = str(clink_exe_path).replace("\\", "\\\\") clink_exe_path_for_wezterm = str(clink_exe_path).replace("\\", "\\\\")
clink_profile_path_for_wezterm = str(clink_profile_dir.relative_to(install_dir)).replace("\\", "\\\\") clink_profile_path_for_wezterm = str(clink_profile_dir.relative_to(install_dir)).replace("\\", "\\\\")
wezterm_config_dest_path.write_text(f"""local wezterm = require 'wezterm'; wezterm_config_dest_path.write_text(f"""local wezterm = require 'wezterm';
local default_prog local default_prog
local set_environment_variables = {{}} local set_environment_variables = {{}}
@ -241,7 +277,7 @@ local set_environment_variables = {{}}
if wezterm.target_triple == "x86_64-pc-windows-msvc" then if wezterm.target_triple == "x86_64-pc-windows-msvc" then
clink_exe = string.format("%s\\\\..\\\\..\\\\{clink_exe_path_for_wezterm}", wezterm.executable_dir) clink_exe = string.format("%s\\\\..\\\\..\\\\{clink_exe_path_for_wezterm}", wezterm.executable_dir)
devenv_bat = string.format("%s\\\\..\\\\..\\\\dev_env.bat", wezterm.executable_dir) devenv_bat = string.format("%s\\\\..\\\\..\\\\{dev_env_script_name}.bat", wezterm.executable_dir)
msvc_bat = string.format("%s\\\\..\\\\..\\\\msvc\\\\msvc-{msvc_version}.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) 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) clink_profile = string.format("%s\\\\..\\\\..\\\\{clink_profile_path_for_wezterm}", wezterm.executable_dir)
@ -266,12 +302,12 @@ return {{
}} }}
""") """)
# Wezterm super terminal # Wezterm super terminal
# ------------------------------------------------------------------------------ # --------------------------------------------------------------------------
wezterm_terminal_script_path = install_dir / "dev_terminal.bat" wezterm_terminal_script_path = install_dir / "dev_terminal.bat"
devenver.lprint(f"Installing WezTerm terminal script to {wezterm_terminal_script_path}") devenver.lprint(f"Installing WezTerm terminal script to {wezterm_terminal_script_path}")
wezterm_terminal_script_path.write_text(f"""@echo off wezterm_terminal_script_path.write_text(f"""@echo off
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
set working_dir= set working_dir=
@ -280,71 +316,87 @@ if "%~1" neq "" (
set working_dir=!working_dir:\=/! set working_dir=!working_dir:\=/!
) )
start "" /MAX "%~dp0{installed_apps["WezTerm"][0]["exe_path"].relative_to(install_dir)}" !working_dir! start "" /MAX "%~dp0{installed_dev_apps["WezTerm"][0]["exe_path"].relative_to(install_dir)}" !working_dir!
""") """)
# Run background scripts helper # Run background scripts helper
# ------------------------------------------------------------------------------ # --------------------------------------------------------------------------
background_apps_script_path = pathlib.Path(install_dir, "dev_run_background_apps.bat") background_apps_script_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 run background script (helper) to {background_apps_script_path}")
background_apps_script_path.write_text(f"""@echo off background_apps_script_path.write_text(f"""@echo off
start "" "%~dp0{installed_apps["Everything"][0]["exe_path"].relative_to(install_dir)}" start "" "%~dp0{installed_dev_apps["Everything"][0]["exe_path"].relative_to(install_dir)}"
REM Ensure that eyes-thanks creates their portable INI file in the correct directory REM Ensure that eyes-thanks creates their portable INI file in the correct directory
pushd "%~dp0{installed_apps["Eyes-Thanks"][0]["install_dir"].parent.relative_to(install_dir)}" pushd "%~dp0{installed_dev_apps["Eyes-Thanks"][0]["install_dir"].parent.relative_to(install_dir)}"
start "" "%~dp0{installed_apps["Eyes-Thanks"][0]["exe_path"].relative_to(install_dir)}" start "" "%~dp0{installed_dev_apps["Eyes-Thanks"][0]["exe_path"].relative_to(install_dir)}"
popd popd
start "" "%~dp0{installed_apps["ShareX"][0]["exe_path"].relative_to(install_dir)}" start "" "%~dp0{installed_dev_apps["ShareX"][0]["exe_path"].relative_to(install_dir)}"
start "" "%~dp0{installed_apps["SpeedCrunch"][0]["exe_path"].relative_to(install_dir)}" start "" "%~dp0{installed_dev_apps["SpeedCrunch"][0]["exe_path"].relative_to(install_dir)}"
""") """)
# Create Odin work-around scripts # Create Odin work-around scripts
# ------------------------------------------------------------------------------ # --------------------------------------------------------------------------
# Odin uses J. Blow's Microsoft craziness SDK locator which relies on the # Odin uses J. Blow's Microsoft craziness SDK locator which relies on the
# registry. Here we inject the registry entry that the SDK locator checks for # registry. Here we inject the registry entry that the SDK locator checks for
# finding our portable MSVC installation. # finding our portable MSVC installation.
win10_sdk_find_test_dir_reg_path = str(win10_sdk_find_test_dir).replace("\\", "\\\\") win10_sdk_find_test_dir_reg_path = str(win10_sdk_find_test_dir).replace("\\", "\\\\")
odin_msvc_install_script_path = install_dir / "odin_msvc_install_workaround.reg" odin_msvc_install_script_path = install_dir / "odin_msvc_install_workaround.reg"
odin_msvc_uninstall_script_path = install_dir / "odin_msvc_uninstall_workaround.reg" odin_msvc_uninstall_script_path = install_dir / "odin_msvc_uninstall_workaround.reg"
devenver.lprint(f"Installing Odin MSVC workaround scripts", level=0) 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_install_script_path}", level=1)
devenver.lprint(f" - {odin_msvc_uninstall_script_path}", level=1) devenver.lprint(f" - {odin_msvc_uninstall_script_path}", level=1)
odin_msvc_install_script_path.write_text(f"""Windows Registry Editor Version 5.00 odin_msvc_install_script_path.write_text(f"""Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots] [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots]
"KitsRoot10"="{win10_sdk_find_test_dir_reg_path}" "KitsRoot10"="{win10_sdk_find_test_dir_reg_path}"
""") """)
odin_msvc_uninstall_script_path.write_text(f"""Windows Registry Editor Version 5.00 odin_msvc_uninstall_script_path.write_text(f"""Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots] [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots]
"KitsRoot10"=- "KitsRoot10"=-
""") """)
# Python # Python
# ------------------------------------------------------------------------------ # --------------------------------------------------------------------------
# TODO: If I'm using the terminal that this script generates it will lock the # 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. # executable and Python cannot open the file for verifying the SHA256.
python_exe_path = pathlib.Path(installed_apps["Python"][0]['exe_path']) python_exe_path = pathlib.Path(installed_dev_apps["Python"][0]['exe_path'])
# PyNvim # PyNvim
devenver.lprint(f"Installing PyNVIM") devenver.lprint(f"Installing PyNVIM")
subprocess.run(f"{python_exe_path} -m pip install pynvim") subprocess.run(f"{python_exe_path} -m pip install pynvim")
# Add update script # Add update script
python_rel_exe_path = pathlib.Path(python_exe_path).relative_to(install_dir) 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) 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") win_setup_script_path = pathlib.Path(devenver.script_dir, "win_install.py")
(install_dir / "dev_env_update.bat").write_text(f"""@echo off (install_dir / "dev_env_update.bat").write_text(f"""@echo off
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
set PYTHONHOME=%~dp0{python_install_dir} set PYTHONHOME=%~dp0{python_install_dir}
%~dp0{python_rel_exe_path} {win_setup_script_path} %~dp0{python_rel_exe_path} {win_setup_script_path} --with-dev-apps
pause pause
""") """)
(install_dir / "user_env_update.bat").write_text(f"""@echo off
setlocal EnableDelayedExpansion
set PYTHONHOME=%~dp0{python_install_dir}
%~dp0{python_rel_exe_path} {win_setup_script_path} --with-user-apps
pause
""")
# Install user apps
# ------------------------------------------------------------------------------
if args.with_user_apps:
app_list = win_app_manifest_user.get_manifest()
installed_user_apps = devenver.run(user_app_list=app_list,
download_dir=download_dir,
install_dir=install_dir,
devenv_script_name="user_env")