Skip to content

Commit 317a75e

Browse files
committed
improve automatic conda installation robustness
1 parent 539956e commit 317a75e

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

src/ReactionMechanismSimulator.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ module ReactionMechanismSimulator
22
ENV["JULIA_CONDAPKG_BACKEND"] = "MicroMamba"
33
using CondaPkg
44
using Logging
5-
packages = keys(CondaPkg.current_packages())
5+
has_rmgpy = true
6+
has_rmgmolecule = true
7+
try
8+
PythonCall.pyimport("rmgpy")
9+
catch
10+
has_rmgpy = false
11+
end
12+
try
13+
PythonCall.pyimport("rmgmolecule")
14+
catch
15+
has_rmgmolecule = false
16+
end
617

7-
if !("rmg" in packages) && !("rmgmolecule" in packages)
18+
if !has_rmgpy && !has_rmgmolecule
819
@info "missing rmg and rmgmolecule installing rmgmolecule..."
920
if "python" in packages
1021
py_version = VersionNumber(CondaPkg.current_packages()["python"][:version])
@@ -13,7 +24,7 @@ if !("rmg" in packages) && !("rmgmolecule" in packages)
1324
end
1425
if py_version === nothing || !(v"3.7" <= py_version && py_version <= v"3.9")
1526
@info "python version was not in 3.7-3.9 changing python version"
16-
CondaPkg.add("python"; version="3.9",resolve=false)
27+
CondaPkg.add("python"; version=">=3.9",resolve=false)
1728
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541",resolve=false)
1829
CondaPkg.add("matplotlib", channel="conda-forge",resolve=false)
1930
CondaPkg.add("rdkit", channel="conda-forge",resolve=false)

src/rmstest.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@ Logging.disable_logging(Logging.Warn)
33
ENV["JULIA_CONDAPKG_BACKEND"] = "MicroMamba"
44
using CondaPkg
55

6-
packages = keys(CondaPkg.current_packages())
6+
has_rmgpy = true
7+
has_rmgmolecule = true
8+
try
9+
PythonCall.pyimport("rmgpy")
10+
catch
11+
has_rmgpy = false
12+
end
13+
try
14+
PythonCall.pyimport("molecule")
15+
catch
16+
has_rmgmolecule = false
17+
end
718

8-
if !("rmg" in packages) && !("rmgmolecule" in packages)
19+
if !has_rmgpy && !has_rmgmolecule
920
@info "missing rmg and rmgmolecule installing rmgmolecule..."
1021
if "python" in packages
1122
py_version = VersionNumber(CondaPkg.current_packages()["python"][:version])
@@ -14,7 +25,7 @@ if !("rmg" in packages) && !("rmgmolecule" in packages)
1425
end
1526
if py_version === nothing || !(v"3.7" <= py_version && py_version <= v"3.9")
1627
@info "python version was not in 3.7-3.9 changing python version"
17-
CondaPkg.add("python"; version="3.9",resolve=false)
28+
CondaPkg.add("python"; version=">=3.9",resolve=false)
1829
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541",resolve=false)
1930
CondaPkg.add("matplotlib", channel="conda-forge",resolve=false)
2031
CondaPkg.add("rdkit", channel="conda-forge",resolve=false)

0 commit comments

Comments
 (0)