diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-21 01:18:21 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-21 01:18:21 -0400 |
commit | fe73a9d176f502feb454fde8c328d5ed761f50ff (patch) | |
tree | 07476d0b0f60a6c1dc760d3c3ed474008f4e9be8 /source/conda.d | |
parent | dee2bb287820edd24ca38c678a45295426cb2b28 (diff) | |
download | dm-fe73a9d176f502feb454fde8c328d5ed761f50ff.tar.gz |
A bit more work
Diffstat (limited to 'source/conda.d')
-rw-r--r-- | source/conda.d | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/source/conda.d b/source/conda.d index 90799c8..6fb7bd1 100644 --- a/source/conda.d +++ b/source/conda.d @@ -1,4 +1,6 @@ import core.cpuid : isX86_64; +import std.array; +import std.conv; import std.file; import std.stdio; import std.string; @@ -59,7 +61,7 @@ class Conda { this() { env = getenv(); env_orig = env.dup; - this.url_installer = join([this.url_miniconda, this.installer_file()], dirSeparator); + this.url_installer = join([this.url_miniconda, this.installer_file()], "/"); } void dump_env_shell() { @@ -179,7 +181,7 @@ class Conda { void configure_headless() { // YAML is cheap. // Generate a .condarc inside the new prefix root - auto fp = File(this.install_prefix ~ dirSeparator ~ ".condarc", "w+"); + auto fp = File(chainPath(this.install_prefix, ".condarc").array, "w+"); fp.write("changeps1: False\n"); fp.write("always_yes: True\n"); fp.write("quiet: True\n"); @@ -202,7 +204,7 @@ class Conda { } this.env["PATH"] = join( - [this.install_prefix ~ dirSeparator ~ "bin", + [cast(string)chainPath(this.install_prefix, "bin").array, this.env["PATH"]], pathSeparator); this.configure_headless(); @@ -239,4 +241,20 @@ class Conda { string multiarg(string flag, string[] arr) { return flag ~ " " ~ arr.join(" " ~ flag ~ " "); } + + string[] scan_packages(string pattern="*") { + string[] result; + string pkgdir = chainPath(this.install_prefix, "pkgs").array; + if (!pkgdir.exists) { + throw new Exception(pkgdir ~ " does not exist"); + } + + foreach (DirEntry e; dirEntries(pkgdir, pattern, SpanMode.shallow)) { + if (e.isFile || e.name.endsWith(dirSeparator ~ "cache")) { + continue; + } + result ~= baseName(e.name); + } + return result; + } } |