Skip to content

Commit

Permalink
Merge pull request #81 from Hind-M/ps_install
Browse files Browse the repository at this point in the history
Handle all micromamba versions in `install.ps1` and add test
  • Loading branch information
Hind-M authored Feb 26, 2025
2 parents e43e4f6 + 58812f1 commit 11510e5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
31 changes: 24 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,15 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Micromamba (${{ matrix.os }}, ${{ matrix.shell }})
- name: Install micromamba (${{ matrix.os }}, ${{ matrix.shell }})
# Need to force the shell to get the default *calling* shell right
run: |
${{ matrix.shell }} -c 'cat ./install.sh | ${SHELL}'
- name: Test Micromamba
- name: Test micromamba
# use either -l or -i to source .bash_profile or .bashrc/.zshrc
run: |
${{ matrix.shell }} ${{ matrix.shell-source-param }} -ec micromamba
- name: Test Micromamba is found
# use either -l or -i to source .bash_profile or .bashrc/.zshrc
run: |
${{ matrix.shell }} ${{ matrix.shell-source-param }} -ec micromamba --help
- name: Test Micromamba is found
- name: Test micromamba is found
# use either -l or -i to source .bash_profile or .bashrc/.zshrc
run: |
${{ matrix.shell }} ${{ matrix.shell-source-param }} -ec micromamba --help
Expand All @@ -50,3 +46,24 @@ jobs:
# use either -l or -i to source .bash_profile or .bashrc/.zshrc
run: |
${{ matrix.shell }} ${{ matrix.shell-source-param }} -ec micromamba activate -n test
test_install_ps1:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install micromamba using PowerShell
shell: pwsh
run: |
.\install.ps1
# Make updated `PATH` persistent in GHA
echo "PATH=$Env:LocalAppData\micromamba" >> $env:GITHUB_ENV
- name: Test micromamba after install.ps1
shell: pwsh
run: |
micromamba --help
- name: Test micromamba create
shell: pwsh
run: |
micromamba create -c conda-forge -n test python
15 changes: 12 additions & 3 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ if ($PATH -notlike "*$Env:LocalAppData\micromamba*") {
Write-Output "$MAMBA_INSTALL_PATH is already in PATH`n"
}

# Get the version of micromamba
$version = & $MAMBA_INSTALL_PATH --version
# Determine the appropriate flag based on the version
if ($version -like "1.*" -or $version -like "0.*") {
$prefixArg = "-p"
} else {
$prefixArg = "-r"
}

# check if this is an interactive session
if ($null -eq $Host.UI.RawUI) {
Write-Output "`nNot an interactive session, initializing micromamba to $Env:UserProfile\micromamba`n"
& $MAMBA_INSTALL_PATH shell init -s powershell -r $Env:UserProfile\micromamba
& $MAMBA_INSTALL_PATH shell init -s powershell $prefixArg $Env:UserProfile\micromamba
}

$choice = Read-Host "Do you want to initialize micromamba for the shell activate command? (Y/n)"
Expand All @@ -40,7 +49,7 @@ if ($choice -eq "y" -or $choice -eq "Y" -or $choice -eq "") {
Write-Output "Initializing micromamba in $prefix"
$MAMBA_INSTALL_PATH = Join-Path -Path $Env:LocalAppData -ChildPath micromamba\micromamba.exe
Write-Output $MAMBA_INSTALL_PATH
& $MAMBA_INSTALL_PATH shell init -s powershell -r $prefix
& $MAMBA_INSTALL_PATH shell init -s powershell $prefixArg $prefix
} else {
Write-Output "`nYou can always initialize powershell or cmd.exe with micromamba by running `nmicromamba shell init -s powershell -r $Env:UserProfile\micromamba`n"
Write-Output "`nYou can always initialize powershell or cmd.exe with micromamba by running `nmicromamba shell init -s powershell $prefixArg $Env:UserProfile\micromamba`n"
}

0 comments on commit 11510e5

Please sign in to comment.