Begin adding linux installation

This commit is contained in:
doyle 2023-02-08 00:35:07 +11:00
parent 12c57fa222
commit acc5d57340
4 changed files with 1437 additions and 946 deletions

View File

@ -24,74 +24,6 @@ from enum import Enum
# Internal
# ------------------------------------------------------------------------------
DOWNLOAD_CHUNK_SIZE = 1 * 1024 * 1024 # 1 megabyte
IS_WINDOWS = os.name == "nt"
# ------------------------------------------------------------------------------
# This app list must always be installed, they provide the tools to install all
# other archives. Upon installation, we will collect the installation executable
# path and store them in global variables for the rest of the progam to use to
# unzip the files.
internal_app_list = []
internal_app_list.append({
'label': '7zip',
'manifests': [],
})
version = "920"
internal_app_list[-1]['manifests'].append({ # Download the bootstrap 7zip, this can be unzipped using shutils
'download_checksum': '2a3afe19c180f8373fa02ff00254d5394fec0349f5804e0ad2f6067854ff28ac',
'download_url': f'https://www.7-zip.org/a/7za{version}.zip',
'version': version,
'executables': [
{
'path': '7za.exe',
'symlink': [],
'add_to_devenv_path': False,
'checksum': 'c136b1467d669a725478a6110ebaaab3cb88a3d389dfa688e06173c066b76fcf'
}
],
'add_to_devenv_script': [],
})
version = "2201"
internal_app_list[-1]['manifests'].append({ # Download proper 7zip, extract this exe with the bootstrap 7zip
'download_checksum': 'b055fee85472921575071464a97a79540e489c1c3a14b9bdfbdbab60e17f36e4',
'download_url': f'https://www.7-zip.org/a/7z{version}-x64.exe',
'version': version,
'executables': [
{
'path': '7z.exe',
'symlink': [],
'add_to_devenv_path': True,
'checksum': '254cf6411d38903b2440819f7e0a847f0cfee7f8096cfad9e90fea62f42b0c23'
}
],
'add_to_devenv_script': [],
})
# ------------------------------------------------------------------------------
version = "1.5.2"
internal_app_list.append({
"label": "zstd",
"manifests": [
{
"download_checksum": "68897cd037ee5e44c6d36b4dbbd04f1cc4202f9037415a3251951b953a257a09",
"download_url": f"https://github.com/facebook/zstd/releases/download/v{version}/zstd-v{version}-win64.zip",
"version": version,
"executables": [
{
"path": "zstd.exe",
"symlink": [],
"add_to_devenv_path": True,
"checksum": "f14e78c0651851a670f508561d2c5d647da0ba08e6b73231f2e7539812bae311",
},
],
"add_to_devenv_script": [],
},
],
})
# ------------------------------------------------------------------------------
@ -101,7 +33,6 @@ zstd_exe = ""
zip7_exe = ""
zip7_bootstrap_exe = ""
# Functions
# ------------------------------------------------------------------------------
def print_header(title):
@ -216,7 +147,8 @@ def download_and_install_archive(download_url,
label,
unzip_method,
download_dir,
install_dir):
install_dir,
is_windows):
exe_install_dir = get_exe_install_dir(install_dir=install_dir,
label=label,
@ -321,7 +253,7 @@ def download_and_install_archive(download_url,
# We call this an intermediate zip file, we will extract that file
# with 7zip. After we're done, we will delete that _intermediate_
# file to cleanup our install directory.
if archive_path.suffix == '.zst' or archive_path.suffix == '.xz':
if archive_path.suffix == '.zst' or archive_path.suffix == '.xz' or archive_path.suffix == '.gz':
archive_without_suffix = pathlib.Path(str(archive_path)[:-len(archive_path.suffix)]).name
next_archive_path = pathlib.Path(exe_install_dir, archive_without_suffix)
@ -445,7 +377,7 @@ def download_and_install_archive(download_url,
if os.path.exists(symlink_dest):
# Windows uses hardlinks because symlinks require you to enable "developer" mode
# Everyone else uses symlinks
if (IS_WINDOWS and not os.path.isfile(symlink_dest)) or (not IS_WINDOWS and not os.path.islink(symlink_dest)):
if (is_windows and not os.path.isfile(symlink_dest)) or (not is_windows and not os.path.islink(symlink_dest)):
lprint( "- Cannot create symlink! The destination file to create the symlink at.", level=1)
lprint( " already exists and is *not* a link. We cannot remove this safely as we", level=1)
lprint( " don't know what it is, exiting.", level=1)
@ -458,7 +390,7 @@ def download_and_install_archive(download_url,
os.unlink(symlink_dest)
if not skip_link:
if IS_WINDOWS == True:
if is_windows == True:
os.link(src=symlink_src, dst=symlink_dest)
else:
os.symlink(src=symlink_src, dst=symlink_dest)
@ -471,7 +403,7 @@ def download_and_install_archive(download_url,
global devenv_script_buffer
for path in paths_to_add_to_devenv_script:
if IS_WINDOWS:
if is_windows:
devenv_script_buffer += f"set PATH=%~dp0{path};%PATH%\n"
else:
devenv_script_buffer += f"PATH=$( cd -- \"$( dirname -- \"${BASH_SOURCE[0]}\" ) &> /dev/null && pwd ){path}\";%PATH%\n"
@ -547,8 +479,10 @@ def validate_app_list(app_list):
return result
internal_app_list = []
devenv_script_buffer = ""
def install_app_list(app_list, download_dir, install_dir):
def install_app_list(app_list, download_dir, install_dir, is_windows):
title = "Internal Apps" if app_list is internal_app_list else "User Apps"
print_header(title)
result = {}
@ -573,22 +507,24 @@ def install_app_list(app_list, download_dir, install_dir):
# Bootstrapping code, when installing the internal app list, we will
# assign the variables to point to our unarchiving tools.
# ------------------------------------------------------------------
if app_list is internal_app_list:
global zip7_exe
global zip7_bootstrap_exe
global zstd_exe
exe_path = get_exe_install_path(install_dir, label, version, manifest['executables'][0]['path'])
if label == '7zip':
if version == '920':
unzip_method = UnzipMethod.SHUTILS
zip7_bootstrap_exe = exe_path
else:
unzip_method = UnzipMethod.ZIP7_BOOTSTRAP
zip7_exe = exe_path
if label == 'zstd':
zstd_exe = exe_path
if is_windows:
if app_list is internal_app_list:
global zip7_exe
global zip7_bootstrap_exe
global zstd_exe
exe_path = get_exe_install_path(install_dir, label, version, manifest['executables'][0]['path'])
if label == '7zip':
if version == '920':
unzip_method = UnzipMethod.SHUTILS
zip7_bootstrap_exe = exe_path
else:
unzip_method = UnzipMethod.ZIP7_BOOTSTRAP
zip7_exe = exe_path
if label == 'zstd':
zstd_exe = exe_path
else:
unzip_method = UnzipMethod.SHUTILS
# Download and install
# ------------------------------------------------------------------
@ -600,7 +536,8 @@ def install_app_list(app_list, download_dir, install_dir):
label=label,
unzip_method=unzip_method,
download_dir=download_dir,
install_dir=install_dir)
install_dir=install_dir,
is_windows=is_windows)
# Post-installation
# ------------------------------------------------------------------
@ -645,6 +582,7 @@ base_install_dir = default_base_install_dir
def run(user_app_list,
devenv_script_name,
is_windows,
download_dir=base_downloads_dir,
install_dir=base_install_dir):
""" Download and install the given user app list at the specified
@ -668,6 +606,75 @@ def run(user_app_list,
base_downloads_dir = download_dir
base_install_dir = install_dir
# --------------------------------------------------------------------------
# This app list must always be installed, they provide the tools to install all
# other archives. Upon installation, we will collect the installation executable
# path and store them in global variables for the rest of the progam to use to
# unzip the files.
global internal_app_list
internal_app_list = []
if is_windows:
internal_app_list.append({
'label': '7zip',
'manifests': [],
})
version = "920"
internal_app_list[-1]['manifests'].append({ # Download the bootstrap 7zip, this can be unzipped using shutils
'download_checksum': '2a3afe19c180f8373fa02ff00254d5394fec0349f5804e0ad2f6067854ff28ac',
'download_url': f'https://www.7-zip.org/a/7za{version}.zip',
'version': version,
'executables': [
{
'path': '7za.exe',
'symlink': [],
'add_to_devenv_path': False,
'checksum': 'c136b1467d669a725478a6110ebaaab3cb88a3d389dfa688e06173c066b76fcf'
}
],
'add_to_devenv_script': [],
})
version = "2201"
internal_app_list[-1]['manifests'].append({ # Download proper 7zip, extract this exe with the bootstrap 7zip
'download_checksum': 'b055fee85472921575071464a97a79540e489c1c3a14b9bdfbdbab60e17f36e4',
'download_url': f'https://www.7-zip.org/a/7z{version}-x64.exe',
'version': version,
'executables': [
{
'path': '7z.exe',
'symlink': [],
'add_to_devenv_path': True,
'checksum': '254cf6411d38903b2440819f7e0a847f0cfee7f8096cfad9e90fea62f42b0c23'
}
],
'add_to_devenv_script': [],
})
# ------------------------------------------------------------------------------
version = "1.5.2"
internal_app_list.append({
"label": "zstd",
"manifests": [
{
"download_checksum": "68897cd037ee5e44c6d36b4dbbd04f1cc4202f9037415a3251951b953a257a09",
"download_url": f"https://github.com/facebook/zstd/releases/download/v{version}/zstd-v{version}-win64.zip",
"version": version,
"executables": [
{
"path": "zstd.exe",
"symlink": [],
"add_to_devenv_path": True,
"checksum": "f14e78c0651851a670f508561d2c5d647da0ba08e6b73231f2e7539812bae311",
},
],
"add_to_devenv_script": [],
},
],
})
# Run
# --------------------------------------------------------------------------
# Create the starting directories and install the internal app list (e.g.
@ -705,16 +712,18 @@ def run(user_app_list,
# Install apps
internal_apps = install_app_list(app_list=internal_app_list,
download_dir=download_dir,
install_dir=install_dir)
install_dir=install_dir,
is_windows=is_windows)
user_apps = install_app_list(app_list=user_app_list,
download_dir=download_dir,
install_dir=install_dir)
install_dir=install_dir,
is_windows=is_windows)
# Write the devenv script with environment variables
devenv_script_buffer += "set PATH=%~dp0Symlinks;%PATH%\n"
devenv_script_name = f"{devenv_script_name}.bat" if IS_WINDOWS else f"{devenv_script_name}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)
lprint(f"Writing script to augment the environment with installed applications: {devenv_script_path}")
with open(devenv_script_path, 'w') as file:

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +1,53 @@
def get_manifest():
def get_manifest(is_windows):
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": [],
}
],
})
if is_windows:
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": [],
}
],
})
if is_windows:
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": [],
}
],
})
# --------------------------------------------------------------------------

View File

@ -33,18 +33,15 @@ def git_clone(install_dir, git_exe, url, commit_hash):
# Arguments
# ------------------------------------------------------------------------------
default_download_dir = devenver.script_dir / 'Downloads'
default_install_dir = devenver.script_dir / 'Win'
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--download-dir',
help=f'Set the directory where downloaded files are cached (default: {default_download_dir})',
default=default_download_dir,
help=f'Set the directory where downloaded files are cached (default: ./(Win|Linux))',
default="",
type=pathlib.Path)
arg_parser.add_argument('--install-dir',
help=f'Set the directory where downloaded files are installed (default: {default_install_dir})',
default=default_install_dir,
help=f'Set the directory where downloaded files are installed (default: ./Downloads)',
default="",
type=pathlib.Path)
arg_parser.add_argument('--with-dev-apps',
@ -57,9 +54,23 @@ arg_parser.add_argument('--with-user-apps',
const=True,
action="store_const")
arg_parser.add_argument('operating_system',
choices=['win', 'linux'],
help=f'Download and install apps for the specified operating system')
args = arg_parser.parse_args()
download_dir = args.download_dir
install_dir = args.install_dir
is_windows = args.operating_system == 'win'
if download_dir == pathlib.Path(""):
download_dir = devenver.script_dir / 'Downloads'
if install_dir == pathlib.Path(""):
if is_windows:
install_dir = devenver.script_dir / 'Win'
else:
install_dir = devenver.script_dir / 'Linux'
# Install development apps
# ------------------------------------------------------------------------------
@ -67,162 +78,141 @@ if args.with_dev_apps:
# Run DEVenver, installing the portable apps
# --------------------------------------------------------------------------
dev_env_script_name = "dev_env"
app_list = win_app_manifest_dev.get_manifest()
app_list = win_app_manifest_dev.get_manifest(is_windows=is_windows)
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)
devenv_script_name=dev_env_script_name,
is_windows=is_windows)
# Install MSVC
# --------------------------------------------------------------------------
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"
if is_windows:
# Install MSVC
# --------------------------------------------------------------------------
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_install_dir = install_dir / "msvc"
msvc_install_dir = install_dir / "msvc"
# Basic heuristic to see if we"ve already installed the MSVC/SDK version
msvc_installed = False
win10_sdk_installed = False
# Basic heuristic to see if we"ve already installed the MSVC/SDK version
msvc_installed = False
win10_sdk_installed = False
msvc_find_test_dir = msvc_install_dir / "VC/Tools/MSVC"
win10_sdk_find_test_dir = msvc_install_dir / "Windows Kits/10"
msvc_find_test_dir = msvc_install_dir / "VC/Tools/MSVC"
win10_sdk_find_test_dir = msvc_install_dir / "Windows Kits/10"
if os.path.exists(msvc_find_test_dir):
for file_name in os.listdir(msvc_find_test_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}")
if os.path.exists(msvc_find_test_dir):
for file_name in os.listdir(msvc_find_test_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}")
if os.path.exists(win10_sdk_find_test_dir):
for file_name in os.listdir(win10_sdk_find_test_dir / "bin"):
# 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}")
if os.path.exists(win10_sdk_find_test_dir):
for file_name in os.listdir(win10_sdk_find_test_dir / "bin"):
# 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 msvc_installed == False or win10_sdk_installed == False:
with tempfile.TemporaryDirectory() as temp_dir:
# Install MSVC
if msvc_installed == False or win10_sdk_installed == False:
with tempfile.TemporaryDirectory() as temp_dir:
# Invoke the MSVC script to download MSVC to disk
command = f"\"{sys.executable}\" \"{msvc_script}\" --accept-license"
line = "Invoking MSVC script to install"
if msvc_installed:
command += " --no-msvc"
else:
command += f" --msvc-version {msvc_version}"
line += f" MSVC {msvc_version}"
# Invoke the MSVC script to download MSVC to disk
command = f"\"{sys.executable}\" \"{msvc_script}\" --accept-license"
line = "Invoking MSVC script to install"
if msvc_installed:
command += " --no-msvc"
else:
command += f" --msvc-version {msvc_version}"
line += f" MSVC {msvc_version}"
if win10_sdk_installed:
command += " --no-sdk"
else:
command += f" --sdk-version {win10_sdk_version}"
line += f" Windows 10 SDK {win10_sdk_version}"
if win10_sdk_installed:
command += " --no-sdk"
else:
command += f" --sdk-version {win10_sdk_version}"
line += f" Windows 10 SDK {win10_sdk_version}"
devenver.lprint(line)
devenver.lprint(f"Command: {command}")
subprocess.run(command, cwd=temp_dir)
devenver.lprint(line)
devenver.lprint(f"Command: {command}")
subprocess.run(command, cwd=temp_dir)
# Merge the download MSVC installation to our unified install dir
temp_msvc_dir = pathlib.Path(temp_dir, "msvc")
for src_dir, dirs, files in os.walk(temp_msvc_dir):
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)
# Merge the download MSVC installation to our unified install dir
temp_msvc_dir = pathlib.Path(temp_dir, "msvc")
for src_dir, dirs, files in os.walk(temp_msvc_dir):
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)
devenver.lprint(f"MSVC {msvc_version} Windows 10 SDK {win10_sdk_version} installed: {msvc_install_dir}")
devenver.lprint(f"MSVC {msvc_version} Windows 10 SDK {win10_sdk_version} installed: {msvc_install_dir}")
# Install apps dependent on Git
# --------------------------------------------------------------------------
devenver.print_header("Install apps that rely on Git")
git_exe = installed_dev_apps["Git"][0]['exe_path']
# Install apps dependent on Git
# --------------------------------------------------------------------------
devenver.print_header("Install apps that rely on Git")
git_exe = installed_dev_apps["Git"][0]['exe_path']
# Clink
# --------------------------------------------------------------------------
clink_install_dir = installed_dev_apps["Clink"][0]['install_dir']
clink_base_dir = clink_install_dir.parent
# Clink
# --------------------------------------------------------------------------
clink_install_dir = installed_dev_apps["Clink"][0]['install_dir']
clink_base_dir = clink_install_dir.parent
# Gizmos
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,
url="https://github.com/chrisant996/clink-gizmos",
commit_hash=clink_gizmo_git_hash)
# Gizmos
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,
url="https://github.com/chrisant996/clink-gizmos",
commit_hash=clink_gizmo_git_hash)
# Completions
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)
# Completions
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)
# Odin
# --------------------------------------------------------------------------
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)
# Odin
# --------------------------------------------------------------------------
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)
# TODO: We can't do this yet because the odin build requires a registry hack so
# that it knows where to find MSVC.
# TODO: We can't do this yet because the odin build requires a registry hack so
# that it knows where to find MSVC.
# Build Odin
# subprocess.run(f"{git_exe} checkout {odin_git_hash}",
# cwd=odin_install_dir)
# Build Odin
# subprocess.run(f"{git_exe} checkout {odin_git_hash}",
# cwd=odin_install_dir)
# Install left-overs
# --------------------------------------------------------------------------
devenver.print_header("Install configuration files")
# 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}")
# 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"
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}")
nvim_init_dir.mkdir(parents=True, exist_ok=True)
shutil.copy(nvim_config_src_path, nvim_config_dest_path)
# Download vim.plug to NVIM init directory
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
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
@ -260,16 +250,16 @@ clink.path = {clink_completions_install_dir};{clink_gizmo
fzf.default_bindings = True
""")
# Install wezterm configuration
# --------------------------------------------------------------------------
wezterm_config_dest_path = installed_dev_apps["WezTerm"][0]["install_dir"] / "wezterm.lua"
devenver.lprint(f"Installing WezTerm config to {wezterm_config_dest_path}")
# Install wezterm configuration
# --------------------------------------------------------------------------
wezterm_config_dest_path = installed_dev_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_profile_path_for_wezterm = str(clink_profile_dir.relative_to(install_dir)).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_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 set_environment_variables = {{}}
@ -302,12 +292,12 @@ return {{
}}
""")
# Wezterm super terminal
# --------------------------------------------------------------------------
wezterm_terminal_script_path = install_dir / "dev_terminal.bat"
devenver.lprint(f"Installing WezTerm terminal script to {wezterm_terminal_script_path}")
# Wezterm super terminal
# --------------------------------------------------------------------------
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
wezterm_terminal_script_path.write_text(f"""@echo off
setlocal EnableDelayedExpansion
set working_dir=
@ -319,12 +309,12 @@ if "%~1" neq "" (
start "" /MAX "%~dp0{installed_dev_apps["WezTerm"][0]["exe_path"].relative_to(install_dir)}" !working_dir!
""")
# Run background scripts helper
# --------------------------------------------------------------------------
background_apps_script_path = install_dir / "dev_run_background_apps.bat"
devenver.lprint(f"Installing run background script (helper) to {background_apps_script_path}")
# Run background scripts helper
# --------------------------------------------------------------------------
background_apps_script_path = install_dir / "dev_run_background_apps.bat"
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_dev_apps["Everything"][0]["exe_path"].relative_to(install_dir)}"
REM Ensure that eyes-thanks creates their portable INI file in the correct directory
@ -336,49 +326,49 @@ start "" "%~dp0{installed_dev_apps["ShareX"][0]["exe_path"].relative_to(install_
start "" "%~dp0{installed_dev_apps["SpeedCrunch"][0]["exe_path"].relative_to(install_dir)}"
""")
# Create Odin work-around scripts
# --------------------------------------------------------------------------
# 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
# finding our portable MSVC installation.
win10_sdk_find_test_dir_reg_path = str(win10_sdk_find_test_dir).replace("\\", "\\\\")
# Create Odin work-around scripts
# --------------------------------------------------------------------------
# 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
# finding our portable MSVC installation.
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_uninstall_script_path = install_dir / "odin_msvc_uninstall_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"
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)
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)
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]
"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]
"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
# --------------------------------------------------------------------------
# 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_path = pathlib.Path(installed_dev_apps["Python"][0]['exe_path'])
python_exe_path = pathlib.Path(installed_dev_apps["Python"][0]['exe_path'])
# PyNvim
devenver.lprint(f"Installing PyNVIM")
subprocess.run(f"{python_exe_path} -m pip install pynvim")
# 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")
# 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")
(install_dir / "dev_env_update.bat").write_text(f"""@echo off
(install_dir / "dev_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-dev-apps
@ -392,11 +382,42 @@ set PYTHONHOME=%~dp0{python_install_dir}
pause
""")
# Install left-overs
# --------------------------------------------------------------------------
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 = ""
if is_windows:
nvim_init_dir = pathlib.Path(os.path.expanduser("~")) / "AppData" / "Local" / "nvim"
else:
nvim_init_dir = pathlib.Path(os.path.expanduser("~")) / ".config" / "nvim"
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}")
nvim_init_dir.mkdir(parents=True, exist_ok=True)
shutil.copy(nvim_config_src_path, nvim_config_dest_path)
# Download vim.plug to NVIM init directory
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 user apps
# ------------------------------------------------------------------------------
if args.with_user_apps:
app_list = win_app_manifest_user.get_manifest()
app_list = win_app_manifest_user.get_manifest(is_windows=is_windows)
installed_user_apps = devenver.run(user_app_list=app_list,
download_dir=download_dir,
install_dir=install_dir,
devenv_script_name="user_env")
devenv_script_name="user_env",
is_windows=True)