Skip to content

Commit

Permalink
clean up conda installs
Browse files Browse the repository at this point in the history
avoid use of PythonCall
resolve all conda changes at once
  • Loading branch information
mjohnson541 committed Jul 1, 2024
1 parent 2d07eac commit e597206
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 38 deletions.
8 changes: 5 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ authors = ["Matt Johnson <mjohnson541@gmail.com>", "Hao-Wei Pang <hao4wei3pang2@
version = "1.0.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Expand All @@ -17,6 +17,7 @@ IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LsqFit = "2fda8390-95c7-5789-9bda-21331edee243"
MicroMamba = "0b3b1443-0f03-428d-bdfb-f27f9c1191ea"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Expand All @@ -41,18 +42,18 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[compat]
CSV = "0.10"
Calculus = "0.4,0.5"
Colors = "0.11,0.12"
CondaPkg = "0.2"
CSV = "0.10"
DataFrames = "1"
SciMLSensitivity = "^7"
FastGaussQuadrature = "0.5"
ForwardDiff = "0.10"
Images = "0.24"
IncompleteLU = "0.2"
IterTools = "1.3"
LsqFit = "0.12"
MicroMamba = "0.1"
ModelingToolkit = "8"
OrdinaryDiffEq = "^6"
Parameters = "0.12"
Expand All @@ -63,6 +64,7 @@ QuartzImageIO = "0.7"
RecursiveArrayTools = "2.17"
ReverseDiff = "1.9"
SciMLBase = "^1"
SciMLSensitivity = "^7"
SmoothingSplines = "0.3"
SpecialFunctions = "1"
StaticArrays = "1"
Expand Down
47 changes: 28 additions & 19 deletions src/ReactionMechanismSimulator.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
module ReactionMechanismSimulator
using PythonCall
ENV["JULIA_CONDAPKG_BACKEND"] = "MicroMamba"
using CondaPkg
using Logging
packages = keys(CondaPkg.current_packages())

if !("rmg" in packages) && !("rmgmolecule" in packages)
@info "missing rmg and rmgmolecule installing rmgmolecule..."
if "python" in packages
py_version = VersionNumber(CondaPkg.current_packages()["python"][:version])
else
py_version = nothing
end
if py_version === nothing || !(v"3.7" <= py_version && py_version <= v"3.9")
@info "python version was not in 3.7-3.9 changing python version"
CondaPkg.add("python"; version="3.9",resolve=false)
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541",resolve=false)
CondaPkg.add("matplotlib", channel="conda-forge",resolve=false)
CondaPkg.add("rdkit", channel="conda-forge",resolve=false)
CondaPkg.add("pydot", channel="conda-forge",resolve=false)
CondaPkg.resolve()
else
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541",resolve=false)
CondaPkg.add("matplotlib", channel="conda-forge",resolve=false)
CondaPkg.add("rdkit", channel="conda-forge",resolve=false)
CondaPkg.add("pydot", channel="conda-forge",resolve=false)
CondaPkg.resolve()
end
end

using PythonCall
const Chem = PythonCall.pynew()
const Desc = PythonCall.pynew()
const molecule = PythonCall.pynew()
Expand All @@ -17,24 +44,6 @@ const solvation = PythonCall.pynew()
const fragment = PythonCall.pynew()
const pydot = PythonCall.pynew()

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")

Pkgc = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"))
Pkgc.build("PythonCall")
end


function __init__()
PythonCall.pycopy!(Chem, pyimport("rdkit.Chem"))
PythonCall.pycopy!(Desc, pyimport("rdkit.Chem.Descriptors"))
Expand Down
43 changes: 27 additions & 16 deletions src/rmstest.jl
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
import Logging
Logging.disable_logging(Logging.Warn)

using PythonCall
using CondaPkg
const Chem = PythonCall.pynew()
const molecule = PythonCall.pynew()
const fragment = PythonCall.pynew()
const pydot = PythonCall.pynew()
ENV["JULIA_CONDAPKG_BACKEND"] = "MicroMamba"
using CondaPkg

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")
if "python" in packages
py_version = VersionNumber(CondaPkg.current_packages()["python"][:version])
else
py_version = nothing
end
if py_version === nothing || !(v"3.7" <= py_version && py_version <= v"3.9")
@info "python version was not in 3.7-3.9 changing python version"
CondaPkg.add("python"; version="3.9")
CondaPkg.add("python"; version="3.9",resolve=false)
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541",resolve=false)
CondaPkg.add("matplotlib", channel="conda-forge",resolve=false)
CondaPkg.add("rdkit", channel="conda-forge",resolve=false)
CondaPkg.add("pydot", channel="conda-forge",resolve=false)
CondaPkg.resolve()
else
CondaPkg.add("rmgmolecule"; version=">=0.3.0", channel="mjohnson541",resolve=false)
CondaPkg.add("matplotlib", channel="conda-forge",resolve=false)
CondaPkg.add("rdkit", channel="conda-forge",resolve=false)
CondaPkg.add("pydot", channel="conda-forge",resolve=false)
CondaPkg.resolve()
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")

Pkgc = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"))
Pkgc.build("PythonCall")
end

using PythonCall

const Chem = PythonCall.pynew()
const molecule = PythonCall.pynew()
const fragment = PythonCall.pynew()
const pydot = PythonCall.pynew()

PythonCall.pycopy!(Chem, pyimport("rdkit.Chem"))
try
PythonCall.pycopy!(molecule, pyimport("rmgpy.molecule"))
Expand Down

0 comments on commit e597206

Please sign in to comment.