diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 496b9834f1..bb3b8ca2f3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -73,7 +73,9 @@ jobs: - name: Compel Arm-based Mac to use x86 if: matrix.os == 'macos-latest' - run: echo "CONDA_SUBDIR=osx-64" >> $GITHUB_ENV + run: | + echo "CONDA_SUBDIR=osx-64" >> $GITHUB_ENV + # softwareupdate --install-rosetta --agree-to-license # did not help with encodings issue - name: Setup Miniforge Python ${{ matrix.python-version }} uses: conda-incubator/setup-miniconda@v3 @@ -83,15 +85,21 @@ jobs: miniforge-version: latest python-version: ${{ matrix.python-version }} activate-environment: rmg_env - use-mamba: true + auto-update-conda: true show-channel-urls: true channels: conda-forge,cantera,rmg + conda-remove-defaults: "true" + + # - name: Continue to Coerce Arm-Mac # pure python mode works without this, so it isn't required + # if: matrix.os == 'macos-latest' + # run: | + # conda config --env --set subdir osx-64 # list the environment for debugging purposes - - name: mamba info + - name: conda info run: | - mamba info - mamba list + conda info + conda list # Clone RMG-database - name: Clone RMG-database @@ -99,48 +107,68 @@ jobs: cd .. git clone -b $RMG_DATABASE_BRANCH https://github.com/ReactionMechanismGenerator/RMG-database.git - # modify env variables as directed in the RMG installation instructions - - name: Set Environment Variables - run: | - RUNNER_CWD=$(pwd) - echo "PYTHONPATH=$RUNNER_CWD/RMG-Py:$PYTHONPATH" >> $GITHUB_ENV - echo "$RUNNER_CWD/RMG-Py" >> $GITHUB_PATH + # # modify env variables as directed in the RMG installation instructions + # - name: Set Environment Variables + # run: | + # RUNNER_CWD=$(pwd) + # echo "$RUNNER_CWD/RMG-Py" >> $GITHUB_PATH # I don't think this actually accomplishes anything # RMG build step - name: make RMG run: | - make clean - make + make install - # Setup Juliaup - - name: Set Julia paths + - name: PRE-JULIA ENVIRONMENT run: | - # echo "JULIAUP_DEPOT_PATH=$CONDA/envs/rmg_env/.julia" >> $GITHUB_ENV - # echo "JULIAUP_DEPOT_PATH=$CONDA/envs/rmg_env/.julia" >> $GITHUB_PATH - # echo "JULIA_DEPOT_PATH=$CONDA/envs/rmg_env/.julia" >> $GITHUB_ENV - # echo "JULIA_DEPOT_PATH=$CONDA/envs/rmg_env/.julia" >> $GITHUB_PATH - # echo "JULIA_CONDAPKG_EXE=$CONDA/condabin/mamba" >> $GITHUB_ENV - # echo "JULIA_CONDAPKG_EXE=$CONDA/condabin/mamba" >> $GITHUB_PATH - # echo "JULIA_CONDAPKG_EXE=$CONDA/condabin/mamba" >> $GITHUB_ENV - # echo "JULIA_CONDAPKG_EXE=$CONDA/condabin/mamba" >> $GITHUB_PATH - echo "JULIA_CONDAPKG_BACKEND=Current" >> $GITHUB_ENV - # echo "JULIA_CONDAPKG_BACKEND=Current" >> $GITHUB_PATH + printenv | sort + conda list - name: Setup Juliaup uses: julia-actions/install-juliaup@v2 with: channel: '1.9' - - name: Check Julia version - run: julia --version + - name: POST JULIAUP + run: | + printenv | sort + conda list + + # - name: Try and Make Julia stop ruining the Compilers + # run: | + # echo "LD_LIBRARY_PATH=$CONDA_PREFIX/lib" >> $GITHUB_ENV + + # - name: POST LIBRARY PATH UPDATE + # run: | + # printenv | sort + # conda list + + - name: Set some env vars + run: | + echo "JULIA_CONDAPKG_BACKEND=Null" >> $GITHUB_ENV + echo "JULIA_PYTHONCALL_EXE=$CONDA_PREFIX/bin/python" >> $GITHUB_ENV # RMS installation and linking to Julia - name: Install and link Julia dependencies timeout-minutes: 120 # this usually takes 20-45 minutes (or hangs for 6+ hours). - # JULIA_CONDAPKG_EXE points to the existing conda/mamba to avoid JuliaCall from installing their own. See https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-a-Conda-environment. + run: . install_rms.sh + + - name: Where is RMS? + run: julia -E "using ReactionMechanismSimulator; pathof(ReactionMechanismSimulator)" + + - name: Set some other env vars run: | - mamba install conda-forge::pyjuliacall - julia -e 'using Pkg; Pkg.add(Pkg.PackageSpec(name="ReactionMechanismSimulator", url="https://github.com/hwpang/ReactionMechanismSimulator.jl.git", rev="fix_installation")); using ReactionMechanismSimulator' + echo "PYTHON_JULIAPKG_EXE=$(which julia)" >> $GITHUB_ENV + echo "PYTHON_JULIAPKG_PROJECT=$HOME/.julia/packages" >> $GITHUB_ENV + + - name: POST-JULIA ENVIRONMENT + run: | + printenv | sort + conda list + + # - name: Rebuild RMG + # run: | + # make clean + # make - name: Install Q2DTor run: echo "" | make q2dtor @@ -322,14 +350,14 @@ jobs: - name: Upload regression summary artifact # the annotate workflow uses this artifact to add a comment to the PR - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if : ${{ github.event_name == 'pull_request' }} with: name: regression_summary path: summary.txt - name: Upload Comparison Results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: regression_test_comparison_results path: | @@ -339,7 +367,7 @@ jobs: - name: Code coverage install and run if: success() || ( failure() && steps.regression-execution.conclusion == 'success' ) run: | - mamba install -y -c conda-forge codecov + conda install -y -c conda-forge codecov codecov build-and-push-docker: diff --git a/.github/workflows/pure_python_ci.yml b/.github/workflows/pure_python_ci.yml index 9cc0d88e10..e40d42068f 100644 --- a/.github/workflows/pure_python_ci.yml +++ b/.github/workflows/pure_python_ci.yml @@ -55,15 +55,16 @@ jobs: miniforge-version: latest python-version: ${{ matrix.python-version }} activate-environment: rmg_env - use-mamba: true + auto-update-conda: true show-channel-urls: true channels: conda-forge,cantera,rmg + conda-remove-defaults: "true" # list the environment for debugging purposes - - name: mamba info + - name: conda info run: | - mamba info - mamba list + conda info + conda list # Clone RMG-database - name: Clone RMG-database @@ -71,13 +72,6 @@ jobs: cd .. git clone -b $RMG_DATABASE_BRANCH https://github.com/ReactionMechanismGenerator/RMG-database.git - # modify env variables as directed in the RMG installation instructions - - name: Set Environment Variables - run: | - RUNNER_CWD=$(pwd) - echo "PYTHONPATH=$RUNNER_CWD/RMG-Py:$PYTHONPATH" >> $GITHUB_ENV - echo "$RUNNER_CWD/RMG-Py" >> $GITHUB_PATH - # RMG build step - name: make RMG run: | diff --git a/.gitignore b/.gitignore index 38d73e2bc1..723a18e5cb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ # ################################################################################ +# build dir +reactionmechanismgenerator.egg-info/ + # MacOS files .DS_Store @@ -11,6 +14,8 @@ *.pyc *.so *.pyd +# and intermediate source files +*.c # Image files generated by RMG *.png diff --git a/Makefile b/Makefile index 06055daa3a..6ccdf07af8 100644 --- a/Makefile +++ b/Makefile @@ -7,28 +7,14 @@ CC=gcc CXX=g++ -.PHONY : all minimal main solver check pycheck arkane clean install decython documentation test q2dtor +.PHONY : all check clean install decython documentation test q2dtor -all: pycheck main solver check - -minimal: - python setup.py build_ext minimal --inplace --build-temp . - -main: - python setup.py build_ext main --inplace --build-temp . - -solver: - @ python utilities.py check-pydas - python setup.py build_ext solver --inplace --build-temp . - -arkane: - python setup.py build_ext arkane --inplace --build-temp . +all: check install check check: @ python utilities.py check-dependencies - -pycheck: @ python utilities.py check-python + @ python utilities.py check-pydas documentation: $(MAKE) -C documentation html @@ -42,7 +28,7 @@ clean-solver: install: @ python utilities.py check-pydas - python setup.py install + python -m pip install -vv --no-cache-dir -e . q2dtor: @ echo -e "\nInstalling Q2DTor...\n" diff --git a/arkane/encorr/data.py b/arkane/encorr/data.py index d96e292048..cb27decd2a 100644 --- a/arkane/encorr/data.py +++ b/arkane/encorr/data.py @@ -54,6 +54,8 @@ from arkane.exceptions import BondAdditivityCorrectionError from arkane.modelchem import LevelOfTheory, CompositeLevelOfTheory +pybel.ob.obErrorLog.SetOutputLevel(0) + # ######## Database loading ########## quantum_corrections_path = os.path.join(settings['database.directory'], 'quantum_corrections', 'data.py') spec = importlib.util.spec_from_file_location("quantum_calculations", quantum_corrections_path) diff --git a/install_rms.sh b/install_rms.sh new file mode 100644 index 0000000000..ee64604f7e --- /dev/null +++ b/install_rms.sh @@ -0,0 +1,24 @@ +# manual installation steps +# start by installing juliaup on your system globally +# curl -fsSL https://install.julialang.org | sh +# # restart shell +# juliaup add 1.9 +# juliaup default 1.9 +# juliaup remove release + +# actual steps +conda install -y conda-forge::pyjuliacall # conda-forge::pyside2 +# export JULIA_CONDAPKG_BACKEND=Current +# export JULIA_CONDAPKG_EXE=$CONDA_EXE +# export JULIA_PYTHONCALL_EXE=$CONDA_PREFIX/bin/python + +# https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-Python-and-required-Python-packages-installed +export JULIA_CONDAPKG_BACKEND=Null +export JULIA_PYTHONCALL_EXE=$CONDA_PREFIX/bin/python +# export MPLBACKEND=tkagg # supported backend for PythonPlot.jl, needed by RMS + +julia -e 'using Pkg; Pkg.add(Pkg.PackageSpec(name="ReactionMechanismSimulator", url="https://github.com/hwpang/ReactionMechanismSimulator.jl.git", rev="fix_installation")); using ReactionMechanismSimulator; Pkg.instantiate()' | echo "RMS install error - continuing anyway ¯\_(ツ)_/¯" + +# ensure that juliacall in Python uses the correct julia executable and packages: https://github.com/JuliaPy/PyJuliaPkg?tab=readme-ov-file#which-julia-gets-used +export PYTHON_JULIAPKG_EXE=$(which julia) +export PYTHON_JULIAPKG_PROJECT=$HOME/.julia/packages diff --git a/rmgpy/rmg/reactionmechanismsimulator_reactors.py b/rmgpy/rmg/reactionmechanismsimulator_reactors.py index f40ba703d6..77b0ffb8b0 100644 --- a/rmgpy/rmg/reactionmechanismsimulator_reactors.py +++ b/rmgpy/rmg/reactionmechanismsimulator_reactors.py @@ -32,32 +32,13 @@ """ import itertools import logging -import sys import numpy as np -import rmgpy.constants as constants - -NO_JULIA = True -try: - import juliacall - from juliacall import Main - Main.seval("using PythonCall") - Main.seval("using ReactionMechanismSimulator") - Main.seval("using ReactionMechanismSimulator.Sundials") - NO_JULIA = False -except: - logging.warning("Julia import failed, RMS reactors not available.") - -from rmgpy import constants -from rmgpy.data.kinetics.depository import DepositoryReaction -from rmgpy.data.kinetics.family import TemplateReaction from rmgpy.data.solvation import SolventData from rmgpy.kinetics.arrhenius import ( Arrhenius, - ArrheniusBM, ArrheniusChargeTransfer, - ArrheniusEP, Marcus, MultiArrhenius, MultiPDepArrhenius, @@ -65,7 +46,6 @@ ) from rmgpy.kinetics.chebyshev import Chebyshev from rmgpy.kinetics.falloff import Lindemann, ThirdBody, Troe -from rmgpy.kinetics.kineticsdata import KineticsData from rmgpy.kinetics.surface import StickingCoefficient, SurfaceChargeTransfer from rmgpy.molecule.fragment import Fragment from rmgpy.reaction import Reaction @@ -77,7 +57,17 @@ from rmgpy.species import Species from rmgpy.thermo.nasa import NASA, NASAPolynomial from rmgpy.thermo.thermodata import ThermoData -from rmgpy.thermo.wilhoit import Wilhoit + + +NO_JULIA = True +try: + from juliacall import Main + Main.seval("using PythonCall") + Main.seval("using ReactionMechanismSimulator") + Main.seval("using ReactionMechanismSimulator.Sundials") + NO_JULIA = False +except Exception as e: + logging.warning(f"Julia import failed, RMS reactors not available.\nException: {str(e)}\nStacktrace:\n{e.__traceback__}") def to_julia(obj): @@ -104,21 +94,6 @@ def to_julia(obj): else: # Other native Python project does not need special conversion. return obj -NO_JULIA = False -try: - if __debug__: - from os.path import abspath, dirname, exists, join - - from julia.api import Julia - path_rms = dirname(dirname(dirname(abspath(__file__)))) - jl = Julia(sysimage=join(path_rms, "rms.so")) if exists(join(path_rms, "rms.so")) else Julia(compiled_modules=False) - from diffeqpy import de - from julia import Main - from pyrms import rms -except Exception as e: - logging.info("Unable to import Julia dependencies, original error: " + str(e) + ". RMS features will not be available on this execution.") - NO_JULIA = True - class PhaseSystem: """ diff --git a/setup.py b/setup.py index 604a856eb1..4bebd5a556 100644 --- a/setup.py +++ b/setup.py @@ -27,16 +27,7 @@ # # ############################################################################### -import sys -import os -from collections import OrderedDict - -try: - from distutils.core import setup - from distutils.extension import Extension -except ImportError: - print('The distutils package is required to build or install RMG Py.') - raise +from setuptools import setup try: from Cython.Build import cythonize @@ -51,8 +42,10 @@ print('NumPy (http://numpy.scipy.org/) is required to build or install RMG Py.') raise +from setuptools import find_packages + # Create annotated HTML files for each of the Cython modules -Options.annotate = True +Options.annotate = False directives = { # Set input language version to python 3 @@ -63,143 +56,68 @@ # 'embedsignature': True, } -################################################################################ - -main_ext_modules = [ +ext_modules = [ # RMG - Extension('rmgpy.rmgobject', ['rmgpy/rmgobject.pyx']), + 'rmgpy/rmgobject.pyx', # Kinetics - Extension('rmgpy.kinetics.arrhenius', ['rmgpy/kinetics/arrhenius.pyx']), - Extension('rmgpy.kinetics.chebyshev', ['rmgpy/kinetics/chebyshev.pyx']), - Extension('rmgpy.kinetics.kineticsdata', ['rmgpy/kinetics/kineticsdata.pyx']), - Extension('rmgpy.kinetics.falloff', ['rmgpy/kinetics/falloff.pyx']), - Extension('rmgpy.kinetics.model', ['rmgpy/kinetics/model.pyx']), - Extension('rmgpy.kinetics.tunneling', ['rmgpy/kinetics/tunneling.pyx']), - Extension('rmgpy.kinetics.surface', ['rmgpy/kinetics/surface.pyx']), - Extension('rmgpy.kinetics.uncertainties', ['rmgpy/kinetics/uncertainties.pyx']), + 'rmgpy/kinetics/arrhenius.pyx', + 'rmgpy/kinetics/chebyshev.pyx', + 'rmgpy/kinetics/kineticsdata.pyx', + 'rmgpy/kinetics/falloff.pyx', + 'rmgpy/kinetics/model.pyx', + 'rmgpy/kinetics/tunneling.pyx', + 'rmgpy/kinetics/surface.pyx', + 'rmgpy/kinetics/uncertainties.pyx', # Molecules and molecular representations - Extension('rmgpy.molecule.atomtype', ['rmgpy/molecule/atomtype.py'], include_dirs=['.']), - Extension('rmgpy.molecule.element', ['rmgpy/molecule/element.py'], include_dirs=['.']), - Extension('rmgpy.molecule.graph', ['rmgpy/molecule/graph.pyx'], include_dirs=['.']), - Extension('rmgpy.molecule.group', ['rmgpy/molecule/group.py'], include_dirs=['.']), - Extension('rmgpy.molecule.molecule', ['rmgpy/molecule/molecule.py'], include_dirs=['.']), - Extension('rmgpy.molecule.symmetry', ['rmgpy/molecule/symmetry.py'], include_dirs=['.']), - Extension('rmgpy.molecule.vf2', ['rmgpy/molecule/vf2.pyx'], include_dirs=['.']), - Extension('rmgpy.molecule.converter', ['rmgpy/molecule/converter.py'], include_dirs=['.']), - Extension('rmgpy.molecule.translator', ['rmgpy/molecule/translator.py'], include_dirs=['.']), - Extension('rmgpy.molecule.util', ['rmgpy/molecule/util.py'], include_dirs=['.']), - Extension('rmgpy.molecule.inchi', ['rmgpy/molecule/inchi.py'], include_dirs=['.']), - Extension('rmgpy.molecule.resonance', ['rmgpy/molecule/resonance.py'], include_dirs=['.']), - Extension('rmgpy.molecule.pathfinder', ['rmgpy/molecule/pathfinder.py'], include_dirs=['.']), - Extension('rmgpy.molecule.kekulize', ['rmgpy/molecule/kekulize.pyx'], include_dirs=['.']), - # Pressure dependence - Extension('rmgpy.pdep.collision', ['rmgpy/pdep/collision.pyx']), - Extension('rmgpy.pdep.configuration', ['rmgpy/pdep/configuration.pyx']), - Extension('rmgpy.pdep.me', ['rmgpy/pdep/me.pyx']), - Extension('rmgpy.pdep.msc', ['rmgpy/pdep/msc.pyx']), - Extension('rmgpy.pdep.reaction', ['rmgpy/pdep/reaction.pyx']), - Extension('rmgpy.pdep.rs', ['rmgpy/pdep/rs.pyx']), - Extension('rmgpy.pdep.cse', ['rmgpy/pdep/cse.pyx']), - # Statistical mechanics - Extension('rmgpy.statmech.conformer', ['rmgpy/statmech/conformer.pyx']), - Extension('rmgpy.statmech.mode', ['rmgpy/statmech/mode.pyx']), - Extension('rmgpy.statmech.rotation', ['rmgpy/statmech/rotation.pyx']), - Extension('rmgpy.statmech.schrodinger', ['rmgpy/statmech/schrodinger.pyx']), - Extension('rmgpy.statmech.torsion', ['rmgpy/statmech/torsion.pyx']), - Extension('rmgpy.statmech.translation', ['rmgpy/statmech/translation.pyx']), - Extension('rmgpy.statmech.vibration', ['rmgpy/statmech/vibration.pyx']), - # Thermodynamics - Extension('rmgpy.thermo.thermodata', ['rmgpy/thermo/thermodata.pyx']), - Extension('rmgpy.thermo.model', ['rmgpy/thermo/model.pyx']), - Extension('rmgpy.thermo.nasa', ['rmgpy/thermo/nasa.pyx']), - Extension('rmgpy.thermo.wilhoit', ['rmgpy/thermo/wilhoit.pyx']), - # Miscellaneous - Extension('rmgpy.constants', ['rmgpy/constants.py'], include_dirs=['.']), - Extension('rmgpy.quantity', ['rmgpy/quantity.py'], include_dirs=['.']), - Extension('rmgpy.reaction', ['rmgpy/reaction.py'], include_dirs=['.']), - Extension('rmgpy.species', ['rmgpy/species.py'], include_dirs=['.']), - Extension('rmgpy.chemkin', ['rmgpy/chemkin.pyx'], include_dirs=['.']), -] - -solver_ext_modules = [ - Extension('rmgpy.solver.base', ['rmgpy/solver/base.pyx'], include_dirs=['.']), - Extension('rmgpy.solver.simple', ['rmgpy/solver/simple.pyx'], include_dirs=['.']), - Extension('rmgpy.solver.liquid', ['rmgpy/solver/liquid.pyx'], include_dirs=['.']), - Extension('rmgpy.solver.mbSampled', ['rmgpy/solver/mbSampled.pyx'], include_dirs=['.']), - Extension('rmgpy.solver.surface', ['rmgpy/solver/surface.pyx'], include_dirs=['.']), -] - -arkane_ext_modules = [ - # RMG - Extension('rmgpy.rmgobject', ['rmgpy/rmgobject.pyx']), - # Kinetics - Extension('rmgpy.kinetics.arrhenius', ['rmgpy/kinetics/arrhenius.pyx']), - Extension('rmgpy.kinetics.chebyshev', ['rmgpy/kinetics/chebyshev.pyx']), - Extension('rmgpy.kinetics.kineticsdata', ['rmgpy/kinetics/kineticsdata.pyx']), - Extension('rmgpy.kinetics.falloff', ['rmgpy/kinetics/falloff.pyx']), - Extension('rmgpy.kinetics.model', ['rmgpy/kinetics/model.pyx']), - Extension('rmgpy.kinetics.tunneling', ['rmgpy/kinetics/tunneling.pyx']), + 'rmgpy/molecule/atomtype.py', + 'rmgpy/molecule/element.py', + 'rmgpy/molecule/graph.pyx', + 'rmgpy/molecule/group.py', + 'rmgpy/molecule/molecule.py', + 'rmgpy/molecule/symmetry.py', + 'rmgpy/molecule/vf2.pyx', + 'rmgpy/molecule/converter.py', + 'rmgpy/molecule/translator.py', + 'rmgpy/molecule/util.py', + 'rmgpy/molecule/inchi.py', + 'rmgpy/molecule/resonance.py', + 'rmgpy/molecule/pathfinder.py', + 'rmgpy/molecule/kekulize.pyx', # Pressure dependence - Extension('rmgpy.pdep.collision', ['rmgpy/pdep/collision.pyx']), - Extension('rmgpy.pdep.configuration', ['rmgpy/pdep/configuration.pyx']), - Extension('rmgpy.pdep.me', ['rmgpy/pdep/me.pyx']), - Extension('rmgpy.pdep.msc', ['rmgpy/pdep/msc.pyx']), - Extension('rmgpy.pdep.reaction', ['rmgpy/pdep/reaction.pyx']), - Extension('rmgpy.pdep.rs', ['rmgpy/pdep/rs.pyx']), - Extension('rmgpy.pdep.cse', ['rmgpy/pdep/cse.pyx']), + 'rmgpy/pdep/collision.pyx', + 'rmgpy/pdep/configuration.pyx', + 'rmgpy/pdep/me.pyx', + 'rmgpy/pdep/msc.pyx', + 'rmgpy/pdep/reaction.pyx', + 'rmgpy/pdep/rs.pyx', + 'rmgpy/pdep/cse.pyx', # Statistical mechanics - Extension('rmgpy.statmech.conformer', ['rmgpy/statmech/conformer.pyx']), - Extension('rmgpy.statmech.mode', ['rmgpy/statmech/mode.pyx']), - Extension('rmgpy.statmech.rotation', ['rmgpy/statmech/rotation.pyx']), - Extension('rmgpy.statmech.schrodinger', ['rmgpy/statmech/schrodinger.pyx']), - Extension('rmgpy.statmech.torsion', ['rmgpy/statmech/torsion.pyx']), - Extension('rmgpy.statmech.translation', ['rmgpy/statmech/translation.pyx']), - Extension('rmgpy.statmech.vibration', ['rmgpy/statmech/vibration.pyx']), + 'rmgpy/statmech/conformer.pyx', + 'rmgpy/statmech/mode.pyx', + 'rmgpy/statmech/rotation.pyx', + 'rmgpy/statmech/schrodinger.pyx', + 'rmgpy/statmech/torsion.pyx', + 'rmgpy/statmech/translation.pyx', + 'rmgpy/statmech/vibration.pyx', # Thermodynamics - Extension('rmgpy.thermo.thermodata', ['rmgpy/thermo/thermodata.pyx']), - Extension('rmgpy.thermo.model', ['rmgpy/thermo/model.pyx']), - Extension('rmgpy.thermo.nasa', ['rmgpy/thermo/nasa.pyx']), - Extension('rmgpy.thermo.wilhoit', ['rmgpy/thermo/wilhoit.pyx']), + 'rmgpy/thermo/thermodata.pyx', + 'rmgpy/thermo/model.pyx', + 'rmgpy/thermo/nasa.pyx', + 'rmgpy/thermo/wilhoit.pyx', # Miscellaneous - Extension('rmgpy.constants', ['rmgpy/constants.py'], include_dirs=['.']), - Extension('rmgpy.quantity', ['rmgpy/quantity.py'], include_dirs=['.']), + 'rmgpy/constants.py', + 'rmgpy/quantity.py', + 'rmgpy/reaction.py', + 'rmgpy/species.py', + 'rmgpy/chemkin.pyx', + # solvers + 'rmgpy/solver/base.pyx', + 'rmgpy/solver/simple.pyx', + 'rmgpy/solver/liquid.pyx', + 'rmgpy/solver/mbSampled.pyx', + 'rmgpy/solver/surface.pyx', ] -################################################################################ - -ext_modules = [] -if 'install' in sys.argv: - # This is so users can still do simply `python setup.py install` - ext_modules.extend(main_ext_modules) - ext_modules.extend(solver_ext_modules) -if 'main' in sys.argv: - # This is for `python setup.py build_ext main` - sys.argv.remove('main') - ext_modules.extend(main_ext_modules) -if 'solver' in sys.argv: - # This is for `python setup.py build_ext solver` - sys.argv.remove('solver') - ext_modules.extend(solver_ext_modules) -if 'arkane' in sys.argv: - # This is for `python setup.py build_ext arkane` - sys.argv.remove('arkane') - ext_modules.extend(main_ext_modules) - ext_modules.extend(arkane_ext_modules) -if 'minimal' in sys.argv: - # This starts with the full install list, but removes anything that has a pure python mode - # i.e. in only includes things whose source is .pyx - sys.argv.remove('minimal') - temporary_list = [] - temporary_list.extend(main_ext_modules) - temporary_list.extend(solver_ext_modules) - for module in temporary_list: - for source in module.sources: - if os.path.splitext(source)[1] == '.pyx': - ext_modules.append(module) - -# Remove duplicates while preserving order: -ext_modules = list(OrderedDict.fromkeys(ext_modules)) - scripts = [ 'Arkane.py', 'rmg.py', @@ -215,41 +133,27 @@ 'scripts/standardizeModelSpeciesNames.py', 'scripts/thermoEstimator.py', 'scripts/isotopes.py', - 'testing/databaseTest.py', ] -modules = [] -for root, dirs, files in os.walk('rmgpy'): - if 'test_data' in root: - continue - for f in files: - if f.endswith('.py') or f.endswith('.pyx'): - if 'Test' not in f and '__init__' not in f: - module = 'rmgpy' + root.partition('rmgpy')[-1].replace('/', '.') + '.' + f.partition('.py')[0] - modules.append(module) -for root, dirs, files in os.walk('arkane'): - if 'data' in root: - continue - for f in files: - if f.endswith('.py') or f.endswith('.pyx'): - if 'Test' not in f and '__init__' not in f: - module = 'arkane' + root.partition('arkane')[-1].replace('/', '.') + '.' + f.partition('.py')[0] - modules.append(module) - # Read the version number exec(open('rmgpy/version.py').read()) # Initiate the build and/or installation setup( - name='RMG-Py', + name='reactionmechanismgenerator', version=__version__, description='Reaction Mechanism Generator', author='William H. Green and the RMG Team', author_email='rmg_dev@mit.edu', url='http://reactionmechanismgenerator.github.io', - packages=['rmgpy', 'arkane'], - py_modules=modules, + python_requires='>=3.9,<3.10', + packages=find_packages(where='.', include=["rmgpy*"]) + find_packages(where='.', include=["arkane*"]), scripts=scripts, - ext_modules=cythonize(ext_modules, build_dir='build', compiler_directives=directives), - include_dirs=['.', numpy.get_include()], + include_package_data=True, + package_data={ + "": ["*.pxd"], + }, + ext_modules=cythonize(ext_modules, compiler_directives=directives), + include_dirs=numpy.get_include(), + install_requires=["Cython", "numpy"], ) diff --git a/test/conftest.py b/test/conftest.py new file mode 100644 index 0000000000..e31c2d0649 --- /dev/null +++ b/test/conftest.py @@ -0,0 +1,3 @@ +import multiprocessing + +multiprocessing.set_start_method('fork') diff --git a/utilities.py b/utilities.py index 87d39e7384..757d678d97 100644 --- a/utilities.py +++ b/utilities.py @@ -253,7 +253,7 @@ def clean(subdirectory=''): if platform.system() == 'Windows': extensions = ['.pyd', '.pyc'] else: - extensions = ['.so', '.pyc'] + extensions = ['.so', '.pyc', ".c"] # Remove temporary build files print('Removing build directory...')