diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-21 23:50:15 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-21 23:50:15 -0400 |
commit | 425e59b2e430fb5715fb943a8b64bbb867ee823b (patch) | |
tree | a44e7e5943af3edcae44f0619b96b4112eaa7e7c /source/app.d | |
parent | faa81e94ae2930a794e1ab1bab320b33e206abeb (diff) | |
download | dm-425e59b2e430fb5715fb943a8b64bbb867ee823b.tar.gz |
Clean up a little
Diffstat (limited to 'source/app.d')
-rw-r--r-- | source/app.d | 97 |
1 files changed, 46 insertions, 51 deletions
diff --git a/source/app.d b/source/app.d index cbb90e3..8eb3625 100644 --- a/source/app.d +++ b/source/app.d @@ -12,51 +12,57 @@ int main(string[] args) { string env_name; string output_dir = "delivery"; string installer_prefix = "miniconda"; + string installer_variant = "3"; string installer_version = "4.5.12"; bool run_tests = false; string mergefile; string base_spec; - auto helpInformation = getopt( - args, - config.passThrough, - config.required, "env-name|n", "name of delivery", &env_name, - config.required, "dmfile|d", "delivery merge specification file", &mergefile, - "output-dir|o", "store delivery-related results in dir", &output_dir, - "install-prefix|p", "path to install miniconda", &installer_prefix, - "install-version|i", "version of miniconda installer", &installer_version, - "run-tests|R", "scan merged packages and execute their tests", &run_tests, - "base-spec", "conda explicit or yaml environment dump", &base_spec - ); + try { + auto optargs = getopt( + args, + config.passThrough, + config.required, "env-name|n", "name of delivery", &env_name, + config.required, "dmfile|d", "delivery merge specification file", &mergefile, + "output-dir|o", "store delivery-related results in dir", &output_dir, + "install-prefix|p", "path to install miniconda", &installer_prefix, + "install-variant", "miniconda Python variant", &installer_variant, + "install-version|i", "version of miniconda installer", &installer_version, + "run-tests|R", "scan merged packages and execute their tests", &run_tests, + "base-spec", "conda explicit or yaml environment dump", &base_spec + ); - if (helpInformation.helpWanted) { - defaultGetoptPrinter("Delivery merge [fill in the blanks]", - helpInformation.options); - return 0; + if (optargs.helpWanted) { + defaultGetoptPrinter("Delivery merge [fill in the blanks]", + optargs.options); + return 0; + } + } catch (GetOptException e) { + writeln(e.msg); + return 1; } installer_prefix = buildPath(installer_prefix).absolutePath; output_dir = buildPath(output_dir, env_name).absolutePath; mergefile = buildPath(mergefile).absolutePath; + if (installer_variant != "3") { + writeln("Python 2.7 has reached end-of-life."); + writeln("3.x variant will be used instead."); + installer_variant = "3"; + } + // Ingest the dump file via --base-spec or with a positional argument. if (base_spec.empty && args.length > 1) { base_spec = args[1]; args.popBack(); } - /* - string optfmt = "env_name: %s\n" - ~ "output_dir: %s\n" - ~ "installer_prefix: %s\n" - ~ "installer_version: %s\n" - ~ "run_tests: %d\n" - ~ "mergefile: %s\n" - ~ "base_spec: %s\n" - ~ "ARGS: %s\n"; - writefln(optfmt, env_name, output_dir, installer_prefix, installer_version, - run_tests, mergefile, base_spec, args); - */ + // Make sure base_spec contains at least something + if (base_spec.empty) { + writeln("Missing base environment dump file (--base-spec)"); + return 1; + } Conda conda = new Conda(); conda.channels = [ @@ -66,43 +72,32 @@ int main(string[] args) { ]; conda.install_prefix = installer_prefix; conda.installer_version = installer_version; - conda.installer_variant = "3"; + conda.installer_variant = installer_variant; + if (!conda.installer()) { writeln("Installation failed."); return 1; } + conda.initialize(); + + if (conda.env_exists(env_name)) { + writefln("Environment '%s' already exists. Removing.", env_name); + conda.run("env remove -n " ~ env_name); + } + if (!env_combine(conda, env_name, base_spec, mergefile)) { - writeln("Delivery merge failed. Adjust '*.dm' file to match constraints reported by the 'solver'."); + writeln("Delivery merge failed!"); return 1; } if (!output_dir.exists) { output_dir.mkdirRecurse; } - writeln(conda.dump_env_yaml(buildPath(output_dir, env_name ~ ".yml"))); - writeln(conda.dump_env_explicit(buildPath(output_dir, env_name ~ ".txt"))); - - auto info = testable_packages(conda, "test.dm"); - writeln(info); - - /* - conda.activate("base"); - conda.run("info"); - conda.sh("python --version"); - conda.sh("python -c 'import sys; print(sys.path)'"); - */ - - /* - conda.sh("git clone https://github.com/spacetelescope/tweakwcs"); - auto project = "tweakwcs"; - chdir(project); - conda.sh("pip install stsci.distutils numpy"); - conda.sh("pip install -e '.[test]'"); - conda.sh("pytest -v"); - chdir(".."); - */ + conda.dump_env_yaml(buildPath(output_dir, env_name ~ ".yml")); + conda.dump_env_explicit(buildPath(output_dir, env_name ~ ".txt")); + writeln("Done!"); return 0; } |