Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address mamba v2 incompatibilities #368

Merged
merged 38 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1a66b28
look for mamba in more places and guarantee existence
jaimergp Oct 1, 2024
0c12b94
parameterize mamba versions
jaimergp Oct 1, 2024
625e750
debug locations
jaimergp Oct 1, 2024
4dca16b
pass options
jaimergp Oct 1, 2024
fdee7b3
Pass MAMBA_ROOT_PREFIX for mamba v2
jaimergp Oct 1, 2024
f1768ca
mamba v2 doesn't create env with update
jaimergp Oct 1, 2024
c773066
copy to condabin?
jaimergp Oct 1, 2024
16f2ab5
use basename
jaimergp Oct 1, 2024
7e45c83
fix extension
jaimergp Oct 1, 2024
04ec2dd
fix path under Windows
jaimergp Oct 1, 2024
6acf8b7
extra verbose
jaimergp Oct 1, 2024
bc0ff91
is it pip?
jaimergp Oct 1, 2024
ebb2a6c
it wasn't pip
jaimergp Oct 1, 2024
d516266
do not compile pyc on win
jaimergp Oct 3, 2024
c11abc7
temporarily remove pip section
jaimergp Oct 3, 2024
9b4b371
bash wrapper goes in condabin
jaimergp Oct 3, 2024
d28c6b7
compile
jaimergp Oct 3, 2024
8c64fc2
debug a bit
jaimergp Oct 3, 2024
a490a79
fix workflow
jaimergp Oct 3, 2024
e63b3bf
amend paths
jaimergp Oct 3, 2024
c0ef081
mark as executable?
jaimergp Oct 3, 2024
f5b33fe
remove which?
jaimergp Oct 3, 2024
e824ba9
debug and disablew a few workflows
jaimergp Oct 3, 2024
a48b551
activate before forward?
jaimergp Oct 3, 2024
097861d
slashes?
jaimergp Oct 3, 2024
74a6ae2
refactor forwarders
jaimergp Oct 3, 2024
831d3c6
bash forwarder only on 1.x
jaimergp Oct 3, 2024
8f2ffaf
fwd via cmd?
jaimergp Oct 3, 2024
7e330df
which
jaimergp Oct 3, 2024
2ef314e
move to the bottom
jaimergp Oct 3, 2024
933bf30
this one too
jaimergp Oct 3, 2024
b408436
fix executable names
jaimergp Oct 3, 2024
7d787c9
revert
jaimergp Oct 3, 2024
904836f
clean up a bit
jaimergp Oct 3, 2024
24ed97e
mark as generated
jaimergp Oct 3, 2024
f2345f7
restore bash forwarder
jaimergp Oct 3, 2024
f9e9bea
hide from local diff too
jaimergp Oct 3, 2024
224dec4
do we still need MAMBA_COMPILE_PYC?
jaimergp Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.js -diff
dist/setup/index.js linguist-generated=true -diff
dist/delete/index.js linguist-generated=true -diff
11 changes: 7 additions & 4 deletions .github/workflows/example-6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@ jobs:
if:
(github.event_name == 'schedule' && github.repository ==
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
name: Ex6 (${{ matrix.os }})
name:
Ex6 (${{ matrix.os }}, mamba ${{ matrix.mamba-version }}, ${{
matrix.activate-environment }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
mamba-version: ["1.5.10", "2"]
include:
- os: ubuntu-latest
activate-environment: anaconda-client-env
- os: macos-latest
activate-environment: /tmp/anaconda-client-env
- os: windows-latest
activate-environment: c:\ace
activate-environment: C:\ace
defaults:
run:
shell: bash -el {0}
Expand All @@ -47,7 +50,7 @@ jobs:
with:
miniforge-variant: Miniforge3
python-version: "3.11"
mamba-version: "*"
mamba-version: ${{ matrix.mamba-version }}
channels: conda-forge,nodefaults
channel-priority: true
activate-environment: ${{ matrix.activate-environment }}
Expand All @@ -69,7 +72,7 @@ jobs:
- name: Windows, .bat, from Cmd
shell: cmd /C call {0}
if: matrix.os == 'windows-latest'
run: mamba --version
run: mamba.bat --version
- name: Windows, no .bat, from Cmd
shell: cmd /C call {0}
if: matrix.os == 'windows-latest'
Expand Down
3 changes: 2 additions & 1 deletion dist/delete/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

130 changes: 102 additions & 28 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 54 additions & 10 deletions src/base-tools/update-mamba.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from "fs";
import * as path from "path";

import * as core from "@actions/core";

Expand All @@ -23,16 +24,59 @@ export const updateMamba: types.IToolProvider = {
};
},
postInstall: async (inputs, options) => {
if (!constants.IS_WINDOWS) {
core.info("`mamba` is already executable");
return;
}
core.info("Creating bash wrapper for `mamba`...");
// Add bat-less forwarder for bash users on Windows
const mambaBat = conda.condaExecutable(options).replace(/\\/g, "/");
const mambaExec = conda.condaExecutable(options);
const condabinLocation = path.join(
conda.condaBasePath(options),
"condabin",
path.basename(mambaExec),
);
if (constants.IS_UNIX) {
if (!fs.existsSync(condabinLocation)) {
// This is mamba 2.x with only $PREFIX/bin/mamba,
// we just need a symlink in condabin
core.info(`Symlinking ${mambaExec} to ${condabinLocation}...`);
fs.symlinkSync(mambaExec, condabinLocation);
}
} else {
core.info(`Creating bash wrapper for 'mamba'...`);
const mambaBat = condabinLocation.slice(0, -4) + ".bat";
// Add bat-less forwarder for bash users on Windows
const forwarderContents = `cmd.exe /C CALL "${mambaBat}" $* || exit 1`;
fs.writeFileSync(condabinLocation.slice(0, -4), forwarderContents);
core.info(`... wrote ${mambaExec.slice(0, -4)}:\n${forwarderContents}`);
if (!fs.existsSync(mambaBat)) {
// This is Windows and mamba 2.x, we need a mamba.bat like 1.x used to have
const contents = `
@REM Copyright (C) 2012 Anaconda, Inc
@REM SPDX-License-Identifier: BSD-3-Clause

@REM echo _CE_CONDA is %_CE_CONDA%
@REM echo _CE_M is %_CE_M%
@REM echo CONDA_EXE is %CONDA_EXE%

@IF NOT DEFINED _CE_CONDA (
@SET _CE_M=
@SET "CONDA_EXE=%~dp0..\\Scripts\\conda.exe"
)
@IF [%1]==[activate] "%~dp0_conda_activate" %*
@IF [%1]==[deactivate] "%~dp0_conda_activate" %*

@SET MAMBA_EXES="%~dp0..\\Library\\bin\\mamba.exe"
@CALL %MAMBA_EXES% %*

const contents = `bash.exe -c "exec '${mambaBat}' $*" || exit 1`;
fs.writeFileSync(mambaBat.slice(0, -4), contents);
core.info(`... wrote ${mambaBat}:\n${contents}`);
@IF %errorlevel% NEQ 0 EXIT /B %errorlevel%

@IF [%1]==[install] "%~dp0_conda_activate" reactivate
@IF [%1]==[update] "%~dp0_conda_activate" reactivate
@IF [%1]==[upgrade] "%~dp0_conda_activate" reactivate
@IF [%1]==[remove] "%~dp0_conda_activate" reactivate
@IF [%1]==[uninstall] "%~dp0_conda_activate" reactivate

@EXIT /B %errorlevel%`;
core.info(`Creating .bat wrapper for 'mamba 2.x'...`);
fs.writeFileSync(mambaBat, contents);
core.info(`... wrote ${mambaBat}`);
}
}
},
};
Loading
Loading