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

add mamba support #47

Merged
merged 4 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions .github/workflows/example-6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Example 6: Mamba"

on:
pull_request:
branches:
- '*'
push:
branches:
- 'master'

jobs:
example-6:
name: Ex6 Mamba
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: ./
with:
python-version: 3.6
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
activate-environment: anaconda-client-env
environment-file: etc/example-environment.yml
- shell: bash -l {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- shell: bash -l {0}
run: mamba install jupyterlab
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
![Example 3: Other options](https://github.com/goanpeca/setup-miniconda/workflows/Example%203:%20Other%20options/badge.svg?branch=master)
![Example 4: Channels](https://github.com/goanpeca/setup-miniconda/workflows/Example%204:%20Channels/badge.svg?branch=master)
![Example 5: Custom installer](https://github.com/goanpeca/setup-miniconda/workflows/Example%205:%20Custom%20installer/badge.svg?branch=master)
![Example 6: Mamba](https://github.com/goanpeca/setup-miniconda/workflows/Example%206:%20Mamba/badge.svg?branch=master)
![Caching Example](https://github.com/goanpeca/setup-miniconda/workflows/Caching%20Example/badge.svg?branch=master)
![Linting](https://github.com/goanpeca/setup-miniconda/workflows/Linting/badge.svg?branch=master)

Expand Down Expand Up @@ -217,6 +218,36 @@ jobs:
conda config --show
```

#### Example 6: Mamba

Experimental! Use `mamba` to handle conda installs in a faster way. `mamba-version` accepts a version string `x.y` (including `"*"`). It requires you specify `conda-forge` as part of the channels, ideally with the highest priority.

```yaml
jobs:
example-6:
name: Ex6 Mamba
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- uses: ./
with:
python-version: 3.6
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
activate-environment: anaconda-client-env
environment-file: etc/example-environment.yml
- shell: bash -l {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- shell: bash -l {0}
run: mamba install jupyterlab
```

## Caching

If you want to enable package caching for conda you can use the [cache action](https://github.com/actions/cache) using `~/conda_pkgs_dir` as path for conda packages.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ inputs:
description: 'Advanced. Prior to runnning "conda init" all shell profiles will be removed from the runner. Default is "true".'
required: false
default: "true"
mamba-version:
description: 'Experimental. Use mamba (https://github.com/QuantStack/mamba) as a faster drop-in replacement for conda installs. Disabled by default. To enable, use "*" or a "x.y" version string.'
required: false
default: ""
runs:
using: "node12"
main: "dist/setup/index.js"
Expand Down
76 changes: 51 additions & 25 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21368,12 +21368,16 @@ function minicondaPath(useBundled = true) {
return condaPath;
}
/**
* Provide cross platform location of conda executable
* Provide cross platform location of conda/mamba executable
*/
function condaExecutable(useBundled) {
function condaExecutable(useBundled, useMamba = false) {
const dir = minicondaPath(useBundled);
let condaExe;
condaExe = IS_UNIX ? `${dir}/condabin/conda` : `${dir}\\condabin\\conda.bat`;
let commandName;
commandName = useMamba ? "mamba" : "conda";
condaExe = IS_UNIX
? `${dir}/condabin/${commandName}`
: `${dir}\\condabin\\${commandName}.bat`;
return condaExe;
}
/**
Expand Down Expand Up @@ -21510,9 +21514,9 @@ function installMiniconda(installerPath, useBundled) {
/**
* Run Conda command
*/
function condaCommand(cmd, useBundled) {
function condaCommand(cmd, useBundled, useMamba = false) {
return __awaiter(this, void 0, void 0, function* () {
const command = `${condaExecutable(useBundled)} ${cmd}`;
const command = `${condaExecutable(useBundled, useMamba)} ${cmd}`;
return yield execute(command);
});
}
Expand Down Expand Up @@ -21541,15 +21545,15 @@ function setVariables(useBundled) {
/**
* Create test environment
*/
function createTestEnvironment(activateEnvironment, useBundled) {
function createTestEnvironment(activateEnvironment, useBundled, useMamba) {
return __awaiter(this, void 0, void 0, function* () {
let result;
if (activateEnvironment !== "root" &&
activateEnvironment !== "base" &&
activateEnvironment !== "") {
if (!environmentExists(activateEnvironment, useBundled)) {
utils.consoleLog("Create test environment...");
result = yield condaCommand(`create --name ${activateEnvironment}`, useBundled);
result = yield condaCommand(`create --name ${activateEnvironment}`, useBundled, useMamba);
if (!result.ok)
return result;
}
Expand Down Expand Up @@ -21633,7 +21637,7 @@ function condaInit(activateEnvironment, useBundled, condaConfig, removeProfiles)
// Run conda init
core.info("\n");
for (let cmd of ["--all"]) {
const command = `${condaExecutable(useBundled)} init ${cmd}`;
const command = `${condaExecutable(useBundled, false)} init ${cmd}`;
yield execute(command);
}
// Rename files
Expand Down Expand Up @@ -21730,9 +21734,9 @@ conda activate ${activateEnvironment}`;
/**
* Setup python test environment
*/
function setupPython(activateEnvironment, pythonVersion, useBundled) {
function setupPython(activateEnvironment, pythonVersion, useBundled, useMamba) {
return __awaiter(this, void 0, void 0, function* () {
return yield condaCommand(`install --name ${activateEnvironment} python=${pythonVersion}`, useBundled);
return yield condaCommand(`install --name ${activateEnvironment} python=${pythonVersion}`, useBundled, useMamba);
});
}
/**
Expand All @@ -21751,22 +21755,22 @@ function applyCondaConfiguration(condaConfig, useBundled) {
let channels = condaConfig[key].split(",").reverse();
let channel;
for (channel of channels) {
result = yield condaCommand(`config --add ${key} ${channel}`, useBundled);
result = yield condaCommand(`config --add ${key} ${channel}`, useBundled, false);
if (!result.ok)
return result;
}
}
else {
result = yield condaCommand(`config --set ${key} ${condaConfig[key]}`, useBundled);
result = yield condaCommand(`config --set ${key} ${condaConfig[key]}`, useBundled, false);
if (!result.ok)
return result;
}
}
}
result = yield condaCommand(`config --show-sources`, useBundled);
result = yield condaCommand(`config --show-sources`, useBundled, false);
if (!result.ok)
return result;
result = yield condaCommand(`config --show`, useBundled);
result = yield condaCommand(`config --show`, useBundled, false);
if (!result.ok)
return result;
}
Expand All @@ -21779,10 +21783,11 @@ function applyCondaConfiguration(condaConfig, useBundled) {
/**
* Main conda setup method to handle all configuration options
*/
function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersion, condaBuildVersion, pythonVersion, activateEnvironment, environmentFile, condaConfigFile, condaConfig, removeProfiles) {
function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersion, condaBuildVersion, pythonVersion, activateEnvironment, environmentFile, condaConfigFile, condaConfig, removeProfiles, mambaVersion) {
return __awaiter(this, void 0, void 0, function* () {
let result;
let useBundled = true;
let useMamba = false;
try {
// Check for consistency
if (condaConfig["auto_update_conda"] == "true" && condaVersion) {
Expand All @@ -21794,6 +21799,12 @@ function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersi
error: new Error(`"python-version=${pythonVersion}" was provided but "activate-environment" is not defined!`)
};
}
if (!condaConfig["channels"].includes("conda-forge") && mambaVersion) {
return {
ok: false,
error: new Error(`"mamba-version=${mambaVersion}" requires "conda-forge" to be included in "channels!"`)
};
}
if (installerUrl !== "") {
if (minicondaVersion !== "") {
return {
Expand Down Expand Up @@ -21856,7 +21867,7 @@ function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersi
}
let cacheFolder = "~/conda_pkgs_dir";
cacheFolder = cacheFolder.replace("~", os.homedir().replace("\\", "/"));
result = yield condaCommand(`config --add pkgs_dirs ${cacheFolder}`, useBundled);
result = yield condaCommand(`config --add pkgs_dirs ${cacheFolder}`, useBundled, useMamba);
if (!result.ok)
return result;
core.exportVariable("CONDA_PKGS_DIR", cacheFolder);
Expand All @@ -21877,7 +21888,7 @@ function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersi
// if (!result.ok) return result;
}
utils.consoleLog("Setup Conda basic configuration...");
result = yield condaCommand("config --set always_yes yes --set changeps1 no", useBundled);
result = yield condaCommand("config --set always_yes yes --set changeps1 no", useBundled, useMamba);
if (!result.ok)
return result;
utils.consoleLog("Initialize Conda and fix ownership...");
Expand All @@ -21886,13 +21897,13 @@ function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersi
return result;
if (condaVersion) {
utils.consoleLog("Installing Conda...");
result = yield condaCommand(`install --name base conda=${condaVersion}`, useBundled);
result = yield condaCommand(`install --name base conda=${condaVersion}`, useBundled, useMamba);
if (!result.ok)
return result;
}
if (condaConfig["auto_update_conda"] == "true") {
utils.consoleLog("Updating conda...");
result = yield condaCommand("update conda", useBundled);
result = yield condaCommand("update conda", useBundled, useMamba);
if (!result.ok)
return result;
if (condaConfig) {
Expand All @@ -21903,20 +21914,33 @@ function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersi
}
}
// Any conda commands run here after init and setup
if (mambaVersion) {
utils.consoleLog("Installing Mamba...");
core.warning(`Mamba support is still experimental and can result in differently solved environments!`);
if (mambaVersion) {
result = yield condaCommand(`install --name base mamba=${mambaVersion}`, useBundled, useMamba);
}
if (result.ok) {
useMamba = true;
}
else {
return result;
}
}
if (condaBuildVersion) {
utils.consoleLog("Installing Conda Build...");
result = yield condaCommand(`install --name base conda-build=${condaBuildVersion}`, useBundled);
result = yield condaCommand(`install --name base conda-build=${condaBuildVersion}`, useBundled, useMamba);
if (!result.ok)
return result;
}
if (activateEnvironment) {
result = yield createTestEnvironment(activateEnvironment, useBundled);
result = yield createTestEnvironment(activateEnvironment, useBundled, useMamba);
if (!result.ok)
return result;
}
if (pythonVersion && activateEnvironment) {
utils.consoleLog(`Installing Python="${pythonVersion}" on "${activateEnvironment}" environment...`);
result = yield setupPython(activateEnvironment, pythonVersion, useBundled);
result = yield setupPython(activateEnvironment, pythonVersion, useBundled, useMamba);
if (!result.ok)
return result;
}
Expand Down Expand Up @@ -21945,7 +21969,7 @@ function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersi
else {
condaAction = "create";
}
result = yield condaCommand(`env ${condaAction} -f ${environmentFile}`, useBundled);
result = yield condaCommand(`env ${condaAction} -f ${environmentFile}`, useBundled, useMamba);
if (!result.ok)
return result;
}
Expand Down Expand Up @@ -21983,6 +22007,8 @@ function run() {
let removeProfiles = core.getInput("remove-profiles");
let showChannelUrls = core.getInput("show-channel-urls");
let useOnlyTarBz2 = core.getInput("use-only-tar-bz2");
// Mamba
let mambaVersion = core.getInput("mamba-version");
const condaConfig = {
add_anaconda_token: addAnacondaToken,
add_pip_as_python_dependency: addPipAsPythonDependency,
Expand All @@ -21995,7 +22021,7 @@ function run() {
show_channel_urls: showChannelUrls,
use_only_tar_bz2: useOnlyTarBz2
};
const result = yield setupMiniconda(installerUrl, minicondaVersion, "x64", condaVersion, condaBuildVersion, pythonVersion, activateEnvironment, environmentFile, condaFile, condaConfig, removeProfiles);
const result = yield setupMiniconda(installerUrl, minicondaVersion, "x64", condaVersion, condaBuildVersion, pythonVersion, activateEnvironment, environmentFile, condaFile, condaConfig, removeProfiles, mambaVersion);
if (!result.ok) {
throw result.error;
}
Expand Down Expand Up @@ -29040,7 +29066,7 @@ module.exports = defaults;
/* 771 */
/***/ (function(module) {

module.exports = {"_args":[["[email protected]","/Users/goanpeca/Dropbox (Personal)/develop/quansight/setup-miniconda"]],"_from":"[email protected]","_id":"[email protected]","_inBundle":false,"_integrity":"sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==","_location":"/cheerio","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"[email protected]","name":"cheerio","escapedName":"cheerio","rawSpec":"1.0.0-rc.3","saveSpec":null,"fetchSpec":"1.0.0-rc.3"},"_requiredBy":["/get-hrefs"],"_resolved":"https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz","_spec":"1.0.0-rc.3","_where":"/Users/goanpeca/Dropbox (Personal)/develop/quansight/setup-miniconda","author":{"name":"Matt Mueller","email":"[email protected]","url":"mat.io"},"bugs":{"url":"https://github.com/cheeriojs/cheerio/issues"},"dependencies":{"css-select":"~1.2.0","dom-serializer":"~0.1.1","entities":"~1.1.1","htmlparser2":"^3.9.1","lodash":"^4.15.0","parse5":"^3.0.1"},"description":"Tiny, fast, and elegant implementation of core jQuery designed specifically for the server","devDependencies":{"benchmark":"^2.1.0","coveralls":"^2.11.9","expect.js":"~0.3.1","istanbul":"^0.4.3","jquery":"^3.0.0","jsdom":"^9.2.1","jshint":"^2.9.2","mocha":"^3.1.2","xyz":"~1.1.0"},"engines":{"node":">= 0.6"},"files":["index.js","lib"],"homepage":"https://github.com/cheeriojs/cheerio#readme","keywords":["htmlparser","jquery","selector","scraper","parser","html"],"license":"MIT","main":"./index.js","name":"cheerio","repository":{"type":"git","url":"git://github.com/cheeriojs/cheerio.git"},"scripts":{"test":"make test"},"version":"1.0.0-rc.3"};
module.exports = {"_args":[["[email protected]","/home/jaime/devel/py/jaimergp/setup-miniconda"]],"_from":"[email protected]","_id":"[email protected]","_inBundle":false,"_integrity":"sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==","_location":"/cheerio","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"[email protected]","name":"cheerio","escapedName":"cheerio","rawSpec":"1.0.0-rc.3","saveSpec":null,"fetchSpec":"1.0.0-rc.3"},"_requiredBy":["/get-hrefs"],"_resolved":"https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz","_spec":"1.0.0-rc.3","_where":"/home/jaime/devel/py/jaimergp/setup-miniconda","author":{"name":"Matt Mueller","email":"[email protected]","url":"mat.io"},"bugs":{"url":"https://github.com/cheeriojs/cheerio/issues"},"dependencies":{"css-select":"~1.2.0","dom-serializer":"~0.1.1","entities":"~1.1.1","htmlparser2":"^3.9.1","lodash":"^4.15.0","parse5":"^3.0.1"},"description":"Tiny, fast, and elegant implementation of core jQuery designed specifically for the server","devDependencies":{"benchmark":"^2.1.0","coveralls":"^2.11.9","expect.js":"~0.3.1","istanbul":"^0.4.3","jquery":"^3.0.0","jsdom":"^9.2.1","jshint":"^2.9.2","mocha":"^3.1.2","xyz":"~1.1.0"},"engines":{"node":">= 0.6"},"files":["index.js","lib"],"homepage":"https://github.com/cheeriojs/cheerio#readme","keywords":["htmlparser","jquery","selector","scraper","parser","html"],"license":"MIT","main":"./index.js","name":"cheerio","repository":{"type":"git","url":"git://github.com/cheeriojs/cheerio.git"},"scripts":{"test":"make test"},"version":"1.0.0-rc.3"};

/***/ }),
/* 772 */
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

Loading