From 35546dd02d1c4936b7e218afa7ea99a0c324ed28 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Sat, 29 Jun 2024 19:38:52 -0700 Subject: [PATCH] move Conda env management to __init__ --- src/ReactionMechanismSimulator.jl | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ReactionMechanismSimulator.jl b/src/ReactionMechanismSimulator.jl index fe2d8481..3715fc7f 100644 --- a/src/ReactionMechanismSimulator.jl +++ b/src/ReactionMechanismSimulator.jl @@ -2,23 +2,6 @@ module ReactionMechanismSimulator using PythonCall using CondaPkg using Logging -packages = keys(CondaPkg.current_packages()) - -if !("rmg" in packages) && !("rmgmolecule" in packages) - @info "missing rmg and rmgmolecule installing rmgmolecule..." - if !(v"3.7" <= PythonCall.C.python_version() && PythonCall.C.python_version() <= v"3.9") - @info "python version was not in 3.7-3.9 changing python version" - CondaPkg.add("python"; version="3.9") - end - CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541") - CondaPkg.add("matplotlib", channel="conda-forge") - CondaPkg.add("rdkit", channel="conda-forge") - CondaPkg.add("pydot", channel="conda-forge") - - const Pkg = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")) - Pkg.build("PythonCall") -end - const Chem = PythonCall.pynew() const Desc = PythonCall.pynew() const molecule = PythonCall.pynew() @@ -34,6 +17,23 @@ const solvation = PythonCall.pynew() const fragment = PythonCall.pynew() const pydot = PythonCall.pynew() function __init__() + + packages = keys(CondaPkg.current_packages()) + + if !("rmg" in packages) && !("rmgmolecule" in packages) + @info "missing rmg and rmgmolecule installing rmgmolecule..." + if !(v"3.7" <= PythonCall.C.python_version() && PythonCall.C.python_version() <= v"3.9") + @info "python version was not in 3.7-3.9 changing python version" + CondaPkg.add("python"; version="3.9") + end + CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541") + CondaPkg.add("matplotlib", channel="conda-forge") + CondaPkg.add("rdkit", channel="conda-forge") + CondaPkg.add("pydot", channel="conda-forge") + + const Pkg = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")) + Pkg.build("PythonCall") + end PythonCall.pycopy!(Chem, pyimport("rdkit.Chem")) PythonCall.pycopy!(Desc, pyimport("rdkit.Chem.Descriptors")) try