Skip to content

Commit

Permalink
Support custom conda registory
Browse files Browse the repository at this point in the history
  • Loading branch information
pplam committed Sep 20, 2024
1 parent 3ecbcd4 commit b89aae5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/kotlin/ai/devchat/installer/PythonEnvManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ai.devchat.installer
import ai.devchat.common.Log
import ai.devchat.common.OSInfo
import ai.devchat.common.PathUtils
import ai.devchat.storage.CONFIG
import java.io.File
import java.io.IOException
import java.nio.file.Paths
Expand Down Expand Up @@ -56,7 +57,7 @@ class PythonEnvManager {
PathUtils.mambaBinPath,
"create",
"-n", name,
"-c", "conda-forge",
"-c", getCondaForgeUrl(),
"-r", PathUtils.mambaWorkPath,
"python=$version",
"--yes"
Expand Down Expand Up @@ -91,6 +92,16 @@ class PythonEnvManager {
}
throw RuntimeException("$errPrefix Maximum retries exceed")
}

private fun getCondaForgeUrl(): String {
val defaultUrl = "https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/"
return try {
(CONFIG["conda-forge-url"] as? String ) ?: defaultUrl
} catch (error: Exception) {
Log.warn("Error reading conda-forge URL from config: $error")
defaultUrl
}
}
}


Expand Down

0 comments on commit b89aae5

Please sign in to comment.