Skip to content

Commit

Permalink
move Conda env management to __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
mjohnson541 committed Jun 30, 2024
1 parent 67c1ad6 commit 35546dd
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/ReactionMechanismSimulator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 35546dd

Please sign in to comment.