Skip to content

Commit 35546dd

Browse files
committed
move Conda env management to __init__
1 parent 67c1ad6 commit 35546dd

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/ReactionMechanismSimulator.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,6 @@ module ReactionMechanismSimulator
22
using PythonCall
33
using CondaPkg
44
using Logging
5-
packages = keys(CondaPkg.current_packages())
6-
7-
if !("rmg" in packages) && !("rmgmolecule" in packages)
8-
@info "missing rmg and rmgmolecule installing rmgmolecule..."
9-
if !(v"3.7" <= PythonCall.C.python_version() && PythonCall.C.python_version() <= v"3.9")
10-
@info "python version was not in 3.7-3.9 changing python version"
11-
CondaPkg.add("python"; version="3.9")
12-
end
13-
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541")
14-
CondaPkg.add("matplotlib", channel="conda-forge")
15-
CondaPkg.add("rdkit", channel="conda-forge")
16-
CondaPkg.add("pydot", channel="conda-forge")
17-
18-
const Pkg = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"))
19-
Pkg.build("PythonCall")
20-
end
21-
225
const Chem = PythonCall.pynew()
236
const Desc = PythonCall.pynew()
247
const molecule = PythonCall.pynew()
@@ -34,6 +17,23 @@ const solvation = PythonCall.pynew()
3417
const fragment = PythonCall.pynew()
3518
const pydot = PythonCall.pynew()
3619
function __init__()
20+
21+
packages = keys(CondaPkg.current_packages())
22+
23+
if !("rmg" in packages) && !("rmgmolecule" in packages)
24+
@info "missing rmg and rmgmolecule installing rmgmolecule..."
25+
if !(v"3.7" <= PythonCall.C.python_version() && PythonCall.C.python_version() <= v"3.9")
26+
@info "python version was not in 3.7-3.9 changing python version"
27+
CondaPkg.add("python"; version="3.9")
28+
end
29+
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541")
30+
CondaPkg.add("matplotlib", channel="conda-forge")
31+
CondaPkg.add("rdkit", channel="conda-forge")
32+
CondaPkg.add("pydot", channel="conda-forge")
33+
34+
const Pkg = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"))
35+
Pkg.build("PythonCall")
36+
end
3737
PythonCall.pycopy!(Chem, pyimport("rdkit.Chem"))
3838
PythonCall.pycopy!(Desc, pyimport("rdkit.Chem.Descriptors"))
3939
try

0 commit comments

Comments
 (0)