MCPcopy Create free account
hub / github.com/6174/comflowyspace / getCondaInfo

Function getCondaInfo

apps/node/src/modules/utils/conda.ts:114–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112 * @returns
113 */
114export function getCondaInfo(): CondaInfo {
115 // if user already install conda, conda_prefix is the location of conda root;
116 const conda = getCondaPrefixSync();
117 const CONDA_ROOT = conda ? conda : DEFAULT_CONDA_PATH;
118
119 if (isWindows) {
120 return {
121 CONDA_ROOT,
122 CONDA_SCRIPTS_PATH: `${CONDA_ROOT}\\Scripts`,
123 CONDA_PATH: `${CONDA_ROOT}\\Scripts\\conda.exe`,
124 }
125 }
126
127 return {
128 CONDA_ROOT,
129 CONDA_SCRIPTS_PATH: `${CONDA_ROOT}/bin`,
130 CONDA_PATH: `${CONDA_ROOT}/condabin/conda`,
131 }
132
133 /**
134 * Get real conda path position
135 * @returns
136 */
137 function getCondaPrefixSync(): string | undefined {
138 const SHELL_ENV_PATH = getSystemPath({
139 CONDA_SCRIPTS_PATH: DEFAULT_CONDA_PATH,
140 CONDA_ENV_PATH: DEFAULT_CONDA_ENV_PATH
141 });
142 console.log("Use custom shell path to resolve conda", SHELL_ENV_PATH);
143
144 let ret;
145 try {
146 const result = execSync(`conda info --base`, {
147 env: {
148 ...process.env,
149 PATH: SHELL_ENV_PATH,
150 Path: SHELL_ENV_PATH
151 },
152 encoding: 'utf-8',
153 });
154 ret = result.toString().trim();
155 } catch (err1: any) {
156 console.log("get conda default prefix error", err1);
157 }
158
159 if (ret && ret !== "") {
160 return ret;
161 }
162
163 console.log("Try Use default PATH to resolve conda", process.env.PATH);
164
165 try {
166 const result = execSync(`conda info --base`, {
167 env: {
168 ...process.env,
169 PATH: process.env.PATH,
170 Path: process.env.PATH
171 },

Callers 1

updateCondaInfoMethod · 0.85

Calls 1

getCondaPrefixSyncFunction · 0.85

Tested by

no test coverage detected