#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
#include "core.h"
#include "download.h"
Go to the source code of this file.
|
|
#define | CONDA_INSTALL_PREFIX "conda" |
| |
|
#define | PYPI_INDEX_DEFAULT "https://pypi.org/simple" |
| |
|
#define | PKG_USE_PIP 0 |
| |
|
#define | PKG_USE_CONDA 1 |
| |
|
#define | PKG_NOT_FOUND 0 |
| |
|
#define | PKG_FOUND 1 |
| |
|
#define | PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET (-10) |
| |
|
#define | PKG_E_SUCCESS (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 0) |
| |
|
#define | PKG_INDEX_PROVIDES_E_INTERNAL_MODE_UNKNOWN (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 1) |
| |
|
#define | PKG_INDEX_PROVIDES_E_INTERNAL_LOG_HANDLE (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 2) |
| |
|
#define | PKG_INDEX_PROVIDES_E_MANAGER_RUNTIME (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 3) |
| |
|
#define | PKG_INDEX_PROVIDES_E_MANAGER_SIGNALED (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 4) |
| |
|
#define | PKG_INDEX_PROVIDES_E_MANAGER_EXEC (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 5) |
| |
| #define | PKG_INDEX_PROVIDES_FAILED(ECODE) |
| |
|
| int | micromamba (const struct MicromambaInfo *info, char *command,...) |
| |
| int | python_exec (const char *args) |
| |
| int | pip_exec (const char *args) |
| |
| int | conda_exec (const char *args) |
| |
| int | conda_activate (const char *root, const char *env_name) |
| |
| int | conda_setup_headless () |
| |
| int | conda_env_create_from_uri (char *name, char *uri, char *python_version) |
| |
| int | conda_env_create (char *name, char *python_version, char *packages) |
| |
| int | conda_env_remove (char *name) |
| |
| int | conda_env_export (char *name, char *output_dir, char *output_filename) |
| |
| int | conda_index (const char *path) |
| |
| int | pkg_index_provides (int mode, const char *index, const char *spec, const char *logdir) |
| |
|
const char * | pkg_index_provides_strerror (int code) |
| |
|
char * | conda_get_active_environment () |
| |
|
int | conda_env_exists (const char *root, const char *name) |
| |
◆ PKG_INDEX_PROVIDES_FAILED
| #define PKG_INDEX_PROVIDES_FAILED |
( |
| ECODE | ) |
|
Value:((ECODE) <= PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET)
◆ conda_activate()
| int conda_activate |
( |
const char * | root, |
|
|
const char * | env_name ) |
Configure the runtime environment to use Conda/Mamba
fprintf(stderr, "Failed to activate conda's base environment\n");
exit(1);
}
int conda_activate(const char *root, const char *env_name)
Definition conda.c:359
- Parameters
-
| root | directory where conda is installed |
| env_name | the conda environment to activate |
- Returns
- 0 on success, -1 on error
◆ conda_env_create()
| int conda_env_create |
( |
char * | name, |
|
|
char * | python_version, |
|
|
char * | packages ) |
Create a Conda environment using generic package specs
fprintf(stderr, "Environment creation failed\n");
exit(1);
}
if (conda_env_create("myenv", "3.11", "hstcal fitsverify")) {
fprintf(stderr, "Environment creation failed\n");
exit(1);
}
int conda_env_create(char *name, char *python_version, char *packages)
Definition conda.c:641
- Parameters
-
| name | Environment name |
| python_version | Desired version of Python |
| packages | Packages to install (or NULL) |
- Returns
- exit code from "conda"
◆ conda_env_create_from_uri()
| int conda_env_create_from_uri |
( |
char * | name, |
|
|
char * | uri, |
|
|
char * | python_version ) |
Creates a Conda environment from a YAML config
fprintf(stderr, "Environment creation failed\n");
exit(1);
}
int conda_env_create_from_uri(char *name, char *uri, char *python_version)
Definition conda.c:588
- Parameters
-
- Returns
- exit code from "conda"
◆ conda_env_export()
| int conda_env_export |
( |
char * | name, |
|
|
char * | output_dir, |
|
|
char * | output_filename ) |
Export a Conda environment in YAML format
fprintf(stderr, "Unable to export environment\n");
exit(1);
}
int conda_env_export(char *name, char *output_dir, char *output_filename)
Definition conda.c:662
- Parameters
-
| name | Environment name to export |
| output_dir | Destination directory |
| output_filename | Destination file name |
- Returns
- exit code from "conda"
◆ conda_env_remove()
| int conda_env_remove |
( |
char * | name | ) |
|
Remove a Conda environment
fprintf(stderr, "Unable to remove conda environment\n");
exit(1);
}
int conda_env_remove(char *name)
Definition conda.c:656
- Parameters
-
- Returns
- exit code from "conda"
◆ conda_exec()
| int conda_exec |
( |
const char * | args | ) |
|
Execute conda (or if possible, mamba) Conda/Mamba is determined by PATH
fprintf(stderr, "Failed to list conda environments\n");
exit(1);
}
int conda_exec(const char *args)
Definition conda.c:254
- Parameters
-
| args | arguments to pass to Conda |
- Returns
- exit code from Conda
◆ conda_index()
| int conda_index |
( |
const char * | path | ) |
|
Run "conda index" on a local conda channel
fprintf(stderr, "Unable to index requested path\n");
exit(1);
}
int conda_index(const char *path)
Definition conda.c:683
- Parameters
-
| path | Top-level directory of conda channel |
- Returns
- exit code from "conda"
◆ conda_setup_headless()
| int conda_setup_headless |
( |
| ) |
|
Configure the active conda installation for headless operation
◆ micromamba()
| int micromamba |
( |
const struct MicromambaInfo * | info, |
|
|
char * | command, |
|
|
| ... ) |
Execute micromamba
- Parameters
-
| info | MicromambaInfo data structure (must be populated before use) |
| command | printf-style formatter string |
| ... | variadic arguments |
- Returns
- exit code
◆ pip_exec()
| int pip_exec |
( |
const char * | args | ) |
|
Execute Pip Pip is determined by PATH
fprintf(stderr, "pip freeze failed\n");
exit(1);
}
int pip_exec(const char *args)
Definition conda.c:124
- Parameters
-
| args | arguments to pass to Pip |
- Returns
- exit code from Pip
◆ pkg_index_provides()
| int pkg_index_provides |
( |
int | mode, |
|
|
const char * | index, |
|
|
const char * | spec, |
|
|
const char * | logdir ) |
Determine whether a package index contains a package
if (PKG_INDEX_PROVIDES_FAILED(result)) {
fprintf(stderr, "failed: %s\n", pkg_index_provides_strerror(result));
exit(1);
} else if (result == PKG_NOT_FOUND) {
} else {
}
int pkg_index_provides(int mode, const char *index, const char *spec, const char *logdir)
Definition conda.c:153
- Parameters
-
| mode | USE_PIP |
| mode | USE_CONDA |
| index | a file system path or url pointing to a simple index or conda channel |
| spec | a pip package specification (e.g. name==1.2.3) |
| logdir | the directory to store the output log |
| spec | a conda package specification (e.g. name=1.2.3) |
- Returns
- PKG_NOT_FOUND, if not found
-
PKG_FOUND, if found
-
PKG_E_INDEX_PROVIDES_{ERROR}, on error (see conda.h)
◆ python_exec()
| int python_exec |
( |
const char * | args | ) |
|
Execute Python Python interpreter is determined by PATH
fprintf(stderr, "Hello world failed\n");
exit(1);
}
int python_exec(const char *args)
Definition conda.c:109
- Parameters
-
| args | arguments to pass to interpreter |
- Returns
- exit code from python interpreter