From 41d66dd164bed99f8c9746dfa10696599195fc16 Mon Sep 17 00:00:00 2001 From: tazlin Date: Sat, 6 Jan 2024 18:54:00 -0500 Subject: [PATCH] fix: download micromamba on windows --- .gitignore | 7 ++++++- download_micromamba.ps1 | 11 +++++++++++ runtime.cmd | 2 +- update-runtime.cmd | 9 ++++++--- 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 download_micromamba.ps1 diff --git a/.gitignore b/.gitignore index 64901284..86c193cb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,11 @@ testing .vscode/ +micromamba.exe +micromamba.tar.bz2 +info/ +library/ + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -157,4 +162,4 @@ cython_debug/ #.idea/ bin/* -conda/* \ No newline at end of file +conda/* diff --git a/download_micromamba.ps1 b/download_micromamba.ps1 new file mode 100644 index 00000000..c0bc5c16 --- /dev/null +++ b/download_micromamba.ps1 @@ -0,0 +1,11 @@ +# Download micromamba if it doesn't exist, suppressing any errors +if (!(Test-Path "micromamba.exe")) { + Write-Output "* Downloading micromamba" + Invoke-Webrequest -URI https://micro.mamba.pm/api/micromamba/win-64/latest -OutFile micromamba.tar.bz2 + tar xf micromamba.tar.bz2 + + Move-Item -Force Library\bin\micromamba.exe micromamba.exe + + Remove-Item micromamba.tar.bz2 + Remove-Item -r ./Library/ +} diff --git a/runtime.cmd b/runtime.cmd index 5bd89be8..b68a0405 100644 --- a/runtime.cmd +++ b/runtime.cmd @@ -16,7 +16,7 @@ IF EXIST CONDA GOTO APP call update-runtime :APP -umamba.exe shell hook -s cmd.exe -p "%MAMBA_ROOT_PREFIX%" -v +micromamba.exe shell hook -s cmd.exe -p "%MAMBA_ROOT_PREFIX%" -v call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" call "%MAMBA_ROOT_PREFIX%\condabin\micromamba.bat" activate windows %* diff --git a/update-runtime.cmd b/update-runtime.cmd index 5777b7f7..1effd139 100644 --- a/update-runtime.cmd +++ b/update-runtime.cmd @@ -1,4 +1,6 @@ @echo off +powershell.exe -File .\download_micromamba.ps1 + cd /d "%~dp0" :Isolation @@ -9,6 +11,7 @@ SET MAMBA_ROOT_PREFIX=%~dp0conda echo %MAMBA_ROOT_PREFIX% + setlocal EnableDelayedExpansion for %%a in (%*) do ( if /I "%%a"=="--hordelib" ( @@ -34,13 +37,13 @@ if defined scribe ( Reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v "LongPathsEnabled" /t REG_DWORD /d "1" /f 2>nul :We do this twice the first time to workaround a conda bug where pip is not installed correctly the first time - Henk IF EXIST CONDA GOTO WORKAROUND_END -umamba create --no-shortcuts -r conda -n windows -f %CONDA_ENVIRONMENT_FILE% -y +micromamba create --no-shortcuts -r conda -n windows -f %CONDA_ENVIRONMENT_FILE% -y :WORKAROUND_END -umamba create --no-shortcuts -r conda -n windows -f %CONDA_ENVIRONMENT_FILE% -y +micromamba create --no-shortcuts -r conda -n windows -f %CONDA_ENVIRONMENT_FILE% -y REM Check if hordelib argument is defined -umamba.exe shell hook -s cmd.exe -p %MAMBA_ROOT_PREFIX% -v +micromamba.exe shell hook -s cmd.exe -p %MAMBA_ROOT_PREFIX% -v call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" call "%MAMBA_ROOT_PREFIX%\condabin\micromamba.bat" activate windows