diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-09 10:02:47 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-09 10:02:47 -0400 |
commit | 5801afb48cff83547bccbf214da2b205c9fadcac (patch) | |
tree | a8c9705532334c962239d7fa9ba0cebcb9cbdc84 /src | |
parent | 92b92bfc4913d03acfe4a0b2ca33c5a891790f75 (diff) | |
download | stasis-5801afb48cff83547bccbf214da2b205c9fadcac.tar.gz |
Add static function micromamba_configure() to indexer
* Performing all of the setup tasks within indexer_conda() is very restrictive
* The conda environment bin directory is added to the program PATH
Diffstat (limited to 'src')
-rw-r--r-- | src/stasis_indexer.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/src/stasis_indexer.c b/src/stasis_indexer.c index 1630255..b703ec5 100644 --- a/src/stasis_indexer.c +++ b/src/stasis_indexer.c @@ -396,18 +396,42 @@ int indexer_make_website(struct Delivery *ctx) { return 0; } -int indexer_conda(struct Delivery *ctx) { +static int micromamba_configure(const struct Delivery *ctx, struct MicromambaInfo *m) { int status = 0; - char micromamba_prefix[PATH_MAX] = {0}; - sprintf(micromamba_prefix, "%s/bin", ctx->storage.tools_dir); - struct MicromambaInfo m = {.conda_prefix = globals.conda_install_prefix, .micromamba_prefix = micromamba_prefix}; + char *micromamba_prefix = NULL; + if (asprintf(µmamba_prefix, "%s/bin", ctx->storage.tools_dir) < 0) { + return -1; + } + m->conda_prefix = globals.conda_install_prefix; + m->micromamba_prefix = micromamba_prefix; + + size_t pathvar_len = strlen(getenv("PATH")) + strlen(m->micromamba_prefix + strlen(m->conda_prefix)) + 3 + 4 + 1; + // ^^^^^^^^^^^^^^^^^^ + // 3 = separators + // 4 = chars (/bin) + // 1 = nul terminator + char *pathvar = calloc(pathvar_len, sizeof(*pathvar)); + if (!pathvar) { + SYSERROR("%s", "Unable to allocate bytes for temporary path string"); + exit(1); + } + snprintf(pathvar, pathvar_len, "%s/bin:%s:%s", m->conda_prefix, m->micromamba_prefix, getenv("PATH")); + setenv("PATH", pathvar, 1); + guard_free(pathvar); - status += micromamba(&m, "config prepend --env channels conda-forge"); + status += micromamba(m, "config prepend --env channels conda-forge"); if (!globals.verbose) { - status += micromamba(&m, "config set --env quiet true"); + status += micromamba(m, "config set --env quiet true"); } - status += micromamba(&m, "config set --env always_yes true"); - status += micromamba(&m, "install conda-build"); + status += micromamba(m, "config set --env always_yes true"); + status += micromamba(m, "install conda-build pandoc"); + + return status; +} + +int indexer_conda(struct Delivery *ctx, struct MicromambaInfo m) { + int status = 0; + status += micromamba(&m, "run conda index %s", ctx->storage.conda_artifact_dir); return status; } @@ -825,8 +849,14 @@ int main(int argc, char *argv[]) { mkdirs(ctx.storage.wheel_artifact_dir, 0755); } + struct MicromambaInfo m; + if (micromamba_configure(&ctx, &m)) { + SYSERROR("%s", "Unable to configure micromamba"); + exit(1); + } + msg(STASIS_MSG_L1, "Indexing conda packages\n"); - if (indexer_conda(&ctx)) { + if (indexer_conda(&ctx, m)) { SYSERROR("%s", "Conda package indexing operation failed"); exit(1); } |