From 570a33a0e1f3c546b608b4530faecc0404eb42e5 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Wed, 9 Aug 2023 20:14:59 -0500 Subject: [PATCH] Dodge AppData problems on Windows (#32) --- scripts/dev.py | 16 ++++++++++++++-- scripts/mkdir.bat | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 scripts/mkdir.bat diff --git a/scripts/dev.py b/scripts/dev.py index 4024fdd..12b875e 100644 --- a/scripts/dev.py +++ b/scripts/dev.py @@ -1,4 +1,3 @@ -import argparse from datetime import datetime import glob import os @@ -506,12 +505,25 @@ def install(args): bin_dir = os.path.join(dest, "bin") yeet(bin_dir) + + # The MS Store version of Python does some really stupid stuff with AppData: + # https://git.handmade.network/hmn/orca/issues/32 + # + # Any new files and folders created in AppData actually get created in a special + # folder specific to the Python version. However, if the files or folders already + # exist, the redirect does not happen. So, if we first use the shell to create the + # paths we need, the following scripts work regardless of Python install. + # + # Also apparently you can't just do mkdir in a subprocess call here, hence the + # trivial batch script. + if platform.system() == "Windows": + subprocess.run(["scripts\\mkdir.bat", bin_dir], check=True) + shutil.copytree("scripts", os.path.join(bin_dir, "sys_scripts")) shutil.copy("orca", bin_dir) if platform.system() == "Windows": shutil.copy("orca.bat", bin_dir) - # TODO: Customize these instructions for Windows print() if platform.system() == "Windows": print("The Orca tools have been installed. Make sure the Orca tools are on your PATH by") diff --git a/scripts/mkdir.bat b/scripts/mkdir.bat new file mode 100644 index 0000000..17cb6f0 --- /dev/null +++ b/scripts/mkdir.bat @@ -0,0 +1,3 @@ +@echo off +mkdir %1 +exit /b %errorlevel%