From 7d4c8cfdb7edce7343408a8cc98066ac2ec4e230 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 30 Aug 2023 23:02:43 +0530 Subject: [PATCH 01/95] #3049 initial draft: metadata, dependencies, extras, entry points --- pyproject.toml | 172 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..3e1ad42e76 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,172 @@ +# From the pip documentation: + +# Fallback Behaviour +# If a project does not have a pyproject.toml file containing a build-system section, +# it will be assumed to have the following backend settings: + +# [build-system] +# requires = ["setuptools>=40.8.0", "wheel"] +# build-backend = "setuptools.build_meta:__legacy__" + +# TODO: add appropriate build-system section +[build-system] +# TODO: specify minimum version of setuptools otherwise scikits.odes, NumPy, and others +# will fail to install +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "pybamm" +# TODO: try picking up version from the package itself +# dynamic = ["version", "readme"] +# [tool.setuptools.dynamic] +# version = {attr = "my_package.VERSION"} +version = "23.5" +# Unsure: specify BSD-3-Clause? +# license = {text = "BSD-3-Clause"} +license = { file = "LICENCE.txt" } + +# TODO: add appropriate long description +description = "Python Battery Mathematical Modelling" + +# TODO: correctly specify all authors and maintainers +# Note: these are currently missing when running `pip show pybamm`, so we should add +# them in some form +authors = [{name = "The PyBaMM Team"}] +maintainers = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] +requires-python = ">=3.8, <3.12" +readme = "README.md" + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering", +] + +dependencies = [ + "numpy>=1.16", + "scipy>=1.3", + "casadi>=3.6.0", + "xarray", +] + +[project.optional-dependencies] +# For the generation of documentation +docs = [ + "sphinx>=6", + "sphinx_rtd_theme>=0.5", + "pydata-sphinx-theme", + "sphinx_design", + "sphinx-copybutton", + "myst-parser", + "sphinx-inline-tabs", + "sphinxcontrib-bibtex", + "sphinx-autobuild", + "sphinx-last-updated-by-git", + "nbsphinx", + "ipykernel", + "ipywidgets", + "sphinx-gallery", + "sphinx-hoverxref", + "sphinx-docsearch", +] +# For example notebooks +examples = [ + "jupyter", +] +# Plotting functionality +plot = [ + "imageio>=2.9.0", + # Note: Matplotlib is loaded for debug plots, but to ensure pybamm runs + # on systems without an attached display, it should never be imported + # outside of plot() methods. + "matplotlib>=2.0", +] +# For the Citations class +cite = [ + "pybtex>=0.24.0", +] +# To generate LaTeX strings +latexify = [ + "sympy>=1.8", +] +# Battery Parameter eXchange format +bpx = [ + "bpx", +] +# Low-overhead progress bars +tqdm = [ + "tqdm", +] +# Dependencies intended for use by developers +dev = [ + # For code style checking + "pre-commit", + # For code style auto-formatting + "ruff", + # For running testing sessions + "nox", +] +# Reading CSV files +pandas = [ + "pandas>=0.24", +] +# For the Jax solver +jax = [ + "jax==0.4.8", + "jaxlib==0.4.7", +] +# For the scikits.odes solver +odes = [ + "scikits.odes" +] +# Contains all optional dependencies, except for odes, jax, and dev dependencies +all = [ + "anytree>=2.4.3", + "autograd>=1.2", + "pandas>=0.24", + "scikit-fem>=0.2.0", + "imageio>=2.9.0", + "matplotlib>=2.0", + "pybtex>=0.24.0", + "sympy>=1.8", + "bpx", + "tqdm", + "jupyter", +] + +# Equivalent to the console scripts in the entry_points section of the setup() +# function in setup.py +[project.scripts] +pybamm_edit_parameter = "pybamm.parameters_cli:edit_parameter" +pybamm_add_parameter = "pybamm.parameters_cli:add_parameter" +pybamm_rm_parameter = "pybamm.parameters_cli:remove_parameter" +pybamm_install_odes = "pybamm.install_odes:main" +pybamm_install_jax = "pybamm.util:install_jax" + +# Equivalent to the "pybamm_parameter_sets" entry_points section of the setup() +# function in setup.py +[project.entry-points."pybamm_parameter_sets"] +Sulzer2019 = "pybamm.input.parameters.lead_acid.Sulzer2019:get_parameter_values" +Ai2020 = "pybamm.input.parameters.lithium_ion.Ai2020:get_parameter_values" +Chen2020 = "pybamm.input.parameters.lithium_ion.Chen2020:get_parameter_values" +Chen2020_composite = "pybamm.input.parameters.lithium_ion.Chen2020_composite:get_parameter_values" +Ecker2015 = "pybamm.input.parameters.lithium_ion.Ecker2015:get_parameter_values" +Marquis2019 = "pybamm.input.parameters.lithium_ion.Marquis2019:get_parameter_values" +Mohtat2020 = "pybamm.input.parameters.lithium_ion.Mohtat2020:get_parameter_values" +NCA_Kim2011 = "pybamm.input.parameters.lithium_ion.NCA_Kim2011:get_parameter_values" +OKane2022 = "pybamm.input.parameters.lithium_ion.OKane2022:get_parameter_values" +ORegan2022 = "pybamm.input.parameters.lithium_ion.ORegan2022:get_parameter_values" +Prada2013 = "pybamm.input.parameters.lithium_ion.Prada2013:get_parameter_values" +Ramadass2004 = "pybamm.input.parameters.lithium_ion.Ramadass2004:get_parameter_values" +Xu2019 = "pybamm.input.parameters.lithium_ion.Xu2019:get_parameter_values" +ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" From aca9a6a553022f7bbcf47960b1899da40d0c1b9a Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 30 Aug 2023 23:05:36 +0530 Subject: [PATCH 02/95] #3049 Fix LICENSE spelling --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3e1ad42e76..5ff07e93e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ name = "pybamm" version = "23.5" # Unsure: specify BSD-3-Clause? # license = {text = "BSD-3-Clause"} -license = { file = "LICENCE.txt" } +license = { file = "LICENSE.txt" } # TODO: add appropriate long description description = "Python Battery Mathematical Modelling" From 3af50925654220757fc7fdfcf906784ea30cf938 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 30 Aug 2023 23:22:10 +0530 Subject: [PATCH 03/95] #3049 Temporarily build wheels on pull requests --- .github/workflows/publish_pypi.yml | 79 ++++++++++++++++-------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 6d89da1387..ba693ec88e 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -1,13 +1,16 @@ -name: Build and publish package to PyPI - +# name: Build and publish package to PyPI +name: Test building wheels on Windows, GNU/Linux and macOS +# Temporarily disable publishing to PyPI and enable +# building wheels on pull requests on: - push: - branches: main + # push: + # branches: main + pull_request: workflow_dispatch: inputs: - target: - description: 'Deployment target. Can be "pypi" or "testpypi"' - default: "pypi" + # target: + # description: 'Deployment target. Can be "pypi" or "testpypi"' + # default: "pypi" debug_enabled: type: boolean description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' @@ -153,34 +156,34 @@ jobs: path: ./dist/*.tar.gz if-no-files-found: error - publish_pypi: - name: Upload package to PyPI - needs: [build_wheels, build_windows_wheels, build_sdist] - runs-on: ubuntu-latest - steps: - - name: Download all artifacts - uses: actions/download-artifact@v3 - - - name: Move all package files to files/ - run: | - mkdir files - mv windows_wheels/* wheels/* sdist/* files/ - - - name: Publish on PyPI - if: | - github.event.inputs.target == 'pypi' || - (github.event_name == 'push' && github.ref == 'refs/heads/main') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} - packages_dir: files/ - - - name: Publish on TestPyPI - if: github.event.inputs.target == 'testpypi' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.TESTPYPI_TOKEN }} - packages_dir: files/ - repository_url: https://test.pypi.org/legacy/ + # publish_pypi: + # name: Upload package to PyPI + # needs: [build_wheels, build_windows_wheels, build_sdist] + # runs-on: ubuntu-latest + # steps: + # - name: Download all artifacts + # uses: actions/download-artifact@v3 + + # - name: Move all package files to files/ + # run: | + # mkdir files + # mv windows_wheels/* wheels/* sdist/* files/ + + # - name: Publish on PyPI + # if: | + # github.event.inputs.target == 'pypi' || + # (github.event_name == 'push' && github.ref == 'refs/heads/main') + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # user: __token__ + # password: ${{ secrets.PYPI_TOKEN }} + # packages_dir: files/ + + # - name: Publish on TestPyPI + # if: github.event.inputs.target == 'testpypi' + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # user: __token__ + # password: ${{ secrets.TESTPYPI_TOKEN }} + # packages_dir: files/ + # repository_url: https://test.pypi.org/legacy/ From 8768ed7f3d8814aa778f259030703bba0c8ba93c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 30 Aug 2023 23:37:11 +0530 Subject: [PATCH 04/95] #3049 Add CMakeBuild steps to `setup.py` instead of importing it --- setup.py | 295 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 173 insertions(+), 122 deletions(-) diff --git a/setup.py b/setup.py index dfdd455a16..1917b62728 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import os +import sys import glob import logging import subprocess @@ -13,12 +14,173 @@ from distutils.core import setup, find_packages from distutils.command.install import install -import CMakeBuild +# import CMakeBuild + +# ---------- cmakebuild was integrated into setup.py directly -------------------------- + +try: + from setuptools.command.build_ext import build_ext +except ImportError: + from distutils.command.build_ext import build_ext default_lib_dir = ( "" if system() == "Windows" else os.path.join(os.getenv("HOME"), ".local") ) + +def set_vcpkg_environment_variables(): + if not os.getenv("VCPKG_ROOT_DIR"): + raise EnvironmentError("Environment variable 'VCPKG_ROOT_DIR' is undefined.") + if not os.getenv("VCPKG_DEFAULT_TRIPLET"): + raise EnvironmentError( + "Environment variable 'VCPKG_DEFAULT_TRIPLET' is undefined." + ) + if not os.getenv("VCPKG_FEATURE_FLAGS"): + raise EnvironmentError( + "Environment variable 'VCPKG_FEATURE_FLAGS' is undefined." + ) + return ( + os.getenv("VCPKG_ROOT_DIR"), + os.getenv("VCPKG_DEFAULT_TRIPLET"), + os.getenv("VCPKG_FEATURE_FLAGS"), + ) + + +class CMakeBuild(build_ext): + user_options = build_ext.user_options + [ + ("suitesparse-root=", None, "suitesparse source location"), + ("sundials-root=", None, "sundials source location"), + ] + + def initialize_options(self): + build_ext.initialize_options(self) + self.suitesparse_root = None + self.sundials_root = None + + def finalize_options(self): + build_ext.finalize_options(self) + # Determine the calling command to get the + # undefined options from. + # If build_ext was called directly then this + # doesn't matter. + try: + self.get_finalized_command("install", create=0) + calling_cmd = "install" + except AttributeError: + calling_cmd = "bdist_wheel" + self.set_undefined_options( + calling_cmd, + ("suitesparse_root", "suitesparse_root"), + ("sundials_root", "sundials_root"), + ) + if not self.suitesparse_root: + self.suitesparse_root = os.path.join(default_lib_dir) + if not self.sundials_root: + self.sundials_root = os.path.join(default_lib_dir) + + def get_build_directory(self): + # distutils outputs object files in directory self.build_temp + # (typically build/temp.*). This is our CMake build directory. + # On Windows, distutils is too smart and appends "Release" or + # "Debug" to self.build_temp. So in this case we want the + # build directory to be the parent directory. + if system() == "Windows": + return Path(self.build_temp).parents[0] + return self.build_temp + + def run(self): + if not self.extensions: + return + + if system() == "Windows": + use_python_casadi = False + else: + use_python_casadi = True + + build_type = os.getenv("PYBAMM_CPP_BUILD_TYPE", "RELEASE") + cmake_args = [ + "-DCMAKE_BUILD_TYPE={}".format(build_type), + "-DPYTHON_EXECUTABLE={}".format(sys.executable), + "-DUSE_PYTHON_CASADI={}".format("TRUE" if use_python_casadi else "FALSE"), + ] + if self.suitesparse_root: + cmake_args.append( + "-DSuiteSparse_ROOT={}".format(os.path.abspath(self.suitesparse_root)) + ) + if self.sundials_root: + cmake_args.append( + "-DSUNDIALS_ROOT={}".format(os.path.abspath(self.sundials_root)) + ) + + build_dir = self.get_build_directory() + if not os.path.exists(build_dir): + os.makedirs(build_dir) + + # The CMakeError.log file is generated by cmake is the configure step + # encounters error. In the following the existence of this file is used + # to determine whether or not the cmake configure step went smoothly. + # So must make sure this file does not remain from a previous failed build. + if os.path.isfile(os.path.join(build_dir, "CMakeError.log")): + os.remove(os.path.join(build_dir, "CMakeError.log")) + + build_env = os.environ + if os.getenv("PYBAMM_USE_VCPKG"): + ( + vcpkg_root_dir, + vcpkg_default_triplet, + vcpkg_feature_flags, + ) = set_vcpkg_environment_variables() + build_env["vcpkg_root_dir"] = vcpkg_root_dir + build_env["vcpkg_default_triplet"] = vcpkg_default_triplet + build_env["vcpkg_feature_flags"] = vcpkg_feature_flags + + cmake_list_dir = os.path.abspath(os.path.dirname(__file__)) + print("-" * 10, "Running CMake for idaklu solver", "-" * 40) + subprocess.run( + ["cmake", cmake_list_dir] + cmake_args, cwd=build_dir, env=build_env + ) + + if os.path.isfile(os.path.join(build_dir, "CMakeError.log")): + msg = ( + "cmake configuration steps encountered errors, and the idaklu module" + " could not be built. Make sure dependencies are correctly " + "installed. See " + "https://github.com/pybamm-team/PyBaMM/tree/develop" + "INSTALL-LINUX-MAC.md" + ) + raise RuntimeError(msg) + else: + print("-" * 10, "Building idaklu module", "-" * 40) + subprocess.run( + ["cmake", "--build", ".", "--config", "Release"], + cwd=build_dir, + env=build_env, + ) + + # Move from build temp to final position + for ext in self.extensions: + self.move_output(ext) + + def move_output(self, ext): + # Copy built module to dist/ directory + build_temp = Path(self.build_temp).resolve() + # Get destination location + # self.get_ext_fullpath(ext.name) --> + # build/lib.linux-x86_64-3.5/idaklu.cpython-37m-x86_64-linux-gnu.so + # using resolve() with python < 3.6 will result in a FileNotFoundError + # since the location does not yet exists. + dest_path = Path(self.get_ext_fullpath(ext.name)).resolve() + source_path = build_temp / os.path.basename(self.get_ext_filename(ext.name)) + dest_directory = dest_path.parents[0] + dest_directory.mkdir(parents=True, exist_ok=True) + self.copy_file(source_path, dest_path) + +# ---------- end of cmakebuild steps --------------------------------------------------- + +# default_lib_dir = ( +# "" if system() == "Windows" else os.path.join(os.getenv("HOME"), ".local") +# ) + log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" logger = logging.getLogger("PyBaMM setup") @@ -123,6 +285,7 @@ def compile_KLU(): # Build the list of package data files to be included in the PyBaMM package. # These are mainly the parameter files located in the input/parameters/ subdirectories. +# TODO: might be possible to include in pyproject.toml with data configuration values pybamm_data = [] for file_ext in ["*.csv", "*.py", "*.md", "*.txt"]: # Get all the files ending in file_ext in pybamm/input dir. @@ -162,144 +325,32 @@ def compile_KLU(): ext_modules = [idaklu_ext] if compile_KLU() else [] # Defines __version__ +# TODO: might not be needed anymore, because we define it in pyproject.toml +# and can therefore access it with importlib.metadata.version("pybamm") (python 3.8+) +# The version.py file can then be imported with attr: pybamm.__version__ dynamically root = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(root, "pybamm", "version.py")) as f: exec(f.read()) # Load text for description and license +# TODO: might not be needed anymore, because we define the description and license +# in pyproject.toml +# TODO: add long description there and remove it from setup() with open("README.md", encoding="utf-8") as f: readme = f.read() +# Project metadata was moved to pyproject.toml (which is read by pip). +# However, custom build commands and setuptools extension modules are still defined here setup( - name="pybamm", - version=__version__, # noqa: F821 - description="Python Battery Mathematical Modelling.", long_description=readme, long_description_content_type="text/markdown", url="https://github.com/pybamm-team/PyBaMM", packages=find_packages(include=("pybamm", "pybamm.*")), ext_modules=ext_modules, cmdclass={ - "build_ext": CMakeBuild.CMakeBuild, + "build_ext": CMakeBuild, "bdist_wheel": bdist_wheel, "install": CustomInstall, }, package_data={"pybamm": pybamm_data}, - # Python version - python_requires=">=3.8,<3.12", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Scientific/Engineering", - ], - # List of dependencies - install_requires=[ - "numpy>=1.16", - "scipy>=1.3", - "casadi>=3.6.0", - "xarray", - ], - extras_require={ - "docs": [ - "sphinx>=6", - "sphinx_rtd_theme>=0.5", - "pydata-sphinx-theme", - "sphinx_design", - "sphinx-copybutton", - "myst-parser", - "sphinx-inline-tabs", - "sphinxcontrib-bibtex", - "sphinx-autobuild", - "sphinx-last-updated-by-git", - "nbsphinx", - "ipykernel", - "ipywidgets", - "sphinx-gallery", - "sphinx-hoverxref", - "sphinx-docsearch", - ], # For doc generation - "examples": [ - "jupyter", # For example notebooks - ], - "plot": [ - "imageio>=2.9.0", - # Note: Matplotlib is loaded for debug plots, but to ensure pybamm runs - # on systems without an attached display, it should never be imported - # outside of plot() methods. - # Should not be imported - "matplotlib>=2.0", - ], - "cite": [ - "pybtex>=0.24.0", - ], - "latexify": [ - "sympy>=1.8", - ], - "bpx": [ - "bpx", - ], - "tqdm": [ - "tqdm", - ], - "dev": [ - "pre-commit", # For code style checking - "ruff", # For code style auto-formatting - "nox", # For running testing sessions - ], - "pandas": [ - "pandas>=0.24", - ], - "jax": [ - "jax==0.4.8", - "jaxlib==0.4.7", - ], - "odes": ["scikits.odes"], - "all": [ - "anytree>=2.4.3", - "autograd>=1.2", - "pandas>=0.24", - "scikit-fem>=0.2.0", - "imageio>=2.9.0", - "pybtex>=0.24.0", - "sympy>=1.8", - "bpx", - "tqdm", - "matplotlib>=2.0", - "jupyter", - ], - }, - entry_points={ - "console_scripts": [ - "pybamm_edit_parameter = pybamm.parameters_cli:edit_parameter", - "pybamm_add_parameter = pybamm.parameters_cli:add_parameter", - "pybamm_rm_parameter = pybamm.parameters_cli:remove_parameter", - "pybamm_install_odes = pybamm.install_odes:main", - "pybamm_install_jax = pybamm.util:install_jax", - ], - "pybamm_parameter_sets": [ - "Sulzer2019 = pybamm.input.parameters.lead_acid.Sulzer2019:get_parameter_values", # noqa: E501 - "Ai2020 = pybamm.input.parameters.lithium_ion.Ai2020:get_parameter_values", # noqa: E501 - "Chen2020 = pybamm.input.parameters.lithium_ion.Chen2020:get_parameter_values", # noqa: E501 - "Chen2020_composite = pybamm.input.parameters.lithium_ion.Chen2020_composite:get_parameter_values", # noqa: E501 - "Ecker2015 = pybamm.input.parameters.lithium_ion.Ecker2015:get_parameter_values", # noqa: E501 - "Marquis2019 = pybamm.input.parameters.lithium_ion.Marquis2019:get_parameter_values", # noqa: E501 - "Mohtat2020 = pybamm.input.parameters.lithium_ion.Mohtat2020:get_parameter_values", # noqa: E501 - "NCA_Kim2011 = pybamm.input.parameters.lithium_ion.NCA_Kim2011:get_parameter_values", # noqa: E501 - "OKane2022 = pybamm.input.parameters.lithium_ion.OKane2022:get_parameter_values", # noqa: E501 - "ORegan2022 = pybamm.input.parameters.lithium_ion.ORegan2022:get_parameter_values", # noqa: E501 - "Prada2013 = pybamm.input.parameters.lithium_ion.Prada2013:get_parameter_values", # noqa: E501 - "Ramadass2004 = pybamm.input.parameters.lithium_ion.Ramadass2004:get_parameter_values", # noqa: E501 - "Xu2019 = pybamm.input.parameters.lithium_ion.Xu2019:get_parameter_values", # noqa: E501 - "ECM_Example = pybamm.input.parameters.ecm.example_set:get_parameter_values", # noqa: E501 - ], - }, ) From 66e930264daefd8c1817feb3003cb853aee3c8ad Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 00:19:53 +0530 Subject: [PATCH 05/95] #3049 Temporarily install `casadi` before installing editable --- .github/workflows/test_on_push.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 2fd4c92b2e..ee633bd5dc 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -90,6 +90,8 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox + # For some reason casadi needs to be installed first + pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux @@ -150,6 +152,8 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox + # For some reason casadi needs to be installed first + pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux @@ -233,6 +237,8 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox + # For some reason casadi needs to be installed first + pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux @@ -293,6 +299,8 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox + # For some reason casadi needs to be installed first + pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux @@ -354,6 +362,8 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox + # For some reason casadi needs to be installed first + pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux From 8b6a184ad261a51f4d27f4f9a1ea4690e365a65e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 00:20:48 +0530 Subject: [PATCH 06/95] #3049 Better error message if `casadi` path is not found --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3c5141d4f..889e1c1584 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,8 +63,9 @@ execute_process( if (CASADI_DIR) file(TO_CMAKE_PATH ${CASADI_DIR} CASADI_DIR) + message("Found python casadi path: ${CASADI_DIR}") endif() -message("Found python casadi path: ${CASADI_DIR}") +message("Could not find python casadi path") if(${USE_PYTHON_CASADI}) message("Trying to link against python casadi package") From 3bec0ba944676009671fc92fa9cc25f769bdbf8d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 01:12:58 +0530 Subject: [PATCH 07/95] #3049 Rename wheel build workflow name --- .github/workflows/publish_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index ba693ec88e..fbdcf6fcc3 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -1,5 +1,5 @@ # name: Build and publish package to PyPI -name: Test building wheels on Windows, GNU/Linux and macOS +name: Test building wheels # Temporarily disable publishing to PyPI and enable # building wheels on pull requests on: From bfafc753db11160f010b59998dfa8429a79ceaf6 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 01:15:37 +0530 Subject: [PATCH 08/95] #3049 Temporarily use `--no-build-isolation` in CI --- .github/workflows/test_on_push.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index ee633bd5dc..67bac67be7 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -92,7 +92,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] + pip install -e .[all,docs] --no-build-isolation - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -154,7 +154,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] + pip install -e .[all,docs] --no-build-isolation - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -239,7 +239,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] + pip install -e .[all,docs] --no-build-isolation - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -301,7 +301,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] + pip install -e .[all,docs] --no-build-isolation - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -364,7 +364,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] + pip install -e .[all,docs] --no-build-isolation - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 From f4d148aea20a3aefcb75618091c18ba26f0fdf1c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 01:37:37 +0530 Subject: [PATCH 09/95] #3049 add `cmake` to build-system requirements --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5ff07e93e2..46d7117164 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ [build-system] # TODO: specify minimum version of setuptools otherwise scikits.odes, NumPy, and others # will fail to install -requires = ["setuptools", "wheel"] +requires = ["setuptools", "wheel", "cmake"] build-backend = "setuptools.build_meta" [project] From 60caf0bb0505e0b1ea8df7b0849e387b63838c1a Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 01:50:49 +0530 Subject: [PATCH 10/95] Revert "#3049 add `cmake` to build-system requirements" This reverts commit f4d148aea20a3aefcb75618091c18ba26f0fdf1c. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 46d7117164..5ff07e93e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ [build-system] # TODO: specify minimum version of setuptools otherwise scikits.odes, NumPy, and others # will fail to install -requires = ["setuptools", "wheel", "cmake"] +requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [project] From d8d61949bdd0c08e5871d31d929ed0d0b3b1c584 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 19:20:26 +0530 Subject: [PATCH 11/95] #3049 Clarify author emails --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5ff07e93e2..d49d887191 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ description = "Python Battery Mathematical Modelling" # TODO: correctly specify all authors and maintainers # Note: these are currently missing when running `pip show pybamm`, so we should add # them in some form -authors = [{name = "The PyBaMM Team"}] +authors = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] maintainers = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] requires-python = ">=3.8, <3.12" readme = "README.md" From bdd191e72252fd1431a2c9976ad272606fe406d3 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 19:21:24 +0530 Subject: [PATCH 12/95] #3049 clarify idaklu attributes (`setuptools` API) --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1917b62728..5072e17fad 100644 --- a/setup.py +++ b/setup.py @@ -310,8 +310,8 @@ def compile_KLU(): pybamm_data.append("../CMakeBuild.py") idaklu_ext = Extension( - "pybamm.solvers.idaklu", - [ + name="pybamm.solvers.idaklu", + sources=[ "pybamm/solvers/c_solvers/idaklu.cpp" "pybamm/solvers/c_solvers/idaklu.hpp" "pybamm/solvers/c_solvers/idaklu_casadi.cpp" From 9f0f250cda2a5fabecfc17dc1f29e60ea863130f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 21:14:57 +0530 Subject: [PATCH 13/95] #3049 Specify `casadi` as a build-time dependency to overcome venv isolated build error --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d49d887191..5bc365e9ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ [build-system] # TODO: specify minimum version of setuptools otherwise scikits.odes, NumPy, and others # will fail to install -requires = ["setuptools", "wheel"] +requires = ["setuptools", "wheel", "casadi>=3.6.0"] build-backend = "setuptools.build_meta" [project] @@ -170,3 +170,6 @@ Prada2013 = "pybamm.input.parameters.lithium_ion.Prada2013:get_parameter_values" Ramadass2004 = "pybamm.input.parameters.lithium_ion.Ramadass2004:get_parameter_values" Xu2019 = "pybamm.input.parameters.lithium_ion.Xu2019:get_parameter_values" ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" + +# [tool.setuptools.packages.find] +# include = ["pybamm", "pybamm.*"] From 1e480eec59f5d34b7dbe540ef1a4aaf971429165 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 21:15:49 +0530 Subject: [PATCH 14/95] Revert "#3049 Temporarily use `--no-build-isolation` in CI" This reverts commit bfafc753db11160f010b59998dfa8429a79ceaf6. --- .github/workflows/test_on_push.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 67bac67be7..ee633bd5dc 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -92,7 +92,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] --no-build-isolation + pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -154,7 +154,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] --no-build-isolation + pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -239,7 +239,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] --no-build-isolation + pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -301,7 +301,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] --no-build-isolation + pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -364,7 +364,7 @@ jobs: pip install --upgrade pip wheel setuptools nox # For some reason casadi needs to be installed first pip install casadi - pip install -e .[all,docs] --no-build-isolation + pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 From c2e2734e787a0a156b80eba54fa5d7cec33a0459 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 21:15:59 +0530 Subject: [PATCH 15/95] #3049 Remove `casadi` installation prior to editable This reverts commit 66e930264daefd8c1817feb3003cb853aee3c8ad. --- .github/workflows/test_on_push.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index ee633bd5dc..2fd4c92b2e 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -90,8 +90,6 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox - # For some reason casadi needs to be installed first - pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux @@ -152,8 +150,6 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox - # For some reason casadi needs to be installed first - pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux @@ -237,8 +233,6 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox - # For some reason casadi needs to be installed first - pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux @@ -299,8 +293,6 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox - # For some reason casadi needs to be installed first - pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux @@ -362,8 +354,6 @@ jobs: - name: Install PyBaMM dependencies run: | pip install --upgrade pip wheel setuptools nox - # For some reason casadi needs to be installed first - pip install casadi pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux From 2cd36af55a91517e46622cd0beb1aedffdae6533 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 31 Aug 2023 22:35:27 +0530 Subject: [PATCH 16/95] #3049 specify `cmake`, fix `casadi` build-time requirements --- pyproject.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5bc365e9ad..1bef595bbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,12 @@ [build-system] # TODO: specify minimum version of setuptools otherwise scikits.odes, NumPy, and others # will fail to install -requires = ["setuptools", "wheel", "casadi>=3.6.0"] +requires = [ + "setuptools", + "wheel", + "casadi>=3.6.0; platform_system!='Windows'", + "cmake; platform_system=='Linux'", + ] build-backend = "setuptools.build_meta" [project] From 0cdfd5a81b75c95916e8bb6206c093de4825225d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 1 Sep 2023 00:22:36 +0530 Subject: [PATCH 17/95] #3049 Fix doctests, trigger example notebook tests --- docs/source/user_guide/installation/windows-wsl.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/user_guide/installation/windows-wsl.rst b/docs/source/user_guide/installation/windows-wsl.rst index d08545edc0..6453c92211 100644 --- a/docs/source/user_guide/installation/windows-wsl.rst +++ b/docs/source/user_guide/installation/windows-wsl.rst @@ -22,13 +22,13 @@ Get PyBaMM's Source Code sudo apt install git-core -3. Clone the PyBaMM repository:: +3. Clone the PyBaMM repository: .. code:: bash git clone https://github.com/pybamm-team/PyBaMM.git -4. Enter the PyBaMM Directory by running:: +4. Enter the PyBaMM Directory by running: .. code:: bash From fc222ca897a7545b3321476497ea4789beae3ede Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 1 Sep 2023 00:48:59 +0530 Subject: [PATCH 18/95] #3049 Remove non-colour `nox` output in the CI --- noxfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index d1f119cdf1..4bc91d7b44 100644 --- a/noxfile.py +++ b/noxfile.py @@ -16,9 +16,7 @@ "SUNDIALS_INST": f"{homedir}/.local", "LD_LIBRARY_PATH": f"{homedir}/.local/lib:", } -# Do not stdout ANSI colours on GitHub Actions if os.getenv("CI") == "true": - os.environ["NO_COLOR"] = "1" # The setup-python action installs and caches dependencies by default, so we skip # installing them again in nox environments. The dev and docs sessions will still # require a virtual environment, but we don't run them in the CI From 5cfc07adcbccd083e25ca5529e432ef5ce95b156 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 1 Sep 2023 00:58:05 +0530 Subject: [PATCH 19/95] #3049 Force colour output on GitHub Actions --- .github/workflows/test_on_push.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 2fd4c92b2e..3fe00ccc0f 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -4,6 +4,9 @@ on: workflow_dispatch: pull_request: +env: + FORCE_COLOR: 3 + concurrency: # github.workflow: name of the workflow, so that we don't cancel other workflows # github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request From 82197eb1addccbd54a710e6ae154e467a85e7849 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 1 Sep 2023 01:09:09 +0530 Subject: [PATCH 20/95] #3049 Remove inessential editable install job in favour of `nox` --- .github/workflows/test_on_push.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 3fe00ccc0f..ad3ab3c6b0 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -90,10 +90,9 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install PyBaMM dependencies + - name: Install standard Python dependencies run: | pip install --upgrade pip wheel setuptools nox - pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -150,10 +149,9 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install PyBaMM dependencies + - name: Install standard Python dependencies run: | pip install --upgrade pip wheel setuptools nox - pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -233,10 +231,9 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install PyBaMM dependencies + - name: Install standard Python dependencies run: | pip install --upgrade pip wheel setuptools nox - pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -293,10 +290,9 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install PyBaMM dependencies + - name: Install standard Python dependencies run: | pip install --upgrade pip wheel setuptools nox - pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -354,10 +350,9 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install PyBaMM dependencies + - name: Install standard Python dependencies run: | pip install --upgrade pip wheel setuptools nox - pip install -e .[all,docs] - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 From 13ed52dd52851ff58278cde1b1fb7aefd27d44ef Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 1 Sep 2023 20:23:05 +0530 Subject: [PATCH 21/95] #3049 Remove improper CMake message, add for macOS --- .github/workflows/test_on_push.yml | 4 ++-- CMakeLists.txt | 1 - pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index ad3ab3c6b0..81b0908135 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -76,7 +76,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas + brew install graphviz openblas cmake - name: Install Windows system dependencies if: matrix.os == 'windows-latest' @@ -217,7 +217,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas + brew install graphviz openblas cmake - name: Install Windows system dependencies if: matrix.os == 'windows-latest' diff --git a/CMakeLists.txt b/CMakeLists.txt index 889e1c1584..a58ef66933 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,6 @@ if (CASADI_DIR) file(TO_CMAKE_PATH ${CASADI_DIR} CASADI_DIR) message("Found python casadi path: ${CASADI_DIR}") endif() -message("Could not find python casadi path") if(${USE_PYTHON_CASADI}) message("Trying to link against python casadi package") diff --git a/pyproject.toml b/pyproject.toml index 1bef595bbe..0c22507716 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ requires = [ "setuptools", "wheel", "casadi>=3.6.0; platform_system!='Windows'", - "cmake; platform_system=='Linux'", + "cmake; platform_system!='Windows'", ] build-backend = "setuptools.build_meta" From 24fbb8f7419cb6ed6540bec27882e04443b25b13 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 2 Sep 2023 13:39:40 +0530 Subject: [PATCH 22/95] #3049 Fix installation link --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 5072e17fad..fc657e7791 100644 --- a/setup.py +++ b/setup.py @@ -145,8 +145,7 @@ def run(self): "cmake configuration steps encountered errors, and the idaklu module" " could not be built. Make sure dependencies are correctly " "installed. See " - "https://github.com/pybamm-team/PyBaMM/tree/develop" - "INSTALL-LINUX-MAC.md" + "https://docs.pybamm.org/en/latest/source/user_guide/installation/install-from-source.html" # noqa: E501 ) raise RuntimeError(msg) else: From 2561a6e770d721b2b311665ed6f67efdfddb3c27 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 2 Sep 2023 13:46:00 +0530 Subject: [PATCH 23/95] #3049 Remove casadi rpath fix because its shared object cannot be found --- .github/workflows/publish_pypi.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index fbdcf6fcc3..864bec5cb1 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -99,7 +99,7 @@ jobs: brew update brew reinstall gcc brew install libomp - python -m pip install cmake wget + python -m pip install wget python scripts/install_KLU_Sundials.py - name: Build wheels on Linux and MacOS @@ -113,8 +113,7 @@ jobs: CIBW_BEFORE_BUILD_LINUX: "python -m pip install cmake casadi numpy" CIBW_BEFORE_BUILD_MACOS: > python -m pip - install cmake casadi numpy && - python scripts/fix_casadi_rpath_mac.py && + install casadi numpy && scripts/fix_suitesparse_rpath_mac.sh # got error "re.error: multiple repeat at position 104" on python 3.7 when --require-archs added, so remove # it for mac From 921010ec8cc494ff0c736cb9b5444c240edd2c15 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 2 Sep 2023 21:18:27 +0530 Subject: [PATCH 24/95] #3049 Remove `cmake` from macOS in CI --- .github/workflows/test_on_push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 81b0908135..ad3ab3c6b0 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -76,7 +76,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas cmake + brew install graphviz openblas - name: Install Windows system dependencies if: matrix.os == 'windows-latest' @@ -217,7 +217,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas cmake + brew install graphviz openblas - name: Install Windows system dependencies if: matrix.os == 'windows-latest' From 1ee48c139a9448716c8645ebc92c866feeac6641 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 3 Sep 2023 13:43:16 +0530 Subject: [PATCH 25/95] Revert "#3049 Remove casadi rpath fix because its shared object cannot be found" This reverts commit 2561a6e770d721b2b311665ed6f67efdfddb3c27. --- .github/workflows/publish_pypi.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 864bec5cb1..fbdcf6fcc3 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -99,7 +99,7 @@ jobs: brew update brew reinstall gcc brew install libomp - python -m pip install wget + python -m pip install cmake wget python scripts/install_KLU_Sundials.py - name: Build wheels on Linux and MacOS @@ -113,7 +113,8 @@ jobs: CIBW_BEFORE_BUILD_LINUX: "python -m pip install cmake casadi numpy" CIBW_BEFORE_BUILD_MACOS: > python -m pip - install casadi numpy && + install cmake casadi numpy && + python scripts/fix_casadi_rpath_mac.py && scripts/fix_suitesparse_rpath_mac.sh # got error "re.error: multiple repeat at position 104" on python 3.7 when --require-archs added, so remove # it for mac From e4ea1995bdcf338dfd5c09b5c3132fc1d93b887d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 3 Sep 2023 22:47:52 +0530 Subject: [PATCH 26/95] #3049 Fix macOS universal ABI and platform wheels creation bug --- .github/workflows/test_on_push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index ad3ab3c6b0..4913a6f5ca 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -108,8 +108,8 @@ jobs: ${{ env.HOME }}/.local/examples/ key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - - name: Install SuiteSparse and SUNDIALS on GNU/Linux - if: matrix.os == 'ubuntu-latest' + - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS + if: matrix.os != 'windows-latest' run: nox -s pybamm-requires - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} @@ -249,8 +249,8 @@ jobs: ${{ env.HOME }}/.local/examples/ key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - - name: Install SuiteSparse and SUNDIALS on GNU/Linux - if: matrix.os == 'ubuntu-latest' + - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS + if: matrix.os != 'windows-latest' run: nox -s pybamm-requires - name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} From a91885a56a4c8eb58b0541cc5571dc5bb3be01cb Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 3 Sep 2023 23:00:31 +0530 Subject: [PATCH 27/95] #3049 Add a Fortran compiler via Homebrew --- .github/workflows/test_on_push.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 4913a6f5ca..2040b25bfd 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -76,7 +76,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas + brew install graphviz openblas gcc gfortran libomp - name: Install Windows system dependencies if: matrix.os == 'windows-latest' @@ -94,9 +94,9 @@ jobs: run: | pip install --upgrade pip wheel setuptools nox - - name: Cache pybamm-requires nox environment for GNU/Linux + - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 - if: matrix.os == 'ubuntu-latest' + if: matrix.os != 'windows-latest' with: path: | # Repository files @@ -217,7 +217,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas + brew install graphviz openblas gcc gfortran libomp - name: Install Windows system dependencies if: matrix.os == 'windows-latest' @@ -235,9 +235,9 @@ jobs: run: | pip install --upgrade pip wheel setuptools nox - - name: Cache pybamm-requires nox environment for GNU/Linux + - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 - if: matrix.os == 'ubuntu-latest' + if: matrix.os != 'windows-latest' with: path: | # Repository files From ab246c658fe1e207581ac87cb76cf6547629734f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 3 Sep 2023 23:41:22 +0530 Subject: [PATCH 28/95] #3049 Install optional solvers for macOS `nox` sessions --- .github/workflows/test_on_push.yml | 2 +- .../installation/install-from-source.rst | 16 ++++++++-------- noxfile.py | 11 ++++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 2040b25bfd..ddaeeb7edf 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -247,7 +247,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' diff --git a/docs/source/user_guide/installation/install-from-source.rst b/docs/source/user_guide/installation/install-from-source.rst index 787778fa01..cd846a6ec2 100644 --- a/docs/source/user_guide/installation/install-from-source.rst +++ b/docs/source/user_guide/installation/install-from-source.rst @@ -164,10 +164,10 @@ guidelines ` Running the tests ----------------- -Using Nox (recommended) +Using ``Nox`` (recommended) ~~~~~~~~~~~~~~~~~~~~~~~ -You can use Nox to run the unit tests and example notebooks in isolated virtual environments. +You can use ``Nox`` to run the unit tests and example notebooks in isolated virtual environments. The default command @@ -175,7 +175,7 @@ The default command nox -will run pre-commit, install ``Linux`` dependencies, and run the unit tests. +will run pre-commit, install ``Linux`` and ``macOS`` dependencies, and run the unit tests. This can take several minutes. To just run the unit tests, use @@ -245,7 +245,7 @@ Doctests, examples, and coverage - ``nox -s coverage``: Measure current test coverage and generate a coverage report. - ``nox -s quick``: Run integration tests, unit tests, and doctests sequentially. -Extra tips while using Nox +Extra tips while using ``Nox`` -------------------------- Here are some additional useful commands you can run with ``Nox``: @@ -278,11 +278,11 @@ sure each command was successful. One possibility is that you have not set your ``LD_LIBRARY_PATH`` to point to the sundials library, type ``echo $LD_LIBRARY_PATH`` and make sure one of the directories printed out corresponds to where the -sundials libraries are located. +SUNDIALS libraries are located. Another common reason is that you forget to install a BLAS library such -as OpenBLAS before installing sundials. Check the cmake output when you -configured Sundials, it might say: +as OpenBLAS before installing SUNDIALS. Check the cmake output when you +configured SUNDIALS, it might say: :: @@ -291,5 +291,5 @@ configured Sundials, it might say: If this is the case, on a Debian or Ubuntu system you can install OpenBLAS using ``sudo apt-get install libopenblas-dev`` (or -``brew install openblas`` for Mac OS) and then re-install sundials using +``brew install openblas`` for Mac OS) and then re-install SUNDIALS using the instructions above. diff --git a/noxfile.py b/noxfile.py index 4bc91d7b44..f9b97aa909 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,7 +5,7 @@ # Options to modify nox behaviour nox.options.reuse_existing_virtualenvs = True -if sys.platform == "linux": +if sys.platform != "win32": nox.options.sessions = ["pre-commit", "pybamm-requires", "unit"] else: nox.options.sessions = ["pre-commit", "unit"] @@ -77,8 +77,9 @@ def run_integration(session): """Run the integration tests.""" set_environment_variables(PYBAMM_ENV, session=session) session.run_always("pip", "install", "-e", ".[all]") - if sys.platform == "linux": + if sys.platform != "win32": session.run_always("pip", "install", "-e", ".[odes]") + session.run_always("pip", "install", "-e", ".[jax]") session.run("python", "run-tests.py", "--integration") @@ -94,7 +95,7 @@ def run_unit(session): """Run the unit tests.""" set_environment_variables(PYBAMM_ENV, session=session) session.run_always("pip", "install", "-e", ".[all]") - if sys.platform == "linux": + if sys.platform != "win32": session.run_always("pip", "install", "-e", ".[odes]") session.run_always("pip", "install", "-e", ".[jax]") session.run("python", "run-tests.py", "--unit") @@ -123,7 +124,7 @@ def set_dev(session): envbindir = session.bin session.install("-e", ".[all]") session.install("cmake") - if sys.platform == "linux" or sys.platform == "darwin": + if sys.platform != "win32": session.run( "echo", "export", @@ -139,7 +140,7 @@ def run_tests(session): """Run the unit tests and integration tests sequentially.""" set_environment_variables(PYBAMM_ENV, session=session) session.run_always("pip", "install", "-e", ".[all]") - if sys.platform == "linux" or sys.platform == "darwin": + if sys.platform != "win32": session.run_always("pip", "install", "-e", ".[odes]") session.run_always("pip", "install", "-e", ".[jax]") session.run("python", "run-tests.py", "--all") From 60ac7bf1e2236fb49c1ed1861312fe196dcae6f8 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 3 Sep 2023 23:55:35 +0530 Subject: [PATCH 29/95] #3049 Add remaining `pybamm-requires` caches --- .github/workflows/test_on_push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index ddaeeb7edf..34bd87c148 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -106,7 +106,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' @@ -164,7 +164,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: nox -s pybamm-requires @@ -305,7 +305,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: nox -s pybamm-requires @@ -365,7 +365,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: nox -s pybamm-requires From 95d72e5dd3e401ac47af22830fe73bcb192ffbb4 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 00:16:57 +0530 Subject: [PATCH 30/95] #3049 Fix failing doctests --- .../user_guide/installation/install-from-source.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/user_guide/installation/install-from-source.rst b/docs/source/user_guide/installation/install-from-source.rst index cd846a6ec2..2a43b15096 100644 --- a/docs/source/user_guide/installation/install-from-source.rst +++ b/docs/source/user_guide/installation/install-from-source.rst @@ -105,8 +105,8 @@ Installing PyBaMM You should now have everything ready to build and install PyBaMM successfully. -Using Nox (recommended) -~~~~~~~~~~~~~~~~~~~~~~~ +Using ``Nox`` (recommended) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: bash @@ -164,7 +164,7 @@ guidelines ` Running the tests ----------------- -Using ``Nox`` (recommended) +Using Nox (recommended) ~~~~~~~~~~~~~~~~~~~~~~~ You can use ``Nox`` to run the unit tests and example notebooks in isolated virtual environments. @@ -246,7 +246,7 @@ Doctests, examples, and coverage - ``nox -s quick``: Run integration tests, unit tests, and doctests sequentially. Extra tips while using ``Nox`` --------------------------- +------------------------------ Here are some additional useful commands you can run with ``Nox``: - ``--verbose or -v``: Enables verbose mode, providing more detailed output during the execution of Nox sessions. @@ -258,9 +258,9 @@ Here are some additional useful commands you can run with ``Nox``: - ``--report output.json``: Generates a JSON report of the Nox session execution and saves it to the specified file, in this case, "output.json". Troubleshooting -=============== +--------------- -**Problem:** I’ve made edits to source files in PyBaMM, but these are +**Problem:** I have made edits to source files in PyBaMM, but these are not being used when I run my Python script. **Solution:** Make sure you have installed PyBaMM using the ``-e`` flag, From 5dae55fd7fbd933b5c848cd5a5638e4c85dc618c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:21:02 +0530 Subject: [PATCH 31/95] #3049 Speed up solvers installation without extras Remove dependence on `setuptools` and `wheel`, and use `pipx` which GitHub Actions already comes with. --- .github/workflows/test_on_push.yml | 42 ++++++++---------------------- noxfile.py | 26 ++++++++++++------ 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 34bd87c148..f2be240d39 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -90,10 +90,6 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install standard Python dependencies - run: | - pip install --upgrade pip wheel setuptools nox - - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 if: matrix.os != 'windows-latest' @@ -110,10 +106,10 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' - run: nox -s pybamm-requires + run: pipx run nox -s pybamm-requires - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - run: nox -s unit + run: pipx run nox -s unit # Runs only on Ubuntu with Python 3.11 check_coverage: @@ -149,10 +145,6 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install standard Python dependencies - run: | - pip install --upgrade pip wheel setuptools nox - - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 with: @@ -167,10 +159,10 @@ jobs: key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux - run: nox -s pybamm-requires + run: pipx run nox -s pybamm-requires - name: Run unit tests for Ubuntu with Python 3.11 and generate coverage report - run: nox -s coverage + run: pipx run nox -s coverage - name: Upload coverage report uses: codecov/codecov-action@v3.1.4 @@ -231,10 +223,6 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install standard Python dependencies - run: | - pip install --upgrade pip wheel setuptools nox - - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 if: matrix.os != 'windows-latest' @@ -251,10 +239,10 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' - run: nox -s pybamm-requires + run: pipx run nox -s pybamm-requires - name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - run: nox -s integration + run: pipx run nox -s integration # Runs only on Ubuntu with Python 3.11 run_doctests_and_example_tests: @@ -290,10 +278,6 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install standard Python dependencies - run: | - pip install --upgrade pip wheel setuptools nox - - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 with: @@ -308,13 +292,13 @@ jobs: key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux - run: nox -s pybamm-requires + run: pipx run nox -s pybamm-requires - name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11 - run: nox -s doctests + run: pipx run nox -s doctests - name: Install dev dependencies and run example tests for GNU/Linux with Python 3.11 - run: nox -s examples + run: pipx run nox -s examples # Runs only on Ubuntu with Python 3.11 run_scripts_tests: @@ -350,10 +334,6 @@ jobs: cache: 'pip' cache-dependency-path: setup.py - - name: Install standard Python dependencies - run: | - pip install --upgrade pip wheel setuptools nox - - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 with: @@ -368,7 +348,7 @@ jobs: key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux - run: nox -s pybamm-requires + run: pipx run nox -s pybamm-requires - name: Install dev dependencies and run example scripts tests for GNU/Linux with Python 3.11 - run: nox -s scripts + run: pipx run nox -s scripts diff --git a/noxfile.py b/noxfile.py index f9b97aa909..58a66b7c76 100644 --- a/noxfile.py +++ b/noxfile.py @@ -16,6 +16,12 @@ "SUNDIALS_INST": f"{homedir}/.local", "LD_LIBRARY_PATH": f"{homedir}/.local/lib:", } +# Versions compatible with the current version of PyBaMM. Installed directly in the +# sessions to skip redundant installation of dependencies and building wheels both in +# the CI and locally +JAX_VERSION = "0.4.8" +JAXLIB_VERSION = "0.4.7" + if os.getenv("CI") == "true": # The setup-python action installs and caches dependencies by default, so we skip # installing them again in nox environments. The dev and docs sessions will still @@ -65,8 +71,9 @@ def run_coverage(session): session.run_always("pip", "install", "coverage") session.run_always("pip", "install", "-e", ".[all]") if sys.platform != "win32": - session.run_always("pip", "install", "-e", ".[odes]") - session.run_always("pip", "install", "-e", ".[jax]") + session.run_always("pip", "install", "scikits.odes") + session.run_always("pip", "install", f"jax=={JAX_VERSION}") + session.run_always("pip", "install", f"jaxlib=={JAXLIB_VERSION}") session.run("coverage", "run", "--rcfile=.coveragerc", "run-tests.py", "--nosub") session.run("coverage", "combine") session.run("coverage", "xml") @@ -78,8 +85,9 @@ def run_integration(session): set_environment_variables(PYBAMM_ENV, session=session) session.run_always("pip", "install", "-e", ".[all]") if sys.platform != "win32": - session.run_always("pip", "install", "-e", ".[odes]") - session.run_always("pip", "install", "-e", ".[jax]") + session.run_always("pip", "install", "scikits.odes") + session.run_always("pip", "install", f"jax=={JAX_VERSION}") + session.run_always("pip", "install", f"jaxlib=={JAXLIB_VERSION}") session.run("python", "run-tests.py", "--integration") @@ -96,8 +104,9 @@ def run_unit(session): set_environment_variables(PYBAMM_ENV, session=session) session.run_always("pip", "install", "-e", ".[all]") if sys.platform != "win32": - session.run_always("pip", "install", "-e", ".[odes]") - session.run_always("pip", "install", "-e", ".[jax]") + session.run_always("pip", "install", "scikits.odes") + session.run_always("pip", "install", f"jax=={JAX_VERSION}") + session.run_always("pip", "install", f"jaxlib=={JAXLIB_VERSION}") session.run("python", "run-tests.py", "--unit") @@ -141,8 +150,9 @@ def run_tests(session): set_environment_variables(PYBAMM_ENV, session=session) session.run_always("pip", "install", "-e", ".[all]") if sys.platform != "win32": - session.run_always("pip", "install", "-e", ".[odes]") - session.run_always("pip", "install", "-e", ".[jax]") + session.run_always("pip", "install", "scikits.odes") + session.run_always("pip", "install", f"jax=={JAX_VERSION}") + session.run_always("pip", "install", f"jaxlib=={JAXLIB_VERSION}") session.run("python", "run-tests.py", "--all") From 4c53cc53f35f3279717850048c790cf437276e32 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:21:47 +0530 Subject: [PATCH 32/95] #3049 Cleanup scheduled tests workflow --- .github/workflows/run_periodic_tests.yml | 42 +++++++++--------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index f70a748800..fbe664abb0 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -12,24 +12,19 @@ on: schedule: - cron: "0 3 * * *" -jobs: - pre_job: - runs-on: ubuntu-latest - # Map a step output to a job output - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@master - with: - # All of these options are optional, so you can remove them if you are happy with the defaults - concurrent_skipping: "never" - cancel_others: "true" - paths_ignore: '["**/README.md"]' +env: + FORCE_COLOR: 3 +concurrency: + # github.workflow: name of the workflow, so that we don't cancel other workflows + # github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + # Cancel in-progress runs when a new workflow with the same group name is triggered + # This avoids workflow runs on both pushes and PRs + cancel-in-progress: true + +jobs: style: - needs: pre_job - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -66,19 +61,12 @@ jobs: sudo apt install gfortran gcc libopenblas-dev graphviz pandoc sudo apt install texlive-full - # Added fixes to homebrew installs: - # rm -f /usr/local/bin/2to3 - # (see https://github.com/actions/virtual-environments/issues/2322) - name: Install MacOS system dependencies if: matrix.os == 'macos-latest' run: | - rm -f /usr/local/bin/2to3* - rm -f /usr/local/bin/idle3* - rm -f /usr/local/bin/pydoc3* - rm -f /usr/local/bin/python3* + brew analytics off brew update - brew install graphviz - brew install openblas + brew install graphviz openblas gcc gfortran libomp - name: Install Windows system dependencies if: matrix.os == 'windows-latest' @@ -88,8 +76,8 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools nox - - name: Install SuiteSparse and SUNDIALS on GNU/Linux - if: matrix.os == 'ubuntu-latest' + - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS + if: matrix.os != 'windows-latest' run: nox -s pybamm-requires - name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10, and for macOS and Windows with all Python versions From 0c611d915ea380e28ad958d4613320cecd10247c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:22:32 +0530 Subject: [PATCH 33/95] #3049 Remove dependence on deprecated `pkg_resources` --- pybamm/util.py | 8 ++++---- tests/unit/test_parameters/test_parameter_sets_class.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pybamm/util.py b/pybamm/util.py index 5f84f37e0a..772ab8b78b 100644 --- a/pybamm/util.py +++ b/pybamm/util.py @@ -6,6 +6,7 @@ # import argparse import importlib.util +import importlib.metadata import numbers import os import pathlib @@ -18,11 +19,10 @@ from warnings import warn import numpy as np -import pkg_resources import pybamm -# versions of jax and jaxlib compatible with PyBaMM +# versions of jax and jaxlib compatible with PyBaMM, also in noxfile.py JAX_VERSION = "0.4.8" JAXLIB_VERSION = "0.4.7" @@ -272,8 +272,8 @@ def have_jax(): def is_jax_compatible(): """Check if the available version of jax and jaxlib are compatible with PyBaMM""" return ( - pkg_resources.get_distribution("jax").version == JAX_VERSION - and pkg_resources.get_distribution("jaxlib").version == JAXLIB_VERSION + importlib.metadata.version("jax") == JAX_VERSION + and importlib.metadata.version("jaxlib") == JAXLIB_VERSION ) diff --git a/tests/unit/test_parameters/test_parameter_sets_class.py b/tests/unit/test_parameters/test_parameter_sets_class.py index f548fd7955..309b18bbf2 100644 --- a/tests/unit/test_parameters/test_parameter_sets_class.py +++ b/tests/unit/test_parameters/test_parameter_sets_class.py @@ -1,10 +1,10 @@ # # Tests for the ParameterSets class # +import importlib.metadata from tests import TestCase import pybamm -import pkg_resources import unittest @@ -25,7 +25,7 @@ def test_all_registered(self): """Check that all parameter sets have been registered with the ``pybamm_parameter_sets`` entry point""" known_entry_points = set( - ep.name for ep in pkg_resources.iter_entry_points("pybamm_parameter_sets") + ep.name for ep in importlib.metadata.entry_points()["pybamm_parameter_sets"] ) self.assertEqual(set(pybamm.parameter_sets.keys()), known_entry_points) self.assertEqual(len(known_entry_points), len(pybamm.parameter_sets)) From 82082f278674885b299be3b181ef9061e8695a46 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:27:08 +0530 Subject: [PATCH 34/95] #3049 Improvements to scheduled test workflow --- .github/workflows/run_periodic_tests.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index fbe664abb0..9420049a7b 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -72,36 +72,32 @@ jobs: if: matrix.os == 'windows-latest' run: choco install graphviz --version=2.38.0.20190211 - - name: Install standard python dependencies - run: | - python -m pip install --upgrade pip wheel setuptools nox - - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' - run: nox -s pybamm-requires + run: pipx run nox -s pybamm-requires - name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10, and for macOS and Windows with all Python versions if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11) || (matrix.os != 'ubuntu-latest') - run: nox -s unit + run: pipx run nox -s unit - name: Run unit tests for GNU/Linux with Python 3.11 and generate coverage report if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 - run: nox -s coverage + run: pipx run nox -s coverage - name: Upload coverage report if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 uses: codecov/codecov-action@v3.1.4 - name: Run integration tests - run: nox -s integration + run: pipx run nox -s integration - name: Install docs dependencies and run doctests if: matrix.os == 'ubuntu-latest' - run: nox -s doctests + run: pipx run nox -s doctests - name: Install dev dependencies and run example tests if: matrix.os == 'ubuntu-latest' - run: nox -s examples + run: pipx run nox -s examples #M-series Mac Mini build-apple-mseries: From ee4080f1c5785caf4962239afc2c4393bdbf5d67 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 03:23:45 +0530 Subject: [PATCH 35/95] #3049 Remove separate CMakeBuild file --- CMakeBuild.py | 162 -------------------------------------------------- 1 file changed, 162 deletions(-) delete mode 100644 CMakeBuild.py diff --git a/CMakeBuild.py b/CMakeBuild.py deleted file mode 100644 index 5b34bb27df..0000000000 --- a/CMakeBuild.py +++ /dev/null @@ -1,162 +0,0 @@ -import os -import sys -import subprocess -from pathlib import Path -from platform import system - -try: - from setuptools.command.build_ext import build_ext -except ImportError: - from distutils.command.build_ext import build_ext - -default_lib_dir = ( - "" if system() == "Windows" else os.path.join(os.getenv("HOME"), ".local") -) - - -def set_vcpkg_environment_variables(): - if not os.getenv("VCPKG_ROOT_DIR"): - raise EnvironmentError("Environment variable 'VCPKG_ROOT_DIR' is undefined.") - if not os.getenv("VCPKG_DEFAULT_TRIPLET"): - raise EnvironmentError( - "Environment variable 'VCPKG_DEFAULT_TRIPLET' is undefined." - ) - if not os.getenv("VCPKG_FEATURE_FLAGS"): - raise EnvironmentError( - "Environment variable 'VCPKG_FEATURE_FLAGS' is undefined." - ) - return ( - os.getenv("VCPKG_ROOT_DIR"), - os.getenv("VCPKG_DEFAULT_TRIPLET"), - os.getenv("VCPKG_FEATURE_FLAGS"), - ) - - -class CMakeBuild(build_ext): - user_options = build_ext.user_options + [ - ("suitesparse-root=", None, "suitesparse source location"), - ("sundials-root=", None, "sundials source location"), - ] - - def initialize_options(self): - build_ext.initialize_options(self) - self.suitesparse_root = None - self.sundials_root = None - - def finalize_options(self): - build_ext.finalize_options(self) - # Determine the calling command to get the - # undefined options from. - # If build_ext was called directly then this - # doesn't matter. - try: - self.get_finalized_command("install", create=0) - calling_cmd = "install" - except AttributeError: - calling_cmd = "bdist_wheel" - self.set_undefined_options( - calling_cmd, - ("suitesparse_root", "suitesparse_root"), - ("sundials_root", "sundials_root"), - ) - if not self.suitesparse_root: - self.suitesparse_root = os.path.join(default_lib_dir) - if not self.sundials_root: - self.sundials_root = os.path.join(default_lib_dir) - - def get_build_directory(self): - # distutils outputs object files in directory self.build_temp - # (typically build/temp.*). This is our CMake build directory. - # On Windows, distutils is too smart and appends "Release" or - # "Debug" to self.build_temp. So in this case we want the - # build directory to be the parent directory. - if system() == "Windows": - return Path(self.build_temp).parents[0] - return self.build_temp - - def run(self): - if not self.extensions: - return - - if system() == "Windows": - use_python_casadi = False - else: - use_python_casadi = True - - build_type = os.getenv("PYBAMM_CPP_BUILD_TYPE", "RELEASE") - cmake_args = [ - "-DCMAKE_BUILD_TYPE={}".format(build_type), - "-DPYTHON_EXECUTABLE={}".format(sys.executable), - "-DUSE_PYTHON_CASADI={}".format("TRUE" if use_python_casadi else "FALSE"), - ] - if self.suitesparse_root: - cmake_args.append( - "-DSuiteSparse_ROOT={}".format(os.path.abspath(self.suitesparse_root)) - ) - if self.sundials_root: - cmake_args.append( - "-DSUNDIALS_ROOT={}".format(os.path.abspath(self.sundials_root)) - ) - - build_dir = self.get_build_directory() - if not os.path.exists(build_dir): - os.makedirs(build_dir) - - # The CMakeError.log file is generated by cmake is the configure step - # encounters error. In the following the existence of this file is used - # to determine whether or not the cmake configure step went smoothly. - # So must make sure this file does not remain from a previous failed build. - if os.path.isfile(os.path.join(build_dir, "CMakeError.log")): - os.remove(os.path.join(build_dir, "CMakeError.log")) - - build_env = os.environ - if os.getenv("PYBAMM_USE_VCPKG"): - ( - vcpkg_root_dir, - vcpkg_default_triplet, - vcpkg_feature_flags, - ) = set_vcpkg_environment_variables() - build_env["vcpkg_root_dir"] = vcpkg_root_dir - build_env["vcpkg_default_triplet"] = vcpkg_default_triplet - build_env["vcpkg_feature_flags"] = vcpkg_feature_flags - - cmake_list_dir = os.path.abspath(os.path.dirname(__file__)) - print("-" * 10, "Running CMake for idaklu solver", "-" * 40) - subprocess.run( - ["cmake", cmake_list_dir] + cmake_args, cwd=build_dir, env=build_env - ) - - if os.path.isfile(os.path.join(build_dir, "CMakeError.log")): - msg = ( - "cmake configuration steps encountered errors, and the idaklu module" - " could not be built. Make sure dependencies are correctly " - "installed. See " - "https://github.com/pybamm-team/PyBaMM/tree/develop" - "INSTALL-LINUX-MAC.md" - ) - raise RuntimeError(msg) - else: - print("-" * 10, "Building idaklu module", "-" * 40) - subprocess.run( - ["cmake", "--build", ".", "--config", "Release"], - cwd=build_dir, - env=build_env, - ) - - # Move from build temp to final position - for ext in self.extensions: - self.move_output(ext) - - def move_output(self, ext): - # Copy built module to dist/ directory - build_temp = Path(self.build_temp).resolve() - # Get destination location - # self.get_ext_fullpath(ext.name) --> - # build/lib.linux-x86_64-3.5/idaklu.cpython-37m-x86_64-linux-gnu.so - # using resolve() with python < 3.6 will result in a FileNotFoundError - # since the location does not yet exists. - dest_path = Path(self.get_ext_fullpath(ext.name)).resolve() - source_path = build_temp / os.path.basename(self.get_ext_filename(ext.name)) - dest_directory = dest_path.parents[0] - dest_directory.mkdir(parents=True, exist_ok=True) - self.copy_file(source_path, dest_path) From f2a8724db36da504cc1dea4f1f50a253738481b1 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 03:24:59 +0530 Subject: [PATCH 36/95] #3049 Add configuration for package data files --- pyproject.toml | 17 +++++++++++++++-- setup.py | 35 ----------------------------------- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0c22507716..05c70d6cbb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -176,5 +176,18 @@ Ramadass2004 = "pybamm.input.parameters.lithium_ion.Ramadass2004:get_parameter_v Xu2019 = "pybamm.input.parameters.lithium_ion.Xu2019:get_parameter_values" ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" -# [tool.setuptools.packages.find] -# include = ["pybamm", "pybamm.*"] +[tool.setuptools] +include-package-data = true + +# List of files to include as package data. These are mainly the parameter CSV files in +# the input/parameters/ subdirectories. Other files such as the CITATIONS file, relevant +# README.md files, and specific .txt files inside the pybamm/ directory are also included. +[tool.setuptools.package-data] +pybamm = [ + "*.txt", + "*.md", + "*.csv", + "*.py", + "pybamm/CITATIONS.bib", + "pybamm/plotting/mplstyle", +] diff --git a/setup.py b/setup.py index fc657e7791..5da1d2b16c 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ import os import sys -import glob import logging import subprocess from pathlib import Path @@ -14,8 +13,6 @@ from distutils.core import setup, find_packages from distutils.command.install import install -# import CMakeBuild - # ---------- cmakebuild was integrated into setup.py directly -------------------------- try: @@ -176,10 +173,6 @@ def move_output(self, ext): # ---------- end of cmakebuild steps --------------------------------------------------- -# default_lib_dir = ( -# "" if system() == "Windows" else os.path.join(os.getenv("HOME"), ".local") -# ) - log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" logger = logging.getLogger("PyBaMM setup") @@ -281,33 +274,6 @@ def compile_KLU(): return CMakeFound and PyBind11Found - -# Build the list of package data files to be included in the PyBaMM package. -# These are mainly the parameter files located in the input/parameters/ subdirectories. -# TODO: might be possible to include in pyproject.toml with data configuration values -pybamm_data = [] -for file_ext in ["*.csv", "*.py", "*.md", "*.txt"]: - # Get all the files ending in file_ext in pybamm/input dir. - # list_of_files = [ - # 'pybamm/input/drive_cycles/car_current.csv', - # 'pybamm/input/drive_cycles/US06.csv', - # ... - list_of_files = glob.glob("pybamm/input/**/" + file_ext, recursive=True) - - # Add these files to pybamm_data. - # The path must be relative to the package dir (pybamm/), so - # must process the content of list_of_files to take out the top - # pybamm/ dir, i.e.: - # ['input/drive_cycles/car_current.csv', - # 'input/drive_cycles/US06.csv', - # ... - pybamm_data.extend( - [os.path.join(*Path(filename).parts[1:]) for filename in list_of_files] - ) -pybamm_data.append("./CITATIONS.bib") -pybamm_data.append("./plotting/pybamm.mplstyle") -pybamm_data.append("../CMakeBuild.py") - idaklu_ext = Extension( name="pybamm.solvers.idaklu", sources=[ @@ -351,5 +317,4 @@ def compile_KLU(): "bdist_wheel": bdist_wheel, "install": CustomInstall, }, - package_data={"pybamm": pybamm_data}, ) From 4a3a03c513fc1d1a645771469091ac1f17a12dbf Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 06:34:55 +0530 Subject: [PATCH 37/95] #3049 Check links in `toml`, `yaml`, and `json` files --- .github/workflows/lychee_url_checker.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/lychee_url_checker.yml b/.github/workflows/lychee_url_checker.yml index a6735d2806..20eff22b8c 100644 --- a/.github/workflows/lychee_url_checker.yml +++ b/.github/workflows/lychee_url_checker.yml @@ -49,6 +49,10 @@ jobs: './**/*.md' './**/*.py' './**/*.ipynb' + './**/*.yml' + './**/*.yaml' + './**/*.json' + './**/*.toml' # fail the action on broken links fail: true env: From 7c64841cae0f99e694e102fb9678b9f74cb6a7bd Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 06:40:44 +0530 Subject: [PATCH 38/95] #3049 clean up some project configuration options --- pyproject.toml | 49 ++++++++++++++----------------------------------- setup.py | 30 +++++++----------------------- 2 files changed, 21 insertions(+), 58 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 05c70d6cbb..76a601b46f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,4 @@ -# From the pip documentation: - -# Fallback Behaviour -# If a project does not have a pyproject.toml file containing a build-system section, -# it will be assumed to have the following backend settings: - -# [build-system] -# requires = ["setuptools>=40.8.0", "wheel"] -# build-backend = "setuptools.build_meta:__legacy__" - -# TODO: add appropriate build-system section [build-system] -# TODO: specify minimum version of setuptools otherwise scikits.odes, NumPy, and others -# will fail to install requires = [ "setuptools", "wheel", @@ -22,26 +9,13 @@ build-backend = "setuptools.build_meta" [project] name = "pybamm" -# TODO: try picking up version from the package itself -# dynamic = ["version", "readme"] -# [tool.setuptools.dynamic] -# version = {attr = "my_package.VERSION"} version = "23.5" -# Unsure: specify BSD-3-Clause? -# license = {text = "BSD-3-Clause"} license = { file = "LICENSE.txt" } - -# TODO: add appropriate long description description = "Python Battery Mathematical Modelling" - -# TODO: correctly specify all authors and maintainers -# Note: these are currently missing when running `pip show pybamm`, so we should add -# them in some form -authors = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] +authors = [{name = "The PyBaMM Team"}, {email = "pybamm@pybamm.org"}] maintainers = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] requires-python = ">=3.8, <3.12" -readme = "README.md" - +readme = {file = "README.md", content-type = "text/markdown"} classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -56,7 +30,6 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Topic :: Scientific/Engineering", ] - dependencies = [ "numpy>=1.16", "scipy>=1.3", @@ -64,6 +37,13 @@ dependencies = [ "xarray", ] +[project.urls] +Homepage = "https://pybamm.org" +Documentation = "https://docs.pybamm.org" +Repository = "https://github.com/pybamm-team/PyBaMM" +Releases = "https://github.com/pybamm-team/PyBaMM/releases" +Changelog = "https://github.com/pybamm-team/PyBaMM/blob/develop/CHANGELOG.md" + [project.optional-dependencies] # For the generation of documentation docs = [ @@ -91,7 +71,7 @@ examples = [ # Plotting functionality plot = [ "imageio>=2.9.0", - # Note: Matplotlib is loaded for debug plots, but to ensure pybamm runs + # Note: matplotlib is loaded for debug plots, but to ensure pybamm runs # on systems without an attached display, it should never be imported # outside of plot() methods. "matplotlib>=2.0", @@ -149,8 +129,6 @@ all = [ "jupyter", ] -# Equivalent to the console scripts in the entry_points section of the setup() -# function in setup.py [project.scripts] pybamm_edit_parameter = "pybamm.parameters_cli:edit_parameter" pybamm_add_parameter = "pybamm.parameters_cli:add_parameter" @@ -158,8 +136,6 @@ pybamm_rm_parameter = "pybamm.parameters_cli:remove_parameter" pybamm_install_odes = "pybamm.install_odes:main" pybamm_install_jax = "pybamm.util:install_jax" -# Equivalent to the "pybamm_parameter_sets" entry_points section of the setup() -# function in setup.py [project.entry-points."pybamm_parameter_sets"] Sulzer2019 = "pybamm.input.parameters.lead_acid.Sulzer2019:get_parameter_values" Ai2020 = "pybamm.input.parameters.lithium_ion.Ai2020:get_parameter_values" @@ -180,7 +156,7 @@ ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" include-package-data = true # List of files to include as package data. These are mainly the parameter CSV files in -# the input/parameters/ subdirectories. Other files such as the CITATIONS file, relevant +# the input/parameters/ subdirectories. Other files such as the CITATIONS file, relevant # README.md files, and specific .txt files inside the pybamm/ directory are also included. [tool.setuptools.package-data] pybamm = [ @@ -191,3 +167,6 @@ pybamm = [ "pybamm/CITATIONS.bib", "pybamm/plotting/mplstyle", ] + +[tool.setuptools.packages.find] +include = ["pybamm", "pybamm.*"] diff --git a/setup.py b/setup.py index 5da1d2b16c..2af56c6ef6 100644 --- a/setup.py +++ b/setup.py @@ -7,10 +7,10 @@ import wheel.bdist_wheel as orig try: - from setuptools import setup, find_packages, Extension + from setuptools import setup, Extension from setuptools.command.install import install except ImportError: - from distutils.core import setup, find_packages + from distutils.core import setup from distutils.command.install import install # ---------- cmakebuild was integrated into setup.py directly -------------------------- @@ -173,6 +173,8 @@ def move_output(self, ext): # ---------- end of cmakebuild steps --------------------------------------------------- +# ---------- configure setup logger ---------------------------------------------------- + log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" logger = logging.getLogger("PyBaMM setup") @@ -213,6 +215,7 @@ def finalize_options(self): def run(self): install.run(self) +# ---------- custom wheel build (non-Windows) ------------------------------------------ class bdist_wheel(orig.bdist_wheel): """A custom install command to add 2 build options""" @@ -289,28 +292,9 @@ def compile_KLU(): ) ext_modules = [idaklu_ext] if compile_KLU() else [] -# Defines __version__ -# TODO: might not be needed anymore, because we define it in pyproject.toml -# and can therefore access it with importlib.metadata.version("pybamm") (python 3.8+) -# The version.py file can then be imported with attr: pybamm.__version__ dynamically -root = os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(root, "pybamm", "version.py")) as f: - exec(f.read()) - -# Load text for description and license -# TODO: might not be needed anymore, because we define the description and license -# in pyproject.toml -# TODO: add long description there and remove it from setup() -with open("README.md", encoding="utf-8") as f: - readme = f.read() - -# Project metadata was moved to pyproject.toml (which is read by pip). -# However, custom build commands and setuptools extension modules are still defined here +# Project metadata was moved to pyproject.toml (which is read by pip). However, custom +# build commands and setuptools extension modules are still defined here. setup( - long_description=readme, - long_description_content_type="text/markdown", - url="https://github.com/pybamm-team/PyBaMM", - packages=find_packages(include=("pybamm", "pybamm.*")), ext_modules=ext_modules, cmdclass={ "build_ext": CMakeBuild, From 2e332b5348cc58558d737183f9924a86b0037342 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 4 Sep 2023 06:41:37 +0530 Subject: [PATCH 39/95] #3049, #3249, #2881 Update version in `pyproject.toml` --- scripts/update_version.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/update_version.py b/scripts/update_version.py index 4a5f60d8d8..8912035889 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -32,6 +32,16 @@ def update_version(): file.seek(0) file.write(replace_version) + # pyproject.toml + with open(os.path.join(pybamm.root_dir(), "pyproject.toml"), "r+") as file: + output = file.read() + replace_version = re.sub( + '(?<=version = ")(.+)(?=")', release_version, output + ) + file.truncate(0) + file.seek(0) + file.write(replace_version) + # CITATION.cff with open(os.path.join(pybamm.root_dir(), "CITATION.cff"), "r+") as file: output = file.read() From b51bea7796bf1caac313aeb511d4c66e4d7ffbd2 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:29:53 +0530 Subject: [PATCH 40/95] Clean up PyPI publishing workflow jobs --- .github/workflows/publish_pypi.yml | 32 +++++++++--------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index fbdcf6fcc3..1f5d39877e 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -27,9 +27,6 @@ jobs: with: python-version: 3.8 - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.12.3 - - name: Clone pybind11 repo (no history) run: git clone --depth 1 --branch v2.10.4 https://github.com/pybind/pybind11.git @@ -56,8 +53,7 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} - name: Build 64 bits wheels on Windows - run: | - python -m cibuildwheel --output-dir wheelhouse + run: pipx run cibuildwheel --output-dir wheelhouse env: CIBW_ENVIRONMENT: 'PYBAMM_USE_VCPKG=ON VCPKG_ROOT_DIR=C:\vcpkg VCPKG_DEFAULT_TRIPLET=x64-windows-static-md VCPKG_FEATURE_FLAGS=manifests,registries CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM=x64' CIBW_ARCHS: "AMD64" @@ -82,28 +78,19 @@ jobs: with: python-version: 3.8 - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.12.3 - - name: Clone pybind11 repo (no history) - run: git clone --depth 1 --branch v2.10.4 https://github.com/pybind/pybind11.git + run: git clone --depth 1 --branch v2.11.1 https://github.com/pybind/pybind11.git - name: Install SUNDIALS on macOS if: matrix.os == 'macos-latest' run: | - # https://github.com/actions/virtual-environments/issues/1280 - rm -f /usr/local/bin/2to3* - rm -f /usr/local/bin/idle3* - rm -f /usr/local/bin/pydoc3* - rm -f /usr/local/bin/python3* brew update - brew reinstall gcc - brew install libomp + brew install gcc gfortran libomp graphviz openblas python -m pip install cmake wget python scripts/install_KLU_Sundials.py - - name: Build wheels on Linux and MacOS - run: python -m cibuildwheel --output-dir wheelhouse + - name: Build wheels on Linux and macOS + run: pipx run cibuildwheel --output-dir wheelhouse env: # TODO: openblas no longer available on centos 7 i686 image, use blas instead for now CIBW_BEFORE_ALL_LINUX: > @@ -114,8 +101,7 @@ jobs: CIBW_BEFORE_BUILD_MACOS: > python -m pip install cmake casadi numpy && - python scripts/fix_casadi_rpath_mac.py && - scripts/fix_suitesparse_rpath_mac.sh + python scripts/fix_casadi_rpath_mac.py && python scripts/fix_suitesparse_rpath_mac.sh # got error "re.error: multiple repeat at position 104" on python 3.7 when --require-archs added, so remove # it for mac CIBW_REPAIR_WHEEL_COMMAND_MACOS: > @@ -172,7 +158,7 @@ jobs: # - name: Publish on PyPI # if: | # github.event.inputs.target == 'pypi' || - # (github.event_name == 'push' && github.ref == 'refs/heads/main') + # (github.event-name == 'push' && github.ref == 'refs/heads/main') # uses: pypa/gh-action-pypi-publish@release/v1 # with: # user: __token__ @@ -185,5 +171,5 @@ jobs: # with: # user: __token__ # password: ${{ secrets.TESTPYPI_TOKEN }} - # packages_dir: files/ - # repository_url: https://test.pypi.org/legacy/ + # packages-dir: files/ + # repository-url: https://test.pypi.org/legacy/ From 378eed11ea3c0335a72ca97c7aac15e16a8a4b46 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 7 Sep 2023 04:56:21 +0530 Subject: [PATCH 41/95] Add rpath config for `casadi` directory Co-Authored-By: Martin Robinson --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a58ef66933..2605c89b5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ find_package(SUNDIALS REQUIRED) message("sundials ${SUNDIALS_INCLUDE_DIR} ${SUNDIALS_LIBRARIES}") target_include_directories(idaklu PRIVATE ${SUNDIALS_INCLUDE_DIR}) target_link_libraries(idaklu PRIVATE ${SUNDIALS_LIBRARIES} casadi) +set_property(TARGET idaklu APPEND PROPERTY INSTALL_RPATH "${CASADI_DIR}") # link suitesparse # if using vcpkg, use config mode to From 324c31677a3816532c2a595e153ca3a2aa1a901e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 7 Sep 2023 05:07:45 +0530 Subject: [PATCH 42/95] #3049 Add gcc reinstall step again otherwise Fortran compiler is not found --- .github/workflows/publish_pypi.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 1f5d39877e..15af4ec945 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -85,7 +85,8 @@ jobs: if: matrix.os == 'macos-latest' run: | brew update - brew install gcc gfortran libomp graphviz openblas + brew install gfortran libomp graphviz openblas + brew reinstall gcc python -m pip install cmake wget python scripts/install_KLU_Sundials.py From 5976ec35832ab1871076c77a8b686aaffe1c7242 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 7 Sep 2023 05:30:31 +0530 Subject: [PATCH 43/95] #3049 Fix cibuildwheel job --- .github/workflows/publish_pypi.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 15af4ec945..be07bcad05 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -86,7 +86,6 @@ jobs: run: | brew update brew install gfortran libomp graphviz openblas - brew reinstall gcc python -m pip install cmake wget python scripts/install_KLU_Sundials.py @@ -102,7 +101,7 @@ jobs: CIBW_BEFORE_BUILD_MACOS: > python -m pip install cmake casadi numpy && - python scripts/fix_casadi_rpath_mac.py && python scripts/fix_suitesparse_rpath_mac.sh + python scripts/fix_casadi_rpath_mac.py && scripts/fix_suitesparse_rpath_mac.sh # got error "re.error: multiple repeat at position 104" on python 3.7 when --require-archs added, so remove # it for mac CIBW_REPAIR_WHEEL_COMMAND_MACOS: > From 8d88f5b71a549018ec78a4f4a9c353fc31dd4090 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 7 Sep 2023 05:42:56 +0530 Subject: [PATCH 44/95] #3049 Revert "Add rpath config for `casadi` directory" This reverts commit 378eed11ea3c0335a72ca97c7aac15e16a8a4b46. --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2605c89b5c..a58ef66933 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,7 +81,6 @@ find_package(SUNDIALS REQUIRED) message("sundials ${SUNDIALS_INCLUDE_DIR} ${SUNDIALS_LIBRARIES}") target_include_directories(idaklu PRIVATE ${SUNDIALS_INCLUDE_DIR}) target_link_libraries(idaklu PRIVATE ${SUNDIALS_LIBRARIES} casadi) -set_property(TARGET idaklu APPEND PROPERTY INSTALL_RPATH "${CASADI_DIR}") # link suitesparse # if using vcpkg, use config mode to From 91efeab3f7467aaa350e05cb77e3340bf08b5f49 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 7 Sep 2023 17:48:19 +0530 Subject: [PATCH 45/95] #3049 Fix `gcc`/`gfortran` installation (Homebrew) --- .github/workflows/publish_pypi.yml | 4 +++- .github/workflows/test_on_push.yml | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index be07bcad05..99bf0aa10a 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -81,11 +81,13 @@ jobs: - name: Clone pybind11 repo (no history) run: git clone --depth 1 --branch v2.11.1 https://github.com/pybind/pybind11.git + # sometimes gfortran cannot be found, so reinstall gcc just to be sure - name: Install SUNDIALS on macOS if: matrix.os == 'macos-latest' run: | brew update - brew install gfortran libomp graphviz openblas + brew install gcc gfortran libomp graphviz openblas + brew reinstall gcc python -m pip install cmake wget python scripts/install_KLU_Sundials.py diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index f2be240d39..6ad30f7668 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -73,10 +73,12 @@ jobs: HOMEBREW_NO_COLOR: 1 # Speed up CI NONINTERACTIVE: 1 + # sometimes gfortran cannot be found, so reinstall gcc just to be sure run: | brew analytics off brew update brew install graphviz openblas gcc gfortran libomp + brew reinstall gcc - name: Install Windows system dependencies if: matrix.os == 'windows-latest' @@ -206,10 +208,12 @@ jobs: HOMEBREW_NO_COLOR: 1 # Speed up CI NONINTERACTIVE: 1 + # sometimes gfortran cannot be found, so reinstall gcc just to be sure run: | brew analytics off brew update brew install graphviz openblas gcc gfortran libomp + brew reinstall gcc - name: Install Windows system dependencies if: matrix.os == 'windows-latest' From fd0c1a5f3766d2cdfe88e467f24b084b19587edf Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 12 Sep 2023 02:24:42 +0530 Subject: [PATCH 46/95] #3049 Copy `libcasadi.3.7.dylib` to `LD_LIBRARY_PATH` --- scripts/fix_casadi_rpath_mac.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/fix_casadi_rpath_mac.py b/scripts/fix_casadi_rpath_mac.py index 9b0a181391..82c21a34a8 100644 --- a/scripts/fix_casadi_rpath_mac.py +++ b/scripts/fix_casadi_rpath_mac.py @@ -14,6 +14,7 @@ libcpp_name = "libc++.1.0.dylib" libcppabi_name = "libc++abi.dylib" libcasadi_name = "libcasadi.dylib" +libcasadi_37_name = "libcasadi.3.7.dylib" install_name_tool_args = [ "-change", os.path.join("@rpath", libcpp_name), @@ -34,3 +35,13 @@ print(" ".join(["install_name_tool"] + install_name_tool_args)) subprocess.run(["install_name_tool"] + install_name_tool_args) subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)]) + +# Copy libcasadi.3.7.dylib to LD_LIBRARY_PATH ($HOME/.local/lib) +# This is needed for the casadi python bindings to work + +subprocess.run( + ["cp", + os.path.join(casadi_dir, libcasadi_37_name), + os.path.join(os.getenv("HOME"),".local/lib") + ] +) From e7dd32a00aa8ef829625edacf2f60276562078c2 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 12 Sep 2023 02:35:15 +0530 Subject: [PATCH 47/95] #3049 Add `libc++.1.0.dylib` as well --- scripts/fix_casadi_rpath_mac.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/fix_casadi_rpath_mac.py b/scripts/fix_casadi_rpath_mac.py index 82c21a34a8..9779c88ab3 100644 --- a/scripts/fix_casadi_rpath_mac.py +++ b/scripts/fix_casadi_rpath_mac.py @@ -36,7 +36,7 @@ subprocess.run(["install_name_tool"] + install_name_tool_args) subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)]) -# Copy libcasadi.3.7.dylib to LD_LIBRARY_PATH ($HOME/.local/lib) +# Copy libcasadi.3.7.dylib and libc++.1.0.dylib to LD_LIBRARY_PATH ($HOME/.local/lib) # This is needed for the casadi python bindings to work subprocess.run( @@ -45,3 +45,10 @@ os.path.join(os.getenv("HOME"),".local/lib") ] ) + +subprocess.run( + ["cp", + os.path.join(casadi_dir, libcpp_name), + os.path.join(os.getenv("HOME"),".local/lib") + ] +) From 8388ac6e640d5959ff1c559ba0af26235355a6a2 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 12 Sep 2023 02:40:32 +0530 Subject: [PATCH 48/95] #3049 Refactor casadi lib rpaths --- scripts/fix_casadi_rpath_mac.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/fix_casadi_rpath_mac.py b/scripts/fix_casadi_rpath_mac.py index 9779c88ab3..fb275e339a 100644 --- a/scripts/fix_casadi_rpath_mac.py +++ b/scripts/fix_casadi_rpath_mac.py @@ -1,6 +1,6 @@ """ -Removes the rpath from libcasadi.dylib in the casadi python install -and uses a fixed path +Removes the rpath from libcasadi.dylib and libcasadi.3.7.dylib in the casadi python +install and uses a fixed path Used when building the wheels for macos """ @@ -15,16 +15,28 @@ libcppabi_name = "libc++abi.dylib" libcasadi_name = "libcasadi.dylib" libcasadi_37_name = "libcasadi.3.7.dylib" -install_name_tool_args = [ +install_name_tool_args_for_libcasadi_name = [ "-change", os.path.join("@rpath", libcpp_name), os.path.join(casadi_dir, libcpp_name), os.path.join(casadi_dir, libcasadi_name), ] +install_name_tool_args_for_libcasadi_37_name = [ + "-change", + os.path.join("@rpath", libcpp_name), + os.path.join(casadi_dir, libcpp_name), + os.path.join(casadi_dir, libcasadi_37_name), +] subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcasadi_name)]) -print(" ".join(["install_name_tool"] + install_name_tool_args)) -subprocess.run(["install_name_tool"] + install_name_tool_args) + +print(" ".join(["install_name_tool"] + install_name_tool_args_for_libcasadi_name)) +subprocess.run(["install_name_tool"] + install_name_tool_args_for_libcasadi_name) + +print(" ".join(["install_name_tool"] + install_name_tool_args_for_libcasadi_37_name)) +subprocess.run(["install_name_tool"] + install_name_tool_args_for_libcasadi_37_name) + subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcasadi_name)]) + install_name_tool_args = [ "-change", os.path.join("@rpath", libcppabi_name), @@ -32,8 +44,10 @@ os.path.join(casadi_dir, libcpp_name), ] subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)]) + print(" ".join(["install_name_tool"] + install_name_tool_args)) subprocess.run(["install_name_tool"] + install_name_tool_args) + subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)]) # Copy libcasadi.3.7.dylib and libc++.1.0.dylib to LD_LIBRARY_PATH ($HOME/.local/lib) From cbba6b9e72dcfc380ee8d258b30ee70d9425504a Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 12 Sep 2023 03:23:43 +0530 Subject: [PATCH 49/95] Update link checker with job summary --- .github/workflows/lychee_url_checker.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lychee_url_checker.yml b/.github/workflows/lychee_url_checker.yml index 20eff22b8c..dcf2b7e8ee 100644 --- a/.github/workflows/lychee_url_checker.yml +++ b/.github/workflows/lychee_url_checker.yml @@ -45,16 +45,17 @@ jobs: --accept 200,429 --exclude-path ./CHANGELOG.md --exclude-path ./scripts/update_version.py + --exclude-path asv.conf.json './**/*.rst' './**/*.md' './**/*.py' './**/*.ipynb' - './**/*.yml' - './**/*.yaml' './**/*.json' './**/*.toml' # fail the action on broken links fail: true + jobSummary: true + format: markdown env: # to be used in case rate limits are surpassed GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 9432e612f0e8273ddcc332cd4b0b63d9dc047f2a Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 12 Sep 2023 08:11:06 +0530 Subject: [PATCH 50/95] #3049 Run rpath fixes on macOS and Linux --- ...sadi_rpath_mac.py => fix_casadi_rpath_macos_linux.py} | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) rename scripts/{fix_casadi_rpath_mac.py => fix_casadi_rpath_macos_linux.py} (90%) diff --git a/scripts/fix_casadi_rpath_mac.py b/scripts/fix_casadi_rpath_macos_linux.py similarity index 90% rename from scripts/fix_casadi_rpath_mac.py rename to scripts/fix_casadi_rpath_macos_linux.py index fb275e339a..8b4618f2d9 100644 --- a/scripts/fix_casadi_rpath_mac.py +++ b/scripts/fix_casadi_rpath_macos_linux.py @@ -2,7 +2,7 @@ Removes the rpath from libcasadi.dylib and libcasadi.3.7.dylib in the casadi python install and uses a fixed path -Used when building the wheels for macos +Used when building the wheels for macOS and GNU/Linux """ import casadi import os @@ -15,18 +15,21 @@ libcppabi_name = "libc++abi.dylib" libcasadi_name = "libcasadi.dylib" libcasadi_37_name = "libcasadi.3.7.dylib" + install_name_tool_args_for_libcasadi_name = [ "-change", os.path.join("@rpath", libcpp_name), os.path.join(casadi_dir, libcpp_name), os.path.join(casadi_dir, libcasadi_name), ] + install_name_tool_args_for_libcasadi_37_name = [ "-change", os.path.join("@rpath", libcpp_name), os.path.join(casadi_dir, libcpp_name), os.path.join(casadi_dir, libcasadi_37_name), ] + subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcasadi_name)]) print(" ".join(["install_name_tool"] + install_name_tool_args_for_libcasadi_name)) @@ -50,8 +53,8 @@ subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)]) -# Copy libcasadi.3.7.dylib and libc++.1.0.dylib to LD_LIBRARY_PATH ($HOME/.local/lib) -# This is needed for the casadi python bindings to work +# Copy libcasadi.3.7.dylib and libc++.1.0.dylib to $HOME/.local/lib +# This is needed for the casadi python bindings to work while repairing the wheel subprocess.run( ["cp", From c099385819f80cdc77e1e0116b30d3d245b4b8b2 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 12 Sep 2023 08:11:30 +0530 Subject: [PATCH 51/95] #3049 Add repair script to cibuildwheel --- .github/workflows/publish_pypi.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 99bf0aa10a..2742ec6f56 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -82,7 +82,7 @@ jobs: run: git clone --depth 1 --branch v2.11.1 https://github.com/pybind/pybind11.git # sometimes gfortran cannot be found, so reinstall gcc just to be sure - - name: Install SUNDIALS on macOS + - name: Install SuiteSparse and SUNDIALS on macOS if: matrix.os == 'macos-latest' run: | brew update @@ -91,19 +91,20 @@ jobs: python -m pip install cmake wget python scripts/install_KLU_Sundials.py - - name: Build wheels on Linux and macOS + - name: Build wheels on ${{ matrix.os }} run: pipx run cibuildwheel --output-dir wheelhouse env: # TODO: openblas no longer available on centos 7 i686 image, use blas instead for now CIBW_BEFORE_ALL_LINUX: > yum -y install blas-devel lapack-devel && bash build_manylinux_wheels/install_sundials.sh 5.8.1 6.5.0 - - CIBW_BEFORE_BUILD_LINUX: "python -m pip install cmake casadi numpy" + CIBW_BEFORE_BUILD_LINUX: > + python -m pip install cmake casadi numpy && + python scripts/fix_casadi_rpath_macos_linux.py CIBW_BEFORE_BUILD_MACOS: > python -m pip install cmake casadi numpy && - python scripts/fix_casadi_rpath_mac.py && scripts/fix_suitesparse_rpath_mac.sh + python scripts/fix_casadi_rpath_macos_linux.py && scripts/fix_suitesparse_rpath_mac.sh # got error "re.error: multiple repeat at position 104" on python 3.7 when --require-archs added, so remove # it for mac CIBW_REPAIR_WHEEL_COMMAND_MACOS: > From 3502303bf0649f791df98a59efb07cf55b9b8c3a Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 12 Sep 2023 16:36:41 +0530 Subject: [PATCH 52/95] #3049 Fix casadi rpath on macOS --- .github/workflows/publish_pypi.yml | 5 ++--- ...x_casadi_rpath_macos_linux.py => fix_casadi_rpath_mac.py} | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) rename scripts/{fix_casadi_rpath_macos_linux.py => fix_casadi_rpath_mac.py} (94%) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 2742ec6f56..16314250b6 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -99,12 +99,11 @@ jobs: yum -y install blas-devel lapack-devel && bash build_manylinux_wheels/install_sundials.sh 5.8.1 6.5.0 CIBW_BEFORE_BUILD_LINUX: > - python -m pip install cmake casadi numpy && - python scripts/fix_casadi_rpath_macos_linux.py + python -m pip install cmake casadi numpy CIBW_BEFORE_BUILD_MACOS: > python -m pip install cmake casadi numpy && - python scripts/fix_casadi_rpath_macos_linux.py && scripts/fix_suitesparse_rpath_mac.sh + python scripts/fix_casadi_rpath_mac.py && scripts/fix_suitesparse_rpath_mac.sh # got error "re.error: multiple repeat at position 104" on python 3.7 when --require-archs added, so remove # it for mac CIBW_REPAIR_WHEEL_COMMAND_MACOS: > diff --git a/scripts/fix_casadi_rpath_macos_linux.py b/scripts/fix_casadi_rpath_mac.py similarity index 94% rename from scripts/fix_casadi_rpath_macos_linux.py rename to scripts/fix_casadi_rpath_mac.py index 8b4618f2d9..23c8a32d59 100644 --- a/scripts/fix_casadi_rpath_macos_linux.py +++ b/scripts/fix_casadi_rpath_mac.py @@ -2,7 +2,7 @@ Removes the rpath from libcasadi.dylib and libcasadi.3.7.dylib in the casadi python install and uses a fixed path -Used when building the wheels for macOS and GNU/Linux +Used when building the wheels for macOS """ import casadi import os @@ -53,7 +53,7 @@ subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)]) -# Copy libcasadi.3.7.dylib and libc++.1.0.dylib to $HOME/.local/lib +# Copy libcasadi.3.7.dylib and libc++.1.0.dylib to LD_LIBRARY_PATH # This is needed for the casadi python bindings to work while repairing the wheel subprocess.run( From 51db35f0910620570a5da8ca7de2cb52c5bd1a6b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 13 Sep 2023 00:10:15 +0530 Subject: [PATCH 53/95] #3049 try to move casadi shared objects to local path --- .github/workflows/publish_pypi.yml | 3 ++- scripts/fix_casadi_rpath_linux.sh | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 scripts/fix_casadi_rpath_linux.sh diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 16314250b6..08025195df 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -99,7 +99,8 @@ jobs: yum -y install blas-devel lapack-devel && bash build_manylinux_wheels/install_sundials.sh 5.8.1 6.5.0 CIBW_BEFORE_BUILD_LINUX: > - python -m pip install cmake casadi numpy + python -m pip install cmake casadi numpy && + scripts/fix_casadi_rpath_linux.sh CIBW_BEFORE_BUILD_MACOS: > python -m pip install cmake casadi numpy && diff --git a/scripts/fix_casadi_rpath_linux.sh b/scripts/fix_casadi_rpath_linux.sh new file mode 100644 index 0000000000..188bd68781 --- /dev/null +++ b/scripts/fix_casadi_rpath_linux.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +LD_LIBRARY_PATH=${HOME}/.local/lib +CASADI_PATH=$(python -c "import casadi; print(casadi.__path__[0])") + +cp ${CASADI_PATH}/libcasadi.so.3.7 ${LD_LIBRARY_PATH} +cp ${CASADI_PATH}/libcasadi.so ${LD_LIBRARY_PATH} From 78bff9a6f817552106af1e644130d6fa95d45768 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 13 Sep 2023 00:14:21 +0530 Subject: [PATCH 54/95] #3049 fix copying script for Linux --- scripts/fix_casadi_rpath_linux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/fix_casadi_rpath_linux.sh b/scripts/fix_casadi_rpath_linux.sh index 188bd68781..5c7e7801b7 100644 --- a/scripts/fix_casadi_rpath_linux.sh +++ b/scripts/fix_casadi_rpath_linux.sh @@ -3,5 +3,5 @@ LD_LIBRARY_PATH=${HOME}/.local/lib CASADI_PATH=$(python -c "import casadi; print(casadi.__path__[0])") -cp ${CASADI_PATH}/libcasadi.so.3.7 ${LD_LIBRARY_PATH} -cp ${CASADI_PATH}/libcasadi.so ${LD_LIBRARY_PATH} +sudo cp ${CASADI_PATH}/libcasadi.so.3.7 ${LD_LIBRARY_PATH} +sudo cp ${CASADI_PATH}/libcasadi.so ${LD_LIBRARY_PATH} From cc07fc4782c1517266f7bf626e68794900183784 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 19:12:09 +0530 Subject: [PATCH 55/95] #3049 fix LD_LIBRARY_PATH for `nox` --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 58a66b7c76..d9412db495 100644 --- a/noxfile.py +++ b/noxfile.py @@ -14,7 +14,7 @@ homedir = os.getenv("HOME") PYBAMM_ENV = { "SUNDIALS_INST": f"{homedir}/.local", - "LD_LIBRARY_PATH": f"{homedir}/.local/lib:", + "LD_LIBRARY_PATH": f"{homedir}/.local/lib", } # Versions compatible with the current version of PyBaMM. Installed directly in the # sessions to skip redundant installation of dependencies and building wheels both in From 1e164aeddddcb59aff815ff04f2e11d2c0a3c77e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 19:13:01 +0530 Subject: [PATCH 56/95] #3049 add custom wheel repair command for Linux --- .github/workflows/publish_pypi.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 08025195df..ba797f2b58 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -101,6 +101,9 @@ jobs: CIBW_BEFORE_BUILD_LINUX: > python -m pip install cmake casadi numpy && scripts/fix_casadi_rpath_linux.sh + # override; point to casadi install path so that it can be found by the repair command + CIBW_REPAIR_WHEEL_COMMAND_LINUX: > + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$(python -c 'import casadi; print(casadi.__path__[0])')" auditwheel repair -w {dest_dir} {wheel} CIBW_BEFORE_BUILD_MACOS: > python -m pip install cmake casadi numpy && From f30d37288525ba4b08ea8866c7ad87686cf6b036 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 19:29:17 +0530 Subject: [PATCH 57/95] #3049 remove Linux rpath fix script --- .github/workflows/publish_pypi.yml | 3 +-- scripts/fix_casadi_rpath_linux.sh | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 scripts/fix_casadi_rpath_linux.sh diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index f9df08cb33..5a012f64a8 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -99,8 +99,7 @@ jobs: yum -y install blas-devel lapack-devel && bash build_manylinux_wheels/install_sundials.sh 5.8.1 6.5.0 CIBW_BEFORE_BUILD_LINUX: > - python -m pip install cmake casadi numpy && - scripts/fix_casadi_rpath_linux.sh + python -m pip install cmake casadi numpy # override; point to casadi install path so that it can be found by the repair command CIBW_REPAIR_WHEEL_COMMAND_LINUX: > LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$(python -c 'import casadi; print(casadi.__path__[0])')" auditwheel repair -w {dest_dir} {wheel} diff --git a/scripts/fix_casadi_rpath_linux.sh b/scripts/fix_casadi_rpath_linux.sh deleted file mode 100644 index 5c7e7801b7..0000000000 --- a/scripts/fix_casadi_rpath_linux.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -LD_LIBRARY_PATH=${HOME}/.local/lib -CASADI_PATH=$(python -c "import casadi; print(casadi.__path__[0])") - -sudo cp ${CASADI_PATH}/libcasadi.so.3.7 ${LD_LIBRARY_PATH} -sudo cp ${CASADI_PATH}/libcasadi.so ${LD_LIBRARY_PATH} From c069e44f28549fdb0fbd7f9630fc6733d14d3419 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:13:39 +0530 Subject: [PATCH 58/95] #3049 Add MSMR parameters entry point --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 7842ce39a4..c3c6583adb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -155,6 +155,7 @@ Prada2013 = "pybamm.input.parameters.lithium_ion.Prada2013:get_parameter_values" Ramadass2004 = "pybamm.input.parameters.lithium_ion.Ramadass2004:get_parameter_values" Xu2019 = "pybamm.input.parameters.lithium_ion.Xu2019:get_parameter_values" ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" +MSMR_Example = "pybamm.input.parameters.lithium_ion.MSMR_example_set:get_parameter_values" [tool.setuptools] include-package-data = true From 4bf4537730d487b2524e473fda43c99c8786008b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:12:28 +0530 Subject: [PATCH 59/95] Set up MANIFEST.in --- MANIFEST.in | 6 ++++++ pyproject.toml | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000..24ae488d04 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +graft pybamm +prune tests + +exclude CHANGELOG.md CODE-OF-CONDUCT.md CONTRIBUTING.md GOVERNANCE.md CMakeLists.txt + +global-exclude __pycache__ *.py[cod] .venv diff --git a/pyproject.toml b/pyproject.toml index c3c6583adb..a69a7926ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -163,6 +163,7 @@ include-package-data = true # List of files to include as package data. These are mainly the parameter CSV files in # the input/parameters/ subdirectories. Other files such as the CITATIONS file, relevant # README.md files, and specific .txt files inside the pybamm/ directory are also included. +# These are specified to be included in the SDist through MANIFEST.in. [tool.setuptools.package-data] pybamm = [ "*.txt", @@ -174,4 +175,4 @@ pybamm = [ ] [tool.setuptools.packages.find] -include = ["pybamm", "pybamm.*"] +include = ["pybamm"] From 1c202741835ff57282693b3de973207b82a867db Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 22:30:15 +0530 Subject: [PATCH 60/95] #3049 some installation cleanups (`nox`) --- noxfile.py | 58 ++++++++++++++++++++++++------------------------------ setup.py | 16 +++++++++------ 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/noxfile.py b/noxfile.py index 904770d952..c6d300d0b0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -22,12 +22,6 @@ JAX_VERSION = "0.4.8" JAXLIB_VERSION = "0.4.7" -if os.getenv("CI") == "true": - # The setup-python action installs and caches dependencies by default, so we skip - # installing them again in nox environments. The dev and docs sessions will still - # require a virtual environment, but we don't run them in the CI - nox.options.default_venv_backend = "none" - def set_environment_variables(env_dict, session): """ @@ -50,7 +44,7 @@ def run_pybamm_requires(session): """Download, compile, and install the build-time requirements for Linux and macOS: the SuiteSparse and SUNDIALS libraries.""" # noqa: E501 set_environment_variables(PYBAMM_ENV, session=session) if sys.platform != "win32": - session.run_always("pip", "install", "wget", "cmake") + session.install("wget", "cmake" , silent=False) session.run("python", "scripts/install_KLU_Sundials.py") if not os.path.exists("./pybind11"): session.run( @@ -61,19 +55,19 @@ def run_pybamm_requires(session): external=True, ) else: - session.error("nox -s pybamm-requires is only available on Linux & MacOS.") + session.error("nox -s pybamm-requires is only available on Linux & macOS.") @nox.session(name="coverage") def run_coverage(session): """Run the coverage tests and generate an XML report.""" set_environment_variables(PYBAMM_ENV, session=session) - session.run_always("pip", "install", "coverage") - session.run_always("pip", "install", "-e", ".[all]") + session.install("coverage", silent=False) + session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.run_always("pip", "install", "scikits.odes") - session.run_always("pip", "install", f"jax=={JAX_VERSION}") - session.run_always("pip", "install", f"jaxlib=={JAXLIB_VERSION}") + session.install("scikits.odes", silent=False) + session.install(f"jax=={JAX_VERSION}", silent=False) + session.install(f"jaxlib=={JAXLIB_VERSION}", silent=False) session.run("coverage", "run", "--rcfile=.coveragerc", "run-tests.py", "--nosub") session.run("coverage", "combine") session.run("coverage", "xml") @@ -83,18 +77,18 @@ def run_coverage(session): def run_integration(session): """Run the integration tests.""" set_environment_variables(PYBAMM_ENV, session=session) - session.run_always("pip", "install", "-e", ".[all]") + session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.run_always("pip", "install", "scikits.odes") - session.run_always("pip", "install", f"jax=={JAX_VERSION}") - session.run_always("pip", "install", f"jaxlib=={JAXLIB_VERSION}") + session.install("scikits.odes", silent=False) + session.install(f"jax=={JAX_VERSION}", silent=False) + session.install(f"jaxlib=={JAXLIB_VERSION}", silent=False) session.run("python", "run-tests.py", "--integration") @nox.session(name="doctests") def run_doctests(session): """Run the doctests and generate the output(s) in the docs/build/ directory.""" - session.run_always("pip", "install", "-e", ".[all,docs]") + session.install("-e", ".[all,docs]", silent=False) session.run("python", "run-tests.py", "--doctest") @@ -102,11 +96,11 @@ def run_doctests(session): def run_unit(session): """Run the unit tests.""" set_environment_variables(PYBAMM_ENV, session=session) - session.run_always("pip", "install", "-e", ".[all]") + session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.run_always("pip", "install", "scikits.odes") - session.run_always("pip", "install", f"jax=={JAX_VERSION}") - session.run_always("pip", "install", f"jaxlib=={JAXLIB_VERSION}") + session.install("scikits.odes", silent=False) + session.install(f"jax=={JAX_VERSION}", silent=False) + session.install(f"jaxlib=={JAXLIB_VERSION}", silent=False) session.run("python", "run-tests.py", "--unit") @@ -115,7 +109,7 @@ def run_examples(session): """Run the examples tests for Jupyter notebooks.""" set_environment_variables(PYBAMM_ENV, session=session) notebooks_to_test = session.posargs if session.posargs else [] - session.run_always("pip", "install", "-e", ".[all,dev]") + session.install("-e", ".[all,dev]", silent=False) session.run("pytest", "--nbmake", *notebooks_to_test, external=True) @@ -123,7 +117,7 @@ def run_examples(session): def run_scripts(session): """Run the scripts tests for Python scripts.""" set_environment_variables(PYBAMM_ENV, session=session) - session.run_always("pip", "install", "-e", ".[all]") + session.install("-e", ".[all]", silent=False) session.run("python", "run-tests.py", "--scripts") @@ -132,8 +126,8 @@ def set_dev(session): """Install PyBaMM in editable mode.""" set_environment_variables(PYBAMM_ENV, session=session) envbindir = session.bin - session.install("-e", ".[all]") - session.install("cmake") + session.install("-e", ".[all]", silent=False) + session.install("cmake", silent=False) if sys.platform != "win32": session.run( "echo", @@ -149,11 +143,11 @@ def set_dev(session): def run_tests(session): """Run the unit tests and integration tests sequentially.""" set_environment_variables(PYBAMM_ENV, session=session) - session.run_always("pip", "install", "-e", ".[all]") + session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.run_always("pip", "install", "scikits.odes") - session.run_always("pip", "install", f"jax=={JAX_VERSION}") - session.run_always("pip", "install", f"jaxlib=={JAXLIB_VERSION}") + session.install("scikits.odes", silent=False) + session.install(f"jax=={JAX_VERSION}", silent=False) + session.install(f"jaxlib=={JAXLIB_VERSION}", silent=False) session.run("python", "run-tests.py", "--all") @@ -161,7 +155,7 @@ def run_tests(session): def build_docs(session): """Build the documentation and load it in a browser tab, rebuilding on changes.""" envbindir = session.bin - session.install("-e", ".[all,docs]") + session.install("-e", ".[all,docs]", silent=False) session.chdir("docs") session.run( "sphinx-autobuild", @@ -177,7 +171,7 @@ def build_docs(session): @nox.session(name="pre-commit") def lint(session): """Check all files against the defined pre-commit hooks.""" - session.install("pre-commit") + session.install("pre-commit", silent=False) session.run("pre-commit", "run", "--all-files") diff --git a/setup.py b/setup.py index 2af56c6ef6..018bf9eee0 100644 --- a/setup.py +++ b/setup.py @@ -9,16 +9,15 @@ try: from setuptools import setup, Extension from setuptools.command.install import install + from setuptools.command.build_ext import build_ext except ImportError: from distutils.core import setup from distutils.command.install import install + from distutils.command.build_ext import build_ext -# ---------- cmakebuild was integrated into setup.py directly -------------------------- -try: - from setuptools.command.build_ext import build_ext -except ImportError: - from distutils.command.build_ext import build_ext +# ---------- CMake steps for IDAKLU target (non-Windows) ------------------------------- + default_lib_dir = ( "" if system() == "Windows" else os.path.join(os.getenv("HOME"), ".local") @@ -171,10 +170,13 @@ def move_output(self, ext): dest_directory.mkdir(parents=True, exist_ok=True) self.copy_file(source_path, dest_path) -# ---------- end of cmakebuild steps --------------------------------------------------- + +# ---------- end of CMake steps -------------------------------------------------------- + # ---------- configure setup logger ---------------------------------------------------- + log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" logger = logging.getLogger("PyBaMM setup") @@ -215,8 +217,10 @@ def finalize_options(self): def run(self): install.run(self) + # ---------- custom wheel build (non-Windows) ------------------------------------------ + class bdist_wheel(orig.bdist_wheel): """A custom install command to add 2 build options""" From ddac82e448fb3c31106c08621be3c9bed50aa37d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 22:40:38 +0530 Subject: [PATCH 61/95] #3049 #3121 sync jax, jaxlib version requirements --- noxfile.py | 7 ++++--- pyproject.toml | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/noxfile.py b/noxfile.py index c6d300d0b0..dafa114221 100644 --- a/noxfile.py +++ b/noxfile.py @@ -18,9 +18,10 @@ } # Versions compatible with the current version of PyBaMM. Installed directly in the # sessions to skip redundant installation of dependencies and building wheels both in -# the CI and locally -JAX_VERSION = "0.4.8" -JAXLIB_VERSION = "0.4.7" +# the CI and locally. These should be updated when the version of PyBaMM is updated and +# must be kept in sync with the constants defined in pybamm/util.py. +JAX_VERSION = "0.4" +JAXLIB_VERSION = "0.4" def set_environment_variables(env_dict, session): diff --git a/pyproject.toml b/pyproject.toml index a69a7926ca..5f225cb5f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,10 +109,11 @@ dev = [ pandas = [ "pandas>=0.24", ] -# For the Jax solver +# For the Jax solver. Note: these should be kept in sync with the versions defined +# in noxfile.py and pybamm/util.py. jax = [ - "jax==0.4.8", - "jaxlib==0.4.7", + "jax>=0.4,<=0.5", + "jaxlib>=0.4,<=0.5", ] # For the scikits.odes solver odes = [ From 8016c712f417a816760f02a9b51734e825beb0b7 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 22:51:18 +0530 Subject: [PATCH 62/95] #3049 Improve docs about project installation infrastructure --- CONTRIBUTING.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 577dbd67c6..8e8fdd36e5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -385,21 +385,22 @@ wherever code is called that uses that citation (for example, in functions or in ## Infrastructure -### Setuptools +### Installation -Installation of PyBaMM _and dependencies_ is handled via [setuptools](http://setuptools.readthedocs.io/) +Installation of PyBaMM and its dependencies is handled via [pip](https://pip.pypa.io/en/stable/) and [setuptools](http://setuptools.readthedocs.io/). It uses `CMake` to compile C extensions using [`pybind11`](https://pybind11.readthedocs.io/en/stable/) and [`casadi`](https://web.casadi.org/) (non-Windows). The installation process is described in detail in the [source installation](https://docs.pybamm.org/en/latest/source/user_guide/installation/install-from-source.html) page and is configured through the `CMakeLists.txt` file. Configuration files: ``` setup.py +pyproject.toml ``` -Note that this file must be kept in sync with the version number in [pybamm/**init**.py](pybamm/__init__.py). +Note that this file must be kept in sync with the version number in [`pybamm/__init__.py`](pybamm/__init__.py). -### Continuous Integration using GitHub actions +### Continuous Integration using GitHub Actions -Each change pushed to the PyBaMM GitHub repository will trigger the test and benchmark suites to be run, using [GitHub actions](https://github.com/features/actions). +Each change pushed to the PyBaMM GitHub repository will trigger the test and benchmark suites to be run, using [GitHub Actions](https://github.com/features/actions). Tests are run for different operating systems, and for all Python versions officially supported by PyBaMM. If you opened a Pull Request, feedback is directly available on the corresponding page. If all tests pass, a green tick will be displayed next to the corresponding test run. If one or more test(s) fail, a red cross will be displayed instead. From 9307ee48939464b6a2844b8fe4c75fdedef9c4c0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 23:00:51 +0530 Subject: [PATCH 63/95] #3049 Update cache hashes to include `nox` changes --- .github/workflows/test_on_push.yml | 10 +++++----- noxfile.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index d6a2c73f5c..5fb2e3ab15 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -104,7 +104,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' @@ -158,7 +158,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: pipx run nox -s pybamm-requires @@ -239,7 +239,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' @@ -293,7 +293,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: pipx run nox -s pybamm-requires @@ -349,7 +349,7 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: pipx run nox -s pybamm-requires diff --git a/noxfile.py b/noxfile.py index dafa114221..c6175cd183 100644 --- a/noxfile.py +++ b/noxfile.py @@ -18,7 +18,8 @@ } # Versions compatible with the current version of PyBaMM. Installed directly in the # sessions to skip redundant installation of dependencies and building wheels both in -# the CI and locally. These should be updated when the version of PyBaMM is updated and +# the CI and locally +# Note: These should be updated when the version of PyBaMM is updated and # must be kept in sync with the constants defined in pybamm/util.py. JAX_VERSION = "0.4" JAXLIB_VERSION = "0.4" From 3720f04649c30cbb6beb54914bbf7cd50b15f7d6 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 28 Sep 2023 23:16:44 +0530 Subject: [PATCH 64/95] #3049 temporarily skip i686 Linux builds See https://github.com/numpy/numpy/issues/24703 for more information --- .github/workflows/publish_pypi.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 5a012f64a8..b0c5f5faae 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -94,6 +94,8 @@ jobs: - name: Build wheels on ${{ matrix.os }} run: pipx run cibuildwheel --output-dir wheelhouse env: + # NumPy requires BLAS now which is no longer available on manylinux2014 i686, so skip it + CIBW_ARCHS_LINUX: x86_64 # TODO: openblas no longer available on centos 7 i686 image, use blas instead for now CIBW_BEFORE_ALL_LINUX: > yum -y install blas-devel lapack-devel && From aa86d7268d713805ae90ef80117345fc8ebebf3a Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 29 Sep 2023 00:10:32 +0530 Subject: [PATCH 65/95] #3049 Fix UNKNOWN name error on SDist See https://github.com/pypa/setuptools/issues/3269 for more details --- .github/workflows/publish_pypi.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index b0c5f5faae..6f82c6ca2e 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -124,22 +124,22 @@ jobs: if-no-files-found: error build_sdist: - name: Build sdist + name: Build SDist runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.11 - name: Install dependencies - run: pip install wheel + run: pip install --upgrade pip setuptools wheel - - name: Build sdist - run: python setup.py sdist --formats=gztar + - name: Build SDist + run: pipx run build --sdist - - name: Upload sdist + - name: Upload SDist uses: actions/upload-artifact@v3 with: name: sdist From 588496f198ef3ebc1214028ffebffa20d2166bb1 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 2 Oct 2023 02:49:23 +0530 Subject: [PATCH 66/95] #3049 keep solvers extras in sync, don't install yanked versions --- noxfile.py | 35 ++++++++++++----------------------- pybamm/util.py | 5 ++--- pyproject.toml | 3 +-- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/noxfile.py b/noxfile.py index c6175cd183..c59538d94e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -16,13 +16,6 @@ "SUNDIALS_INST": f"{homedir}/.local", "LD_LIBRARY_PATH": f"{homedir}/.local/lib", } -# Versions compatible with the current version of PyBaMM. Installed directly in the -# sessions to skip redundant installation of dependencies and building wheels both in -# the CI and locally -# Note: These should be updated when the version of PyBaMM is updated and -# must be kept in sync with the constants defined in pybamm/util.py. -JAX_VERSION = "0.4" -JAXLIB_VERSION = "0.4" def set_environment_variables(env_dict, session): @@ -65,11 +58,10 @@ def run_coverage(session): """Run the coverage tests and generate an XML report.""" set_environment_variables(PYBAMM_ENV, session=session) session.install("coverage", silent=False) - session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.install("scikits.odes", silent=False) - session.install(f"jax=={JAX_VERSION}", silent=False) - session.install(f"jaxlib=={JAXLIB_VERSION}", silent=False) + session.install("-e", ".[all,odes,jax]", silent=False) + else: + session.install("-e", ".[all]", silent=False) session.run("coverage", "run", "--rcfile=.coveragerc", "run-tests.py", "--nosub") session.run("coverage", "combine") session.run("coverage", "xml") @@ -79,11 +71,10 @@ def run_coverage(session): def run_integration(session): """Run the integration tests.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.install("scikits.odes", silent=False) - session.install(f"jax=={JAX_VERSION}", silent=False) - session.install(f"jaxlib=={JAXLIB_VERSION}", silent=False) + session.install("-e", ".[all,odes,jax]", silent=False) + else: + session.install("-e", ".[all]", silent=False) session.run("python", "run-tests.py", "--integration") @@ -98,11 +89,10 @@ def run_doctests(session): def run_unit(session): """Run the unit tests.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.install("scikits.odes", silent=False) - session.install(f"jax=={JAX_VERSION}", silent=False) - session.install(f"jaxlib=={JAXLIB_VERSION}", silent=False) + session.install("-e", ".[all,odes,jax]", silent=False) + else: + session.install("-e", ".[all]", silent=False) session.run("python", "run-tests.py", "--unit") @@ -145,11 +135,10 @@ def set_dev(session): def run_tests(session): """Run the unit tests and integration tests sequentially.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.install("scikits.odes", silent=False) - session.install(f"jax=={JAX_VERSION}", silent=False) - session.install(f"jaxlib=={JAXLIB_VERSION}", silent=False) + session.install("-e", ".[all,odes,jax]", silent=False) + else: + session.install("-e", ".[all]", silent=False) session.run("python", "run-tests.py", "--all") diff --git a/pybamm/util.py b/pybamm/util.py index 4799ee0285..f31715e551 100644 --- a/pybamm/util.py +++ b/pybamm/util.py @@ -21,9 +21,8 @@ import numpy as np import pybamm -# versions of jax and jaxlib compatible with PyBaMM. These are also defined in -# noxfile.py and in the extras dependencies in pyproject.toml, and therefore must be -# kept in sync. +# Versions of jax and jaxlib compatible with PyBaMM. Note: these are also defined in +# in the extras dependencies in pyproject.toml, and therefore must be kept in sync. JAX_VERSION = "0.4" JAXLIB_VERSION = "0.4" diff --git a/pyproject.toml b/pyproject.toml index 5f225cb5f5..912f4576c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,8 +109,7 @@ dev = [ pandas = [ "pandas>=0.24", ] -# For the Jax solver. Note: these should be kept in sync with the versions defined -# in noxfile.py and pybamm/util.py. +# For the Jax solver. Note: these must be kept in sync with the versions defined in pybamm/util.py. jax = [ "jax>=0.4,<=0.5", "jaxlib>=0.4,<=0.5", From 690b8145e4c683241e92c0ab3275f6e9066369d2 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 2 Oct 2023 04:13:16 +0530 Subject: [PATCH 67/95] #3049 Fix up authors name and email in project --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 912f4576c9..352f35725e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,7 @@ requires = [ "setuptools", "wheel", "casadi>=3.6.0; platform_system!='Windows'", + # use CMake bundled from MSVC on Windows "cmake; platform_system!='Windows'", ] build-backend = "setuptools.build_meta" @@ -12,7 +13,7 @@ name = "pybamm" version = "23.5" license = { file = "LICENSE.txt" } description = "Python Battery Mathematical Modelling" -authors = [{name = "The PyBaMM Team"}, {email = "pybamm@pybamm.org"}] +authors = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] maintainers = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] requires-python = ">=3.8, <3.12" readme = {file = "README.md", content-type = "text/markdown"} From b18d6661129ea433b4473588c5546c6b394fb810 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:51:20 +0530 Subject: [PATCH 68/95] Cleanup extras list, resolve conflicts --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 352f35725e..685656432e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,9 +95,9 @@ tqdm = [ ] # Dependencies intended for use by developers dev = [ - # For code style checking + # For working with pre-commit hooks "pre-commit", - # For code style auto-formatting + # For code style checks: linting and auto-formatting "ruff", # For running testing sessions "nox", From a91c87b9b4e44835dd2046cdc92fcd0106e9d844 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:16:46 +0530 Subject: [PATCH 69/95] #3049 add `pipx` for doctests job --- .github/workflows/test_on_push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index caf019d08e..6821016e45 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -284,10 +284,10 @@ jobs: cache-dependency-path: setup.py - name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11 - run: nox -s doctests + run: pipx run nox -s doctests - name: Check if the documentation can be built for GNU/Linux with Python 3.11 - run: nox -s docs + run: pipx run nox -s docs # Runs only on Ubuntu with Python 3.11 run_example_tests: From 14c3c61719e0ffc8a44e90a763e173baa8df8285 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:28:15 +0530 Subject: [PATCH 70/95] #3049 try to bump `pybind11`, `vcpkg` versions (Windows) --- .github/workflows/publish_pypi.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 6f82c6ca2e..c38092906e 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -28,14 +28,13 @@ jobs: python-version: 3.8 - name: Clone pybind11 repo (no history) - run: git clone --depth 1 --branch v2.10.4 https://github.com/pybind/pybind11.git + run: git clone --depth 1 --branch v2.11.1 https://github.com/pybind/pybind11.git - # remove when a new vcpkg version is released - - name: Install the latest commit of vcpkg on windows + - name: Install vcpkg on windows run: | cd C:\ rm -r -fo 'C:\vcpkg' - git clone https://github.com/microsoft/vcpkg + git clone https://github.com/microsoft/vcpkg --branch 2023.08.09 cd vcpkg .\bootstrap-vcpkg.bat From 30d76cd1994e566120054a355eaa97cde53e2be5 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:31:43 +0530 Subject: [PATCH 71/95] #3049 add OKane2022 parameter entry points --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 685656432e..a416dfd2a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,10 +147,12 @@ Ai2020 = "pybamm.input.parameters.lithium_ion.Ai2020:get_parameter_values" Chen2020 = "pybamm.input.parameters.lithium_ion.Chen2020:get_parameter_values" Chen2020_composite = "pybamm.input.parameters.lithium_ion.Chen2020_composite:get_parameter_values" Ecker2015 = "pybamm.input.parameters.lithium_ion.Ecker2015:get_parameter_values" +Ecker2015_graphite_halfcell = "pybamm.input.parameters.lithium_ion.Ecker2015_graphite_halfcell:get_parameter_values" Marquis2019 = "pybamm.input.parameters.lithium_ion.Marquis2019:get_parameter_values" Mohtat2020 = "pybamm.input.parameters.lithium_ion.Mohtat2020:get_parameter_values" NCA_Kim2011 = "pybamm.input.parameters.lithium_ion.NCA_Kim2011:get_parameter_values" OKane2022 = "pybamm.input.parameters.lithium_ion.OKane2022:get_parameter_values" +OKane2022_graphite_SiOx_halfcell = "pybamm.input.parameters.lithium_ion.OKane2022_graphite_SiOx_halfcell:get_parameter_values" ORegan2022 = "pybamm.input.parameters.lithium_ion.ORegan2022:get_parameter_values" Prada2013 = "pybamm.input.parameters.lithium_ion.Prada2013:get_parameter_values" Ramadass2004 = "pybamm.input.parameters.lithium_ion.Ramadass2004:get_parameter_values" From 5c18e229b5f9a111dcbf46c0bd9c9fece2bfe069 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 7 Oct 2023 03:27:38 +0530 Subject: [PATCH 72/95] #3049 correctly specify inclusion of packages --- pyproject.toml | 2 +- setup.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a416dfd2a2..c91d275789 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -178,4 +178,4 @@ pybamm = [ ] [tool.setuptools.packages.find] -include = ["pybamm"] +include = ["pybamm", "pybamm.*"] diff --git a/setup.py b/setup.py index 018bf9eee0..a0180cb3e8 100644 --- a/setup.py +++ b/setup.py @@ -299,6 +299,8 @@ def compile_KLU(): # Project metadata was moved to pyproject.toml (which is read by pip). However, custom # build commands and setuptools extension modules are still defined here. setup( + # silence "Package would be ignored" warnings + include_package_data=True, ext_modules=ext_modules, cmdclass={ "build_ext": CMakeBuild, From c016a64a4c41138acd962ab1c36bacbcc69ec2e3 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 7 Oct 2023 17:04:30 +0530 Subject: [PATCH 73/95] #3049 Remove unneeded files (used for old manylinux) Not needed anymore after we have been using `cibuildwheel`, which uses the Dockerfile from PyPA --- build_manylinux_wheels/Dockerfile | 18 ----------------- build_manylinux_wheels/action.yml | 17 ---------------- build_manylinux_wheels/entrypoint.sh | 30 ---------------------------- 3 files changed, 65 deletions(-) delete mode 100644 build_manylinux_wheels/Dockerfile delete mode 100644 build_manylinux_wheels/action.yml delete mode 100644 build_manylinux_wheels/entrypoint.sh diff --git a/build_manylinux_wheels/Dockerfile b/build_manylinux_wheels/Dockerfile deleted file mode 100644 index a6c2dcc41c..0000000000 --- a/build_manylinux_wheels/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM quay.io/pypa/manylinux2014_x86_64:2020-11-11-bc8ce45 - -ENV PLAT manylinux2014_x86_64 - -RUN yum -y update -RUN yum -y remove cmake -RUN yum -y install wget openblas-devel -RUN /opt/python/cp37-cp37m/bin/pip install --upgrade pip cmake -RUN ln -s /opt/python/cp37-cp37m/bin/cmake /usr/bin/cmake - -COPY install_sundials.sh /install_sundials.sh -RUN chmod +x /install_sundials.sh -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - -RUN ./install_sundials.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/build_manylinux_wheels/action.yml b/build_manylinux_wheels/action.yml deleted file mode 100644 index 7264606b30..0000000000 --- a/build_manylinux_wheels/action.yml +++ /dev/null @@ -1,17 +0,0 @@ -# action.yml -# Based on RalfG/python-wheels-manylinux-build/action.yml by Ralf Gabriels - -name: "Python wheels manylinux build" -author: "Thibault Lestang" -description: "Build manylinux wheels for PyBaMM" -inputs: - python-versions: - description: "Python versions to target, space-separated" - required: true - default: "cp36-cp36m cp37-cp37m" - -runs: - using: "docker" - image: "Dockerfile" - args: - - ${{ inputs.python-versions }} diff --git a/build_manylinux_wheels/entrypoint.sh b/build_manylinux_wheels/entrypoint.sh deleted file mode 100644 index 203e5471d3..0000000000 --- a/build_manylinux_wheels/entrypoint.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -set -e -x - -# GitHub runners add "-e LD_LIBRARY_PATH" option to "docker run", -# overriding default value of LD_LIBRARY_PATH in manylinux image. This -# causes libcrypt.so.2 to be missing (it lives in /usr/local/lib) -export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH - -# CLI arguments -PY_VERSIONS=$1 - -git clone https://github.com/pybind/pybind11.git /github/workspace/pybind11 -# Compile wheels -arrPY_VERSIONS=(${PY_VERSIONS// / }) -for PY_VER in "${arrPY_VERSIONS[@]}"; do - # Update pip - /opt/python/"${PY_VER}"/bin/pip install --upgrade --no-cache-dir pip - - # Build wheels - /opt/python/"${PY_VER}"/bin/pip wheel /github/workspace/ -w /github/workspace/wheelhouse/ --no-deps || { echo "Building wheels failed."; exit 1; } -done -ls -l /github/workspace/wheelhouse/ - -# Bundle external shared libraries into the wheels -for whl in /github/workspace/wheelhouse/*-linux*.whl; do - auditwheel repair "$whl" --plat "${PLAT}" -w /github/workspace/dist/ || { echo "Repairing wheels failed."; auditwheel show "$whl"; exit 1; } -done - -echo "Succesfully built wheels:" -ls -l /github/workspace/dist/ From b70e0a64b44acf0e3596efe9dd1cd27d48f1d7c5 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 7 Oct 2023 17:06:01 +0530 Subject: [PATCH 74/95] #3049 move SUNDIALS installation to `scripts/` --- .github/workflows/publish_pypi.yml | 2 +- {build_manylinux_wheels => scripts}/install_sundials.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename {build_manylinux_wheels => scripts}/install_sundials.sh (93%) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index c38092906e..671cf4a0b0 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -98,7 +98,7 @@ jobs: # TODO: openblas no longer available on centos 7 i686 image, use blas instead for now CIBW_BEFORE_ALL_LINUX: > yum -y install blas-devel lapack-devel && - bash build_manylinux_wheels/install_sundials.sh 5.8.1 6.5.0 + bash scripts/install_sundials.sh 5.8.1 6.5.0 CIBW_BEFORE_BUILD_LINUX: > python -m pip install cmake casadi numpy # override; point to casadi install path so that it can be found by the repair command diff --git a/build_manylinux_wheels/install_sundials.sh b/scripts/install_sundials.sh similarity index 93% rename from build_manylinux_wheels/install_sundials.sh rename to scripts/install_sundials.sh index 709d9c13c7..56435066b4 100644 --- a/build_manylinux_wheels/install_sundials.sh +++ b/scripts/install_sundials.sh @@ -1,10 +1,10 @@ #!/bin/bash # This script installs both SuiteSparse -# (https://people.engr.tamu.edu/davis/suitesparse.html) and Sundials +# (https://people.engr.tamu.edu/davis/suitesparse.html) and SUNDIALS # (https://computing.llnl.gov/projects/sundials) from source. For each # two library: -# - Archive downloaded and source code extrated in current working +# - Archive downloaded and source code extracted in current working # directory. # - Library is built and installed. # From 5583d01844a8f7e4eac6ce7e8be6ea81c61233aa Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 7 Oct 2023 17:08:36 +0530 Subject: [PATCH 75/95] #3049 delete older SUNDIALS CMake files these were used for finding KLU earlier but are for now outdated versions of SUNDIALS (<6). We currently use a custom vcpkg registry which comes with modified portfiles for this purpose. --- scripts/replace-cmake/README.md | 1 - .../sundials-3.1.1/CMakeLists.txt | 1597 ----------------- .../sundials-4.1.0/CMakeLists.txt | 1151 ------------ .../sundials-5.0.0/CMakeLists.txt | 1151 ------------ 4 files changed, 3900 deletions(-) delete mode 100644 scripts/replace-cmake/README.md delete mode 100644 scripts/replace-cmake/sundials-3.1.1/CMakeLists.txt delete mode 100644 scripts/replace-cmake/sundials-4.1.0/CMakeLists.txt delete mode 100644 scripts/replace-cmake/sundials-5.0.0/CMakeLists.txt diff --git a/scripts/replace-cmake/README.md b/scripts/replace-cmake/README.md deleted file mode 100644 index e578a96abb..0000000000 --- a/scripts/replace-cmake/README.md +++ /dev/null @@ -1 +0,0 @@ -A modified sundials cmake file which finds the KLU solvers correctly diff --git a/scripts/replace-cmake/sundials-3.1.1/CMakeLists.txt b/scripts/replace-cmake/sundials-3.1.1/CMakeLists.txt deleted file mode 100644 index 81f4267c22..0000000000 --- a/scripts/replace-cmake/sundials-3.1.1/CMakeLists.txt +++ /dev/null @@ -1,1597 +0,0 @@ -# --------------------------------------------------------------- -# Programmer: Radu Serban @ LLNL -# --------------------------------------------------------------- -# LLNS Copyright Start -# Copyright (c) 2014, Lawrence Livermore National Security -# This work was performed under the auspices of the U.S. Department -# of Energy by Lawrence Livermore National Laboratory in part under -# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344. -# Produced at the Lawrence Livermore National Laboratory. -# All rights reserved. -# For details, see the LICENSE file. -# LLNS Copyright End -# --------------------------------------------------------------- -# Top level CMakeLists.txt for SUNDIALS (for cmake build system) -# --------------------------------------------------------------- - -# --------------------------------------------------------------- -# Initial commands -# --------------------------------------------------------------- - -# Require a fairly recent cmake version -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1) - -# Set CMake policy to allow examples to build -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -# Project SUNDIALS (initially only C supported) -# sets PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR variables -PROJECT(sundials C) - -# Set some variables with info on the SUNDIALS project -SET(PACKAGE_BUGREPORT "woodward6@llnl.gov") -SET(PACKAGE_NAME "SUNDIALS") -SET(PACKAGE_STRING "SUNDIALS 3.1.1") -SET(PACKAGE_TARNAME "sundials") - -# set SUNDIALS version numbers -# (use "" for the version label if none is needed) -SET(PACKAGE_VERSION_MAJOR "3") -SET(PACKAGE_VERSION_MINOR "1") -SET(PACKAGE_VERSION_PATCH "1") -SET(PACKAGE_VERSION_LABEL "") - -IF(PACKAGE_VERSION_LABEL) - SET(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}-${PACKAGE_VERSION_LABEL}") -ELSE() - SET(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}") -ENDIF() - -# -SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) - -# Prohibit in-source build -IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - MESSAGE(FATAL_ERROR "In-source build prohibited.") -ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - -# Hide some cache variables -MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) - -# Always show the C compiler and flags -MARK_AS_ADVANCED(CLEAR - CMAKE_C_COMPILER - CMAKE_C_FLAGS) - -# Specify the VERSION and SOVERSION for shared libraries - -SET(arkodelib_VERSION "2.1.1") -SET(arkodelib_SOVERSION "2") - -SET(cvodelib_VERSION "3.1.1") -SET(cvodelib_SOVERSION "3") - -SET(cvodeslib_VERSION "3.1.1") -SET(cvodeslib_SOVERSION "3") - -SET(idalib_VERSION "3.1.1") -SET(idalib_SOVERSION "3") - -SET(idaslib_VERSION "2.1.0") -SET(idaslib_SOVERSION "2") - -SET(kinsollib_VERSION "3.1.1") -SET(kinsollib_SOVERSION "3") - -SET(cpodeslib_VERSION "0.0.0") -SET(cpodeslib_SOVERSION "0") - -SET(nveclib_VERSION "3.1.1") -SET(nveclib_SOVERSION "3") - -SET(sunmatrixlib_VERSION "1.1.1") -SET(sunmatrixlib_SOVERSION "1") - -SET(sunlinsollib_VERSION "1.1.1") -SET(sunlinsollib_SOVERSION "1") - -# Specify the location of additional CMAKE modules -SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/config) - -# --------------------------------------------------------------- -# MACRO definitions -# --------------------------------------------------------------- -INCLUDE(SundialsCMakeMacros) - -# --------------------------------------------------------------- -# Check for deprecated SUNDIALS CMake options/variables -# --------------------------------------------------------------- -INCLUDE(SundialsDeprecated) - -# --------------------------------------------------------------- -# Which modules to build? -# --------------------------------------------------------------- - -# For each SUNDIALS solver available (i.e. for which we have the -# sources), give the user the option of enabling/disabling it. - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/arkode") - OPTION(BUILD_ARKODE "Build the ARKODE library" ON) -ELSE() - SET(BUILD_ARKODE OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cvode") - OPTION(BUILD_CVODE "Build the CVODE library" ON) -ELSE() - SET(BUILD_CVODE OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cvodes") - OPTION(BUILD_CVODES "Build the CVODES library" ON) -ELSE() - SET(BUILD_CVODES OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/ida") - OPTION(BUILD_IDA "Build the IDA library" ON) -ELSE() - SET(BUILD_IDA OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/idas") - OPTION(BUILD_IDAS "Build the IDAS library" ON) -ELSE() - SET(BUILD_IDAS OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/kinsol") - OPTION(BUILD_KINSOL "Build the KINSOL library" ON) -ELSE() - SET(BUILD_KINSOL OFF) -ENDIF() - -# CPODES is always OFF for now. (commented out for Release); ToDo: better way to do this? -#IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes") -# OPTION(BUILD_CPODES "Build the CPODES library" OFF) -#ELSE() -# SET(BUILD_CPODES OFF) -#ENDIF() - -# --------------------------------------------------------------- -# xSDK specific options -# --------------------------------------------------------------- -INCLUDE(SundialsXSDK) - -# --------------------------------------------------------------- -# Build specific C flags -# --------------------------------------------------------------- - -# Hide all build type specific flags -MARK_AS_ADVANCED(FORCE - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_RELWITHDEBINFO) - -# Only show flags for the current build type it is set -# NOTE: Build specific flags are appended those in CMAKE_C_FLAGS -IF(CMAKE_BUILD_TYPE) - IF(CMAKE_BUILD_TYPE MATCHES "Debug") - MESSAGE("Appending C debug flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_DEBUG) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "MinSizeRel") - MESSAGE("Appending C min size release flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_MINSIZEREL) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "Release") - MESSAGE("Appending C release flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_RELEASE) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") - MESSAGE("Appending C release with debug info flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_RELWITHDEBINFO) - ENDIF() -ENDIF() - -# --------------------------------------------------------------- -# Option to specify precision (realtype) -# --------------------------------------------------------------- - -SET(DOCSTR "single, double, or extended") -SHOW_VARIABLE(SUNDIALS_PRECISION STRING "${DOCSTR}" "double") - -# prepare substitution variable PRECISION_LEVEL for sundials_config.h -STRING(TOUPPER ${SUNDIALS_PRECISION} SUNDIALS_PRECISION) -SET(PRECISION_LEVEL "#define SUNDIALS_${SUNDIALS_PRECISION}_PRECISION 1") - -# prepare substitution variable FPRECISION_LEVEL for sundials_fconfig.h -IF(SUNDIALS_PRECISION MATCHES "SINGLE") - SET(FPRECISION_LEVEL "4") -ENDIF(SUNDIALS_PRECISION MATCHES "SINGLE") -IF(SUNDIALS_PRECISION MATCHES "DOUBLE") - SET(FPRECISION_LEVEL "8") -ENDIF(SUNDIALS_PRECISION MATCHES "DOUBLE") -IF(SUNDIALS_PRECISION MATCHES "EXTENDED") - SET(FPRECISION_LEVEL "16") -ENDIF(SUNDIALS_PRECISION MATCHES "EXTENDED") - -# --------------------------------------------------------------- -# Option to specify index type -# --------------------------------------------------------------- - -SET(DOCSTR "Signed 64-bit (int64_t) or signed 32-bit (int32_t) integer") -SHOW_VARIABLE(SUNDIALS_INDEX_TYPE STRING "${DOCSTR}" "int64_t") - -# prepare substitution variable INDEX_TYPE for sundials_config.h -STRING(TOUPPER ${SUNDIALS_INDEX_TYPE} SUNDIALS_INDEX_TYPE) -SET(INDEX_TYPE "#define SUNDIALS_${SUNDIALS_INDEX_TYPE} 1") - -# prepare substitution variable FINDEX_TYPE for sundials_fconfig.h -IF(SUNDIALS_INDEX_TYPE MATCHES "INT32_T") - SET(FINDEX_TYPE "4") -ENDIF(SUNDIALS_INDEX_TYPE MATCHES "INT32_T") -IF(SUNDIALS_INDEX_TYPE MATCHES "INT64_T") - SET(FINDEX_TYPE "8") -ENDIF(SUNDIALS_INDEX_TYPE MATCHES "INT64_T") - -# --------------------------------------------------------------- -# Enable Fortran interface? -# --------------------------------------------------------------- - -# Fortran interface is disabled by default -SET(DOCSTR "Enable Fortran-C support") -SHOW_VARIABLE(FCMIX_ENABLE BOOL "${DOCSTR}" OFF) - -# Check that at least one solver with a Fortran interface is built -IF(NOT BUILD_ARKODE AND NOT BUILD_CVODE AND NOT BUILD_IDA AND NOT BUILD_KINSOL) - IF(FCMIX_ENABLE) - PRINT_WARNING("Enabled packages do not support Fortran" "Disabling FCMIX") - FORCE_VARIABLE(FCMIX_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(FCMIX_ENABLE) -ENDIF() - -# --------------------------------------------------------------- -# Options to build static and/or shared libraries -# --------------------------------------------------------------- - -OPTION(BUILD_STATIC_LIBS "Build static libraries" ON) -OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) - -# Make sure we build at least one type of libraries -IF(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) - PRINT_WARNING("Both static and shared library generation were disabled" - "Building static libraries was re-enabled") - FORCE_VARIABLE(BUILD_STATIC_LIBS BOOL "Build static libraries" ON) -ENDIF(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) - -# --------------------------------------------------------------- -# Option to use the generic math libraries (UNIX only) -# --------------------------------------------------------------- - -IF(UNIX) - OPTION(USE_GENERIC_MATH "Use generic (std-c) math libraries" ON) - IF(USE_GENERIC_MATH) - # executables will be linked against -lm - SET(EXTRA_LINK_LIBS -lm) - # prepare substitution variable for sundials_config.h - SET(SUNDIALS_USE_GENERIC_MATH TRUE) - ENDIF(USE_GENERIC_MATH) -ENDIF(UNIX) - -## clock-monotonic, see if we need to link with rt -include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) -set(CMAKE_REQUIRED_LIBRARIES rt) -CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" SUNDIALS_POSIX_TIMERS) -set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) -if(SUNDIALS_POSIX_TIMERS) - find_library(SUNDIALS_RT_LIBRARY NAMES rt) - mark_as_advanced(SUNDIALS_RT_LIBRARY) - if(SUNDIALS_RT_LIBRARY) - # sundials_config.h symbol - SET(SUNDIALS_HAVE_POSIX_TIMERS TRUE) - set(EXTRA_LINK_LIBS ${EXTRA_LINK_LIBS} ${SUNDIALS_RT_LIBRARY}) - endif() -endif() - - -# =============================================================== -# Options for Parallelism -# =============================================================== - -# --------------------------------------------------------------- -# Enable MPI support? -# --------------------------------------------------------------- -OPTION(MPI_ENABLE "Enable MPI support" OFF) - -# --------------------------------------------------------------- -# Enable OpenMP support? -# --------------------------------------------------------------- -OPTION(OPENMP_ENABLE "Enable OpenMP support" OFF) - -# --------------------------------------------------------------- -# Enable Pthread support? -# --------------------------------------------------------------- -OPTION(PTHREAD_ENABLE "Enable Pthreads support" OFF) - -# ------------------------------------------------------------- -# Enable CUDA support? -# ------------------------------------------------------------- -OPTION(CUDA_ENABLE "Enable CUDA support" OFF) - -# ------------------------------------------------------------- -# Enable RAJA support? -# ------------------------------------------------------------- -OPTION(RAJA_ENABLE "Enable RAJA support" OFF) - - -# =============================================================== -# Options for external packages -# =============================================================== - -# --------------------------------------------------------------- -# Enable BLAS support? -# --------------------------------------------------------------- -OPTION(BLAS_ENABLE "Enable BLAS support" OFF) - -# --------------------------------------------------------------- -# Enable LAPACK/BLAS support? -# --------------------------------------------------------------- -OPTION(LAPACK_ENABLE "Enable Lapack support" OFF) - -# LAPACK does not support extended precision -IF(LAPACK_ENABLE AND SUNDIALS_PRECISION MATCHES "EXTENDED") - PRINT_WARNING("LAPACK is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling LAPACK") - FORCE_VARIABLE(LAPACK_ENABLE BOOL "LAPACK is disabled" OFF) -ENDIF() - -# LAPACK does not support 64-bit integer index types -IF(LAPACK_ENABLE AND SUNDIALS_INDEX_TYPE MATCHES "INT64_T") - PRINT_WARNING("LAPACK is not compatible with ${SUNDIALS_INDEX_TYPE} integers" - "Disabling LAPACK") - SET(LAPACK_ENABLE OFF CACHE BOOL "LAPACK is disabled" FORCE) -ENDIF() - -# --------------------------------------------------------------- -# Enable SuperLU_MT support? -# --------------------------------------------------------------- -OPTION(SUPERLUMT_ENABLE "Enable SUPERLUMT support" OFF) - -# SuperLU_MT does not support extended precision -IF(SUPERLUMT_ENABLE AND SUNDIALS_PRECISION MATCHES "EXTENDED") - PRINT_WARNING("SuperLU_MT is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling SuperLU_MT") - FORCE_VARIABLE(SUPERLUMT_ENABLE BOOL "SuperLU_MT is disabled" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable KLU support? -# --------------------------------------------------------------- -OPTION(KLU_ENABLE "Enable KLU support" OFF) - -# KLU does not support single or extended precision -IF(KLU_ENABLE AND - (SUNDIALS_PRECISION MATCHES "SINGLE" OR SUNDIALS_PRECISION MATCHES "EXTENDED")) - PRINT_WARNING("KLU is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling KLU") - FORCE_VARIABLE(KLU_ENABLE BOOL "KLU is disabled" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable hypre Vector support? -# --------------------------------------------------------------- -OPTION(HYPRE_ENABLE "Enable hypre support" OFF) - -# Using hypre requres building with MPI enabled -IF(HYPRE_ENABLE AND NOT MPI_ENABLE) - PRINT_WARNING("MPI not enabled - Disabling hypre" - "Set MPI_ENABLE to ON to use parhyp") - FORCE_VARIABLE(HYPRE_ENABLE BOOL "Enable hypre support" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable PETSc support? -# --------------------------------------------------------------- -OPTION(PETSC_ENABLE "Enable PETSc support" OFF) - -# Using PETSc requires building with MPI enabled -IF(PETSC_ENABLE AND NOT MPI_ENABLE) - PRINT_WARNING("MPI not enabled - Disabling PETSc" - "Set MPI_ENABLE to ON to use PETSc") - FORCE_VARIABLE(PETSC_ENABLE BOOL "Enable PETSc support" OFF) -ENDIF() - - -# =============================================================== -# Options for examples -# =============================================================== - -# --------------------------------------------------------------- -# Enable examples? -# --------------------------------------------------------------- - -# Enable C examples (on by default) -OPTION(EXAMPLES_ENABLE_C "Build SUNDIALS C examples" ON) - -# F77 examples (on by default) are an option only if the Fortran -# interface is enabled -SET(DOCSTR "Build SUNDIALS Fortran examples") -IF(FCMIX_ENABLE) - OPTION(EXAMPLES_ENABLE_F77 "${DOCSTR}" ON) - # Fortran examples do not support single or extended precision - IF(SUNDIALS_PRECISION MATCHES "EXTENDED" OR SUNDIALS_PRECISION MATCHES "SINGLE") - PRINT_WARNING("F77 examples are not compatible with ${SUNDIALS_PRECISION} precision" - "EXAMPLES_ENABLE_F77") - FORCE_VARIABLE(EXAMPLES_ENABLE_F77 BOOL "Fortran examples are disabled" OFF) - ENDIF() -ELSE() - # set back to OFF (in case was ON) - IF(EXAMPLES_ENABLE_F77) - PRINT_WARNING("EXAMPLES_ENABLE_F77 is ON but FCMIX is OFF" - "Disabling EXAMPLES_ENABLE_F77") - FORCE_VARIABLE(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(EXAMPLES_ENABLE_F77) -ENDIF() - -# C++ examples (off by default) are an option only if ARKode is enabled -SET(DOCSTR "Build ARKode C++ examples") -IF(BUILD_ARKODE) - SHOW_VARIABLE(EXAMPLES_ENABLE_CXX BOOL "${DOCSTR}" OFF) -ELSE() - # set back to OFF (in case was ON) - IF(EXAMPLES_ENABLE_CXX) - PRINT_WARNING("EXAMPLES_ENABLE_CXX is ON but BUILD_ARKODE is OFF" - "Disabling EXAMPLES_ENABLE_CXX") - FORCE_VARIABLE(EXAMPLES_ENABLE_CXX BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(EXAMPLES_ENABLE_CXX) -ENDIF() - -# F90 examples (off by default) are an option only if ARKode is -# built and the Fortran interface is enabled -SET(DOCSTR "Build ARKode F90 examples") -IF(FCMIX_ENABLE AND BUILD_ARKODE) - SHOW_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" OFF) - # Fortran90 examples do not support single or extended precision - # NOTE: This check can be removed after Fortran configure file is integrated into examples - IF(SUNDIALS_PRECISION MATCHES "EXTENDED" OR SUNDIALS_PRECISION MATCHES "SINGLE") - PRINT_WARNING("F90 examples are not compatible with ${SUNDIALS_PRECISION} precision" - "EXAMPLES_ENABLE_F90") - FORCE_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "Fortran90 examples are disabled" OFF) - ENDIF() -ELSE() - # set back to OFF (in case was ON) - IF(EXAMPLES_ENABLE_F90) - PRINT_WARNING("EXAMPLES_ENABLE_F90 is ON but FCMIX or BUILD_ARKODE is OFF" - "Disabling EXAMPLES_ENABLE_F90") - FORCE_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(EXAMPLES_ENABLE_F90) -ENDIF() - -# CUDA examples (off by default) -SET(DOCSTR "Build SUNDIALS CUDA examples") -IF(CUDA_ENABLE) - SHOW_VARIABLE(EXAMPLES_ENABLE_CUDA BOOL "${DOCSTR}" OFF) -ELSE() - IF(EXAMPLES_ENABLE_CUDA) - PRINT_WARNING("EXAMPLES_ENABLE_CUDA is ON but CUDA_ENABLE is OFF" - "Disabling EXAMPLES_ENABLE_CUDA") - FORCE_VARIABLE(EXAMPLES_ENABLE_CUDA BOOL "${DOCSTR}" OFF) - ENDIF() -ENDIF() - -# RAJA examples (off by default) -SET(DOCSTR "Build SUNDIALS RAJA examples") -IF(RAJA_ENABLE) - SHOW_VARIABLE(EXAMPLES_ENABLE_RAJA BOOL "${DOCSTR}" OFF) -ELSE() - IF(EXAMPLES_ENABLE_RAJA) - PRINT_WARNING("EXAMPLES_ENABLE_RAJA is ON but RAJA_ENABLE is OFF" - "Disabling EXAMPLES_ENABLE_RAJA") - FORCE_VARIABLE(EXAMPLES_ENABLE_RAJA BOOL "${DOCSTR}" OFF) - ENDIF() -ENDIF() - -# If any of the above examples are enabled set EXAMPLES_ENABLED to TRUE -IF(EXAMPLES_ENABLE_C OR - EXAMPLES_ENABLE_F77 OR - EXAMPLES_ENABLE_CXX OR - EXAMPLES_ENABLE_F90 OR - EXAMPLES_ENABLE_CUDA OR - EXAMPLES_ENABLE_RAJA) - SET(EXAMPLES_ENABLED TRUE) -ELSE() - SET(EXAMPLES_ENABLED FALSE) -ENDIF() - -# --------------------------------------------------------------- -# Install examples? -# --------------------------------------------------------------- - -IF(EXAMPLES_ENABLED) - - # If examples are enabled, set different options - - # The examples will be linked with the library corresponding to the build type. - # Whenever building shared libraries, use them to link the examples. - IF(BUILD_SHARED_LIBS) - SET(LINK_LIBRARY_TYPE "shared") - ELSE(BUILD_SHARED_LIBS) - SET(LINK_LIBRARY_TYPE "static") - ENDIF(BUILD_SHARED_LIBS) - - # Enable installing examples by default - SHOW_VARIABLE(EXAMPLES_INSTALL BOOL "Install example files" ON) - - # If examples are to be exported, check where we should install them. - IF(EXAMPLES_INSTALL) - - SHOW_VARIABLE(EXAMPLES_INSTALL_PATH PATH - "Output directory for installing example files" "${CMAKE_INSTALL_PREFIX}/examples") - - IF(NOT EXAMPLES_INSTALL_PATH) - PRINT_WARNING("The example installation path is empty" - "Example installation path was reset to its default value") - SET(EXAMPLES_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/examples" CACHE STRING - "Output directory for installing example files" FORCE) - ENDIF(NOT EXAMPLES_INSTALL_PATH) - - # create test_install target and directory for running smoke tests after - # installation - ADD_CUSTOM_TARGET(test_install) - - SET(TEST_INSTALL_DIR ${PROJECT_BINARY_DIR}/Testing_Install) - - IF(NOT EXISTS ${TEST_INSTALL_DIR}) - FILE(MAKE_DIRECTORY ${TEST_INSTALL_DIR}) - ENDIF() - - - ELSE(EXAMPLES_INSTALL) - - HIDE_VARIABLE(EXAMPLES_INSTALL_PATH) - - ENDIF(EXAMPLES_INSTALL) - -ELSE(EXAMPLES_ENABLED) - - # If examples are disabled, hide all options related to - # building and installing the SUNDIALS examples - - HIDE_VARIABLE(EXAMPLES_INSTALL) - HIDE_VARIABLE(EXAMPLES_INSTALL_PATH) - -ENDIF(EXAMPLES_ENABLED) - -# --------------------------------------------------------------- -# Include development examples in regression tests? -# --------------------------------------------------------------- -OPTION(SUNDIALS_DEVTESTS "Include development tests in make test" OFF) -MARK_AS_ADVANCED(FORCE SUNDIALS_DEVTESTS) - -# =============================================================== -# Add any other necessary compiler flags & definitions -# =============================================================== - -IF(APPLE) - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") -ENDIF(APPLE) - -# --------------------------------------------------------------- -# A Fortran compiler is needed if: -# (a) FCMIX is enabled -# (b) BLAS is enabled (for the name-mangling scheme) -# (c) LAPACK is enabled (for the name-mangling scheme) -# --------------------------------------------------------------- - -IF(FCMIX_ENABLE OR BLAS_ENABLE OR LAPACK_ENABLE) - INCLUDE(SundialsFortran) - IF(NOT F77_FOUND AND FCMIX_ENABLE) - PRINT_WARNING("Fortran compiler not functional" - "FCMIX support will not be provided") - ENDIF() -ENDIF() - -# --------------------------------------------------------------- -# A Fortran90 compiler is needed if: -# (a) F90 ARKODE examples are enabled -# --------------------------------------------------------------- - -IF(EXAMPLES_ENABLE_F90) - INCLUDE(SundialsFortran90) - IF(NOT F90_FOUND) - PRINT_WARNING("Fortran90 compiler not functional" - "F90 support will not be provided") - ENDIF() -ENDIF() - -# --------------------------------------------------------------- -# A C++ compiler is needed if: -# (a) C++ ARKODE examples are enabled -# (b) CUDA is enabled -# (c) RAJA is enabled -# --------------------------------------------------------------- - -IF(EXAMPLES_ENABLE_CXX OR CUDA_ENABLE OR RAJA_ENABLE) - INCLUDE(SundialsCXX) - IF(NOT CXX_FOUND) - PRINT_WARNING("C++ compiler not functional" - "C++ support will not be provided") - ENDIF() -ENDIF() - -# --------------------------------------------------------------- -# Check if we need an alternate way of specifying the Fortran -# name-mangling scheme if we were unable to infer it using a -# compiler. -# Ask the user to specify the case and number of appended underscores -# corresponding to the Fortran name-mangling scheme of symbol names -# that do not themselves contain underscores (recall that this is all -# we really need for the interfaces to LAPACK). -# Note: the default scheme is lower case - one underscore -# --------------------------------------------------------------- - -IF(BLAS_ENABLE OR LAPACK_ENABLE AND NOT F77SCHEME_FOUND) - # Specify the case for the Fortran name-mangling scheme - SHOW_VARIABLE(SUNDIALS_F77_FUNC_CASE STRING - "case of Fortran function names (lower/upper)" - "lower") - # Specify the number of appended underscores for the Fortran name-mangling scheme - SHOW_VARIABLE(SUNDIALS_F77_FUNC_UNDERSCORES STRING - "number of underscores appended to Fortran function names" - "one") - # Based on the given case and number of underscores, - # set the C preprocessor macro definition - IF(${SUNDIALS_F77_FUNC_CASE} MATCHES "lower") - IF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "none") - SET(CMAKE_Fortran_SCHEME_NO_UNDERSCORES "mysub") - ENDIF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "none") - IF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "one") - SET(CMAKE_Fortran_SCHEME_NO_UNDERSCORES "mysub_") - ENDIF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "one") - IF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "two") - SET(CMAKE_Fortran_SCHEME_NO_UNDERSCORES "mysub__") - ENDIF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "two") - ELSE(${SUNDIALS_F77_FUNC_CASE} MATCHES "lower") - IF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "none") - SET(CMAKE_Fortran_SCHEME_NO_UNDERSCORES "MYSUB") - ENDIF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "none") - IF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "one") - SET(CMAKE_Fortran_SCHEME_NO_UNDERSCORES "MYSUB_") - ENDIF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "one") - IF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "two") - SET(CMAKE_Fortran_SCHEME_NO_UNDERSCORES "MYSUB__") - ENDIF(${SUNDIALS_F77_FUNC_UNDERSCORES} MATCHES "two") - ENDIF(${SUNDIALS_F77_FUNC_CASE} MATCHES "lower") - # Since the SUNDIALS codes never use symbol names containing - # underscores, set a default scheme (probably wrong) for symbols - # with underscores. - SET(CMAKE_Fortran_SCHEME_WITH_UNDERSCORES "my_sub_") - # We now "have" a scheme. - SET(F77SCHEME_FOUND TRUE) -ENDIF(BLAS_ENABLE OR LAPACK_ENABLE AND NOT F77SCHEME_FOUND) - -# --------------------------------------------------------------- -# If we have a name-mangling scheme (either automatically -# inferred or provided by the user), set the SUNDIALS -# compiler preprocessor macro definitions. -# --------------------------------------------------------------- - -SET(F77_MANGLE_MACRO1 "") -SET(F77_MANGLE_MACRO2 "") - -IF(F77SCHEME_FOUND) - # Symbols WITHOUT underscores - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "mysub") - SET(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "mysub") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "mysub_") - SET(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name ## _") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "mysub_") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "mysub__") - SET(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name ## __") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "mysub__") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB") - SET(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB_") - SET(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME ## _") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB_") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB__") - SET(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME ## __") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB__") - # Symbols with underscores - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "my_sub") - SET(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "my_sub") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "my_sub_") - SET(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name ## _") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "my_sub_") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "my_sub__") - SET(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name ## __") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "my_sub__") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MY_SUB") - SET(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MY_SUB") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MY_SUB_") - SET(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## _") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MY_SUB_") - IF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MY_SUB__") - SET(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## __") - ENDIF(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MY_SUB__") -ENDIF(F77SCHEME_FOUND) - -# --------------------------------------------------------------- -# Decide how to compile MPI codes. -# --------------------------------------------------------------- - -IF(MPI_ENABLE) - # show command to run MPI codes (defaults to mpirun) - SHOW_VARIABLE(MPI_RUN_COMMAND STRING "MPI run command" "mpirun") - - INCLUDE(SundialsMPIC) - IF(MPIC_FOUND) - IF(CXX_FOUND AND EXAMPLES_ENABLE_CXX) - INCLUDE(SundialsMPICXX) - ENDIF() - IF(F77_FOUND AND EXAMPLES_ENABLE_F77) - INCLUDE(SundialsMPIF) - ENDIF() - IF(F90_FOUND AND EXAMPLES_ENABLE_F90) - INCLUDE(SundialsMPIF90) - ENDIF() - ELSE() - PRINT_WARNING("MPI not functional" - "Parallel support will not be provided") - ENDIF() - - IF(MPIC_MPI2) - SET(F77_MPI_COMM_F2C "#define SUNDIALS_MPI_COMM_F2C 1") - ELSE() - SET(F77_MPI_COMM_F2C "#define SUNDIALS_MPI_COMM_F2C 0") - ENDIF() - -ELSE() - - HIDE_VARIABLE(MPI_INCLUDE_PATH) - HIDE_VARIABLE(MPI_LIBRARIES) - HIDE_VARIABLE(MPI_EXTRA_LIBRARIES) - HIDE_VARIABLE(MPI_MPICC) - HIDE_VARIABLE(MPI_MPICXX) - HIDE_VARIABLE(MPI_MPIF77) - HIDE_VARIABLE(MPI_MPIF90) - -ENDIF(MPI_ENABLE) - -# --------------------------------------------------------------- -# If using MPI with C++, disable C++ extensions (for known wrappers) -# --------------------------------------------------------------- - -# IF(MPICXX_FOUND) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX -DLAM_BUILDING") -# ENDIF(MPICXX_FOUND) - -# ------------------------------------------------------------- -# Find OpenMP -# ------------------------------------------------------------- - -IF(OPENMP_ENABLE) - FIND_PACKAGE(OpenMP) - IF(NOT OPENMP_FOUND) - message(STATUS "Disabling OpenMP support, could not determine compiler flags") - ENDIF(NOT OPENMP_FOUND) -ENDIF(OPENMP_ENABLE) - -# ------------------------------------------------------------- -# Find PThreads -# ------------------------------------------------------------- - -IF(PTHREAD_ENABLE) - FIND_PACKAGE(Threads) - IF(CMAKE_USE_PTHREADS_INIT) - message(STATUS "Using Pthreads") - SET(PTHREADS_FOUND TRUE) - # SGS - ELSE() - message(STATUS "Disabling Pthreads support, could not determine compiler flags") - endif() -ENDIF(PTHREAD_ENABLE) - -# ------------------------------------------------------------- -# Find CUDA -# ------------------------------------------------------------- - -# disable CUDA if a working C++ compiler is not found -IF(CUDA_ENABLE AND (NOT CXX_FOUND)) - PRINT_WARNING("C++ compiler required for CUDA support" "Disabling CUDA") - FORCE_VARIABLE(CUDA_ENABLE BOOL "CUDA disabled" OFF) -ENDIF() - -if(CUDA_ENABLE) - find_package(CUDA) - - if (CUDA_FOUND) - #message("CUDA found!") - set(CUDA_NVCC_FLAGS "-lineinfo") - else() - message(STATUS "Disabling CUDA support, could not find CUDA.") - endif() -endif(CUDA_ENABLE) - -# ------------------------------------------------------------- -# Find RAJA -# ------------------------------------------------------------- - -# disable RAJA if CUDA is not enabled/working -IF(RAJA_ENABLE AND (NOT CUDA_FOUND)) - PRINT_WARNING("CUDA is required for RAJA support" "Please enable CUDA and RAJA") - FORCE_VARIABLE(RAJA_ENABLE BOOL "RAJA disabled" OFF) -ENDIF() - -# Check if C++11 compiler is available -IF(RAJA_ENABLE) - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) - - IF(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_STANDARD 11) - ELSE() - PRINT_WARNING("C++11 compliant compiler required for RAJA support" "Disabling RAJA") - FORCE_VARIABLE(RAJA_ENABLE BOOL "RAJA disabled" OFF) - ENDIF() -ENDIF() - -if(RAJA_ENABLE) - # Look for CMake configuration file in RAJA installation - find_package(RAJA CONFIGS) - if (RAJA_FOUND) - #message("RAJA found!") - include_directories(${RAJA_INCLUDE_DIR}) - set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${RAJA_NVCC_FLAGS}) - else() - PRINT_WARNING("RAJA configuration not found" "Please set RAJA_DIR to provide path to RAJA CMake configuration file.") - endif() -endif(RAJA_ENABLE) - -# =============================================================== -# Find (and test) external packages -# =============================================================== - -# --------------------------------------------------------------- -# Find (and test) the BLAS libraries -# --------------------------------------------------------------- - -# If BLAS is needed, first try to find the appropriate -# libraries and linker flags needed to link against them. - -IF(BLAS_ENABLE) - - # find BLAS - INCLUDE(SundialsBlas) - - # show after include so FindBlas can locate BLAS_LIBRARIES if necessary - SHOW_VARIABLE(BLAS_LIBRARIES STRING "Blas libraries" "${BLAS_LIBRARIES}") - - IF(BLAS_LIBRARIES AND NOT BLAS_FOUND) - PRINT_WARNING("BLAS not functional" - "BLAS support will not be provided") - ELSE() - #set sundials_config.h symbol via sundials_config.in - SET(SUNDIALS_BLAS TRUE) - ENDIF() - -ELSE() - - IF(NOT LAPACK_ENABLE) - HIDE_VARIABLE(SUNDIALS_F77_FUNC_CASE) - HIDE_VARIABLE(SUNDIALS_F77_FUNC_UNDERSCORES) - ENDIF() - HIDE_VARIABLE(BLAS_LIBRARIES) - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the Lapack libraries -# --------------------------------------------------------------- - -# If LAPACK is needed, first try to find the appropriate -# libraries and linker flags needed to link against them. - -IF(LAPACK_ENABLE) - - # find LAPACK and BLAS Libraries - INCLUDE(SundialsLapack) - - # show after include so FindLapack can locate LAPCK_LIBRARIES if necessary - SHOW_VARIABLE(LAPACK_LIBRARIES STRING "Lapack and Blas libraries" "${LAPACK_LIBRARIES}") - - IF(LAPACK_LIBRARIES AND NOT LAPACK_FOUND) - PRINT_WARNING("LAPACK not functional" - "Blas/Lapack support will not be provided") - ELSE() - #set sundials_config.h symbol via sundials_config.in - SET(SUNDIALS_BLAS_LAPACK TRUE) - ENDIF() - -ELSE() - - IF(NOT BLAS_ENABLE) - HIDE_VARIABLE(SUNDIALS_F77_FUNC_CASE) - HIDE_VARIABLE(SUNDIALS_F77_FUNC_UNDERSCORES) - ENDIF() - HIDE_VARIABLE(LAPACK_LIBRARIES) - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the SUPERLUMT libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for SuperLU_MT integer type - -# If SUPERLUMT is needed, first try to find the appropriate -# libraries to link against them. - -IF(SUPERLUMT_ENABLE) - - # Show SuperLU_MT options and set default thread type (Pthreads) - SHOW_VARIABLE(SUPERLUMT_THREAD_TYPE STRING "SUPERLUMT threading type: OpenMP or Pthread" "Pthread") - SHOW_VARIABLE(SUPERLUMT_INCLUDE_DIR PATH "SUPERLUMT include directory" "${SUPERLUMT_INCLUDE_DIR}") - SHOW_VARIABLE(SUPERLUMT_LIBRARY_DIR PATH "SUPERLUMT library directory" "${SUPERLUMT_LIBRARY_DIR}") - - INCLUDE(SundialsSuperLUMT) - - IF(SUPERLUMT_FOUND) - # sundials_config.h symbols - SET(SUNDIALS_SUPERLUMT TRUE) - SET(SUNDIALS_SUPERLUMT_THREAD_TYPE ${SUPERLUMT_THREAD_TYPE}) - INCLUDE_DIRECTORIES(${SUPERLUMT_INCLUDE_DIR}) - ENDIF() - - IF(SUPERLUMT_LIBRARIES AND NOT SUPERLUMT_FOUND) - PRINT_WARNING("SUPERLUMT not functional - support will not be provided" - "Double check spelling specified libraries (search is case sensitive)") - ENDIF(SUPERLUMT_LIBRARIES AND NOT SUPERLUMT_FOUND) - -ELSE() - - HIDE_VARIABLE(SUPERLUMT_THREAD_TYPE) - HIDE_VARIABLE(SUPERLUMT_LIBRARY_DIR) - HIDE_VARIABLE(SUPERLUMT_INCLUDE_DIR) - SET (SUPERLUMT_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the KLU libraries -# --------------------------------------------------------------- - -# If KLU is requested, first try to find the appropriate libraries to -# link against them. - -IF(KLU_ENABLE) - - SHOW_VARIABLE(KLU_INCLUDE_DIR PATH "KLU include directory" - "${KLU_INCLUDE_DIR}") - SHOW_VARIABLE(KLU_LIBRARY_DIR PATH - "Klu library directory" "${KLU_LIBRARY_DIR}") - - set(KLU_FOUND TRUE) - get_filename_component(PYBAMM_DIR ${PROJECT_SOURCE_DIR} DIRECTORY) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PYBAMM_DIR}) # use FindSuiteSparse.cmake that is in PyBaMM root - set(SuiteSparse_ROOT ${PYBAMM_DIR}/SuiteSparse-5.6.0) - find_package(SuiteSparse OPTIONAL_COMPONENTS KLU AMD COLAMD BTF) - include_directories(${SuiteSparse_INCLUDE_DIRS}) - set(KLU_LIBRARIES ${SuiteSparse_LIBRARIES}) - - IF(KLU_LIBRARIES AND NOT KLU_FOUND) - PRINT_WARNING("KLU not functional - support will not be provided" - "Double check spelling of include path and specified libraries (search is case sensitive)") - ENDIF(KLU_LIBRARIES AND NOT KLU_FOUND) - -ELSE() - - HIDE_VARIABLE(KLU_LIBRARY_DIR) - HIDE_VARIABLE(KLU_INCLUDE_DIR) - SET (KLU_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF(KLU_ENABLE) - -# --------------------------------------------------------------- -# Find (and test) the hypre libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for hypre precision and integer type - -IF(HYPRE_ENABLE) - SHOW_VARIABLE(HYPRE_INCLUDE_DIR PATH "HYPRE include directory" - "${HYPRE_INCLUDE_DIR}") - SHOW_VARIABLE(HYPRE_LIBRARY_DIR PATH - "HYPRE library directory" "${HYPRE_LIBRARY_DIR}") - - INCLUDE(SundialsHypre) - - IF(HYPRE_FOUND) - # sundials_config.h symbol - SET(SUNDIALS_HYPRE TRUE) - INCLUDE_DIRECTORIES(${HYPRE_INCLUDE_DIR}) - ENDIF(HYPRE_FOUND) - - IF(HYPRE_LIBRARIES AND NOT HYPRE_FOUND) - PRINT_WARNING("HYPRE not functional - support will not be provided" - "Found hypre library, test code does not work") - ENDIF(HYPRE_LIBRARIES AND NOT HYPRE_FOUND) - -ELSE() - - HIDE_VARIABLE(HYPRE_INCLUDE_DIR) - HIDE_VARIABLE(HYPRE_LIBRARY_DIR) - SET (HYPRE_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the PETSc libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for PETSc precision and integer type - -IF(PETSC_ENABLE) - SHOW_VARIABLE(PETSC_INCLUDE_DIR PATH "PETSc include directory" - "${PETSC_INCLUDE_DIR}") - SHOW_VARIABLE(PETSC_LIBRARY_DIR PATH - "PETSc library directory" "${PETSC_LIBRARY_DIR}") - - INCLUDE(SundialsPETSc) - - IF(PETSC_FOUND) - # sundials_config.h symbol - SET(SUNDIALS_PETSC TRUE) - INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIR}) - ENDIF(PETSC_FOUND) - - IF(PETSC_LIBRARIES AND NOT PETSC_FOUND) - PRINT_WARNING("PETSC not functional - support will not be provided" - "Double check spelling specified libraries (search is case sensitive)") - ENDIF(PETSC_LIBRARIES AND NOT PETSC_FOUND) - -ELSE() - - HIDE_VARIABLE(PETSC_LIBRARY_DIR) - HIDE_VARIABLE(PETSC_INCLUDE_DIR) - SET (PETSC_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - - -# =============================================================== -# Add source and configuration files -# =============================================================== - -# --------------------------------------------------------------- -# Configure the header file sundials_config.h -# --------------------------------------------------------------- - -# All required substitution variables should be available at this point. -# Generate the header file and place it in the binary dir. -CONFIGURE_FILE( - ${PROJECT_SOURCE_DIR}/include/sundials/sundials_config.in - ${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h - ) -CONFIGURE_FILE( - ${PROJECT_SOURCE_DIR}/include/sundials/sundials_fconfig.in - ${PROJECT_BINARY_DIR}/include/sundials/sundials_fconfig.h - ) - -# Add the include directory in the source tree and the one in -# the binary tree (for the header file sundials_config.h) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - -# --------------------------------------------------------------- -# Add selected modules to the build system -# --------------------------------------------------------------- - -# Shared components - -ADD_SUBDIRECTORY(src/sundials) -ADD_SUBDIRECTORY(src/nvec_ser) -ADD_SUBDIRECTORY(src/sunmat_dense) -ADD_SUBDIRECTORY(src/sunmat_band) -ADD_SUBDIRECTORY(src/sunmat_sparse) -ADD_SUBDIRECTORY(src/sunlinsol_band) -ADD_SUBDIRECTORY(src/sunlinsol_dense) -IF(KLU_FOUND) - ADD_SUBDIRECTORY(src/sunlinsol_klu) -ENDIF(KLU_FOUND) -IF(SUPERLUMT_FOUND) - ADD_SUBDIRECTORY(src/sunlinsol_superlumt) -ENDIF(SUPERLUMT_FOUND) -IF(LAPACK_FOUND) - ADD_SUBDIRECTORY(src/sunlinsol_lapackband) - ADD_SUBDIRECTORY(src/sunlinsol_lapackdense) -ENDIF(LAPACK_FOUND) -ADD_SUBDIRECTORY(src/sunlinsol_spgmr) -ADD_SUBDIRECTORY(src/sunlinsol_spfgmr) -ADD_SUBDIRECTORY(src/sunlinsol_spbcgs) -ADD_SUBDIRECTORY(src/sunlinsol_sptfqmr) -ADD_SUBDIRECTORY(src/sunlinsol_pcg) -IF(MPIC_FOUND) - ADD_SUBDIRECTORY(src/nvec_par) -ENDIF(MPIC_FOUND) - -IF(HYPRE_FOUND) - ADD_SUBDIRECTORY(src/nvec_parhyp) -ENDIF(HYPRE_FOUND) - -IF(OPENMP_FOUND) - ADD_SUBDIRECTORY(src/nvec_openmp) -ENDIF(OPENMP_FOUND) - -IF(PTHREADS_FOUND) - ADD_SUBDIRECTORY(src/nvec_pthreads) -ENDIF(PTHREADS_FOUND) - -IF(PETSC_FOUND) - ADD_SUBDIRECTORY(src/nvec_petsc) -ENDIF(PETSC_FOUND) - -IF(CUDA_FOUND) - ADD_SUBDIRECTORY(src/nvec_cuda) -ENDIF(CUDA_FOUND) - -IF(RAJA_FOUND) - ADD_SUBDIRECTORY(src/nvec_raja) -ENDIF(RAJA_FOUND) - -# ARKODE library - -IF(BUILD_ARKODE) - ADD_SUBDIRECTORY(src/arkode) - IF(FCMIX_ENABLE AND F77_FOUND) - ADD_SUBDIRECTORY(src/arkode/fcmix) - ENDIF(FCMIX_ENABLE AND F77_FOUND) -ENDIF(BUILD_ARKODE) - -# CVODE library - -IF(BUILD_CVODE) - ADD_SUBDIRECTORY(src/cvode) - IF(FCMIX_ENABLE AND F77_FOUND) - ADD_SUBDIRECTORY(src/cvode/fcmix) - ENDIF(FCMIX_ENABLE AND F77_FOUND) -ENDIF(BUILD_CVODE) - -# CVODES library - -IF(BUILD_CVODES) - ADD_SUBDIRECTORY(src/cvodes) -ENDIF(BUILD_CVODES) - -# IDA library - -IF(BUILD_IDA) - ADD_SUBDIRECTORY(src/ida) - IF(FCMIX_ENABLE AND F77_FOUND) - ADD_SUBDIRECTORY(src/ida/fcmix) - ENDIF(FCMIX_ENABLE AND F77_FOUND) -ENDIF(BUILD_IDA) - -# IDAS library - -IF(BUILD_IDAS) - ADD_SUBDIRECTORY(src/idas) -ENDIF(BUILD_IDAS) - -# KINSOL library - -IF(BUILD_KINSOL) - ADD_SUBDIRECTORY(src/kinsol) - IF(FCMIX_ENABLE AND F77_FOUND) - ADD_SUBDIRECTORY(src/kinsol/fcmix) - ENDIF(FCMIX_ENABLE AND F77_FOUND) -ENDIF(BUILD_KINSOL) - -# CPODES library - -IF(BUILD_CPODES) - ADD_SUBDIRECTORY(src/cpodes) -ENDIF(BUILD_CPODES) - -# --------------------------------------------------------------- -# Include the subdirectories corresponding to various examples -# --------------------------------------------------------------- - -# If building and installing the examples is enabled, include -# the subdirectories for those examples that will be built. -# Also, if we will generate exported example Makefiles, set -# variables needed in generating them from templates. - -# For now, TestRunner is not being distributed. -# So: -# - Don't show TESTRUNNER variable -# - Don't enable testing if TestRunner if not found. -# - There will be no 'make test' target - -INCLUDE(SundialsAddTest) -HIDE_VARIABLE(TESTRUNNER) - -IF(EXAMPLES_ENABLED) - - # enable regression testing with 'make test' - IF(TESTRUNNER) - ENABLE_TESTING() - ENDIF() - - # set variables used in generating CMake and Makefiles for examples - IF(EXAMPLES_INSTALL) - - SET(SHELL "sh") - SET(prefix "${CMAKE_INSTALL_PREFIX}") - SET(exec_prefix "${CMAKE_INSTALL_PREFIX}") - SET(includedir "${prefix}/include") - SET(libdir "${exec_prefix}/lib") - SET(CPP "${CMAKE_C_COMPILER}") - SET(CPPFLAGS "${CMAKE_C_FLAGS_RELEASE}") - SET(CC "${CMAKE_C_COMPILER}") - SET(CFLAGS "${CMAKE_C_FLAGS_RELEASE}") - SET(LDFLAGS "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") - LIST2STRING(EXTRA_LINK_LIBS LIBS) - - IF(CXX_FOUND) - SET(CXX "${CMAKE_CXX_COMPILER}") - SET(CXX_LNKR "${CMAKE_CXX_COMPILER}") - SET(CXXFLAGS "${CMAKE_CXX_FLAGS_RELEASE}") - SET(CXX_LDFLAGS "${CMAKE_CXX_FLAGS_RELEASE}") - LIST2STRING(EXTRA_LINK_LIBS CXX_LIBS) - ENDIF(CXX_FOUND) - - IF(F77_FOUND) - SET(F77 "${CMAKE_Fortran_COMPILER}") - SET(F77_LNKR "${CMAKE_Fortran_COMPILER}") - SET(FFLAGS "${CMAKE_Fortran_FLAGS_RELEASE}") - SET(F77_LDFLAGS "${CMAKE_Fortran_FLAGS_RELEASE}") - LIST2STRING(EXTRA_LINK_LIBS F77_LIBS) - ENDIF(F77_FOUND) - - IF(F90_FOUND) - SET(F90 "${CMAKE_Fortran_COMPILER}") - SET(F90_LNKR "${CMAKE_Fortran_COMPILER}") - SET(F90FLAGS "${CMAKE_Fortran_FLAGS_RELEASE}") - SET(F90_LDFLAGS "${CMAKE_Fortran_FLAGS_RELEASE}") - LIST2STRING(EXTRA_LINK_LIBS F90_LIBS) - ENDIF(F90_FOUND) - - IF(SUPERLUMT_FOUND) - LIST2STRING(SUPERLUMT_LIBRARIES SUPERLUMT_LIBS) - SET(SUPERLUMT_LIBS "${SUPERLUMT_LINKER_FLAGS} ${SUPERLUMT_LIBS}") - ENDIF(SUPERLUMT_FOUND) - - IF(KLU_FOUND) - LIST2STRING(KLU_LIBRARIES KLU_LIBS) - SET(KLU_LIBS "${KLU_LINKER_FLAGS} ${KLU_LIBS}") - ENDIF(KLU_FOUND) - - IF(BLAS_FOUND) - LIST2STRING(BLAS_LIBRARIES BLAS_LIBS) - ENDIF(BLAS_FOUND) - - IF(LAPACK_FOUND) - LIST2STRING(LAPACK_LIBRARIES LAPACK_LIBS) - ENDIF(LAPACK_FOUND) - - IF(MPIC_FOUND) - IF(MPI_MPICC) - SET(MPICC "${MPI_MPICC}") - SET(MPI_INC_DIR ".") - SET(MPI_LIB_DIR ".") - SET(MPI_LIBS "") - SET(MPI_FLAGS "") - ELSE(MPI_MPICC) - SET(MPICC "${CMAKE_C_COMPILER}") - SET(MPI_INC_DIR "${MPI_INCLUDE_PATH}") - SET(MPI_LIB_DIR ".") - LIST2STRING(MPI_LIBRARIES MPI_LIBS) - ENDIF(MPI_MPICC) - SET(HYPRE_INC_DIR "${HYPRE_INCLUDE_DIR}") - SET(HYPRE_LIB_DIR "${HYPRE_LIBRARY_DIR}") - SET(HYPRE_LIBS "${HYPRE_LIBRARIES}") - ENDIF(MPIC_FOUND) - - IF(MPICXX_FOUND) - IF(MPI_MPICXX) - SET(MPICXX "${MPI_MPICXX}") - ELSE(MPI_MPICXX) - SET(MPICXX "${CMAKE_CXX_COMPILER}") - LIST2STRING(MPI_LIBRARIES MPI_LIBS) - ENDIF(MPI_MPICXX) - ENDIF(MPICXX_FOUND) - - IF(MPIF_FOUND) - IF(MPI_MPIF77) - SET(MPIF77 "${MPI_MPIF77}") - SET(MPIF77_LNKR "${MPI_MPIF77}") - ELSE(MPI_MPIF77) - SET(MPIF77 "${CMAKE_Fortran_COMPILER}") - SET(MPIF77_LNKR "${CMAKE_Fortran_COMPILER}") - SET(MPI_INC_DIR "${MPI_INCLUDE_PATH}") - SET(MPI_LIB_DIR ".") - LIST2STRING(MPI_LIBRARIES MPI_LIBS) - ENDIF(MPI_MPIF77) - ENDIF(MPIF_FOUND) - - IF(MPIF90_FOUND) - IF(MPI_MPIF90) - SET(MPIF90 "${MPI_MPIF90}") - SET(MPIF90_LNKR "${MPI_MPIF90}") - ELSE(MPI_MPIF90) - SET(MPIF90 "${CMAKE_Fortran_COMPILER}") - SET(MPIF90_LNKR "${CMAKE_Fortran_COMPILER}") - LIST2STRING(MPI_LIBRARIES MPI_LIBS) - ENDIF(MPI_MPIF90) - ENDIF(MPIF90_FOUND) - - ENDIF(EXAMPLES_INSTALL) - - # add ARKode examples - IF(BUILD_ARKODE) - # C examples - IF(EXAMPLES_ENABLE_C) - ADD_SUBDIRECTORY(examples/arkode/C_serial) - IF(OPENMP_FOUND) - ADD_SUBDIRECTORY(examples/arkode/C_openmp) - ENDIF() - IF(MPIC_FOUND) - ADD_SUBDIRECTORY(examples/arkode/C_parallel) - ENDIF() - IF(HYPRE_ENABLE AND HYPRE_FOUND) - ADD_SUBDIRECTORY(examples/arkode/C_parhyp) - ENDIF() - ENDIF() - # C++ examples - IF(EXAMPLES_ENABLE_CXX) - IF(CXX_FOUND) - ADD_SUBDIRECTORY(examples/arkode/CXX_serial) - ENDIF() - IF(MPICXX_FOUND) - ADD_SUBDIRECTORY(examples/arkode/CXX_parallel) - ENDIF() - ENDIF() - # F77 examples - IF(EXAMPLES_ENABLE_F77) - IF(F77_FOUND) - ADD_SUBDIRECTORY(examples/arkode/F77_serial) - ENDIF() - IF(MPIF_FOUND) - ADD_SUBDIRECTORY(examples/arkode/F77_parallel) - ENDIF() - ENDIF() - # F90 examples - IF(EXAMPLES_ENABLE_F90) - IF(F90_FOUND) - ADD_SUBDIRECTORY(examples/arkode/F90_serial) - ENDIF() - IF(MPIF90_FOUND) - ADD_SUBDIRECTORY(examples/arkode/F90_parallel) - ENDIF() - ENDIF() - ENDIF(BUILD_ARKODE) - - # add CVODE examples - IF(BUILD_CVODE) - # C examples - IF(EXAMPLES_ENABLE_C) - ADD_SUBDIRECTORY(examples/cvode/serial) - IF(OPENMP_FOUND) - ADD_SUBDIRECTORY(examples/cvode/C_openmp) - ENDIF() - IF(MPIC_FOUND) - ADD_SUBDIRECTORY(examples/cvode/parallel) - ENDIF() - IF(HYPRE_ENABLE AND HYPRE_FOUND) - ADD_SUBDIRECTORY(examples/cvode/parhyp) - ENDIF() - ENDIF() - # Fortran examples - IF(EXAMPLES_ENABLE_F77) - IF(F77_FOUND) - ADD_SUBDIRECTORY(examples/cvode/fcmix_serial) - ENDIF() - IF(MPIF_FOUND) - ADD_SUBDIRECTORY(examples/cvode/fcmix_parallel) - ENDIF() - ENDIF() - # cuda examples - IF(EXAMPLES_ENABLE_CUDA) - IF(CUDA_ENABLE AND CUDA_FOUND) - ADD_SUBDIRECTORY(examples/cvode/cuda) - ENDIF() - ENDIF(EXAMPLES_ENABLE_CUDA) - # raja examples - IF(EXAMPLES_ENABLE_RAJA) - IF(RAJA_ENABLE AND RAJA_FOUND) - ADD_SUBDIRECTORY(examples/cvode/raja) - ENDIF() - ENDIF(EXAMPLES_ENABLE_RAJA) - ENDIF(BUILD_CVODE) - - # add CVODES Examples - IF(BUILD_CVODES) - # C examples - IF(EXAMPLES_ENABLE_C) - ADD_SUBDIRECTORY(examples/cvodes/serial) - IF(MPIC_FOUND) - ADD_SUBDIRECTORY(examples/cvodes/parallel) - ENDIF() - IF(OPENMP_FOUND) - ADD_SUBDIRECTORY(examples/cvodes/C_openmp) - ENDIF() - ENDIF() - ENDIF(BUILD_CVODES) - - # add IDA examples - IF(BUILD_IDA) - # C examples - IF(EXAMPLES_ENABLE_C) - ADD_SUBDIRECTORY(examples/ida/serial) - IF(OPENMP_FOUND) - ADD_SUBDIRECTORY(examples/ida/C_openmp) - ENDIF() - IF(MPIC_FOUND) - ADD_SUBDIRECTORY(examples/ida/parallel) - ENDIF() - IF(PETSC_FOUND) - ADD_SUBDIRECTORY(examples/ida/petsc) - ENDIF() - ENDIF() - # Fortran examples - IF(EXAMPLES_ENABLE_F77) - IF(F77_FOUND) - ADD_SUBDIRECTORY(examples/ida/fcmix_serial) - ENDIF() - IF(OPENMP_FOUND) - ADD_SUBDIRECTORY(examples/ida/fcmix_openmp) - ENDIF() - IF(PTHREADS_FOUND) - ADD_SUBDIRECTORY(examples/ida/fcmix_pthreads) - ENDIF() - IF(MPIF_FOUND) - ADD_SUBDIRECTORY(examples/ida/fcmix_parallel) - ENDIF() - ENDIF() - ENDIF(BUILD_IDA) - - # add IDAS examples - IF(BUILD_IDAS) - # C examples - IF(EXAMPLES_ENABLE_C) - ADD_SUBDIRECTORY(examples/idas/serial) - IF(OPENMP_FOUND) - ADD_SUBDIRECTORY(examples/idas/C_openmp) - ENDIF() - IF(MPIC_FOUND) - ADD_SUBDIRECTORY(examples/idas/parallel) - ENDIF() - ENDIF() - ENDIF(BUILD_IDAS) - - # add KINSOL examples - IF(BUILD_KINSOL) - # C examples - IF(EXAMPLES_ENABLE_C) - ADD_SUBDIRECTORY(examples/kinsol/serial) - IF(OPENMP_FOUND) - # the only example here need special handling from testrunner (not yet implemented) - ADD_SUBDIRECTORY(examples/kinsol/C_openmp) - ENDIF() - IF(MPIC_FOUND) - ADD_SUBDIRECTORY(examples/kinsol/parallel) - ENDIF() - ENDIF() - # Fortran examples - IF(EXAMPLES_ENABLE_F77) - IF(F77_FOUND) - ADD_SUBDIRECTORY(examples/kinsol/fcmix_serial) - ENDIF() - IF(MPIF_FOUND) - ADD_SUBDIRECTORY(examples/kinsol/fcmix_parallel) - ENDIF() - ENDIF() - ENDIF(BUILD_KINSOL) - - # add CPODES examples - IF(BUILD_CPODES) - IF(EXAMPLES_ENABLE_C) - ADD_SUBDIRECTORY(examples/cpodes/serial) - IF(MPIC_FOUND) - ADD_SUBDIRECTORY(examples/cpodes/parallel) - ENDIF() - ENDIF() - ENDIF(BUILD_CPODES) - - # Always add the nvector serial examples - ADD_SUBDIRECTORY(examples/nvector/serial) - - # # Always add the serial sunmatrix dense/band/sparse examples - ADD_SUBDIRECTORY(examples/sunmatrix/dense) - ADD_SUBDIRECTORY(examples/sunmatrix/band) - ADD_SUBDIRECTORY(examples/sunmatrix/sparse) - - # # Always add the serial sunlinearsolver dense/band/spils examples - ADD_SUBDIRECTORY(examples/sunlinsol/band) - ADD_SUBDIRECTORY(examples/sunlinsol/dense) - IF(KLU_FOUND) - ADD_SUBDIRECTORY(examples/sunlinsol/klu) - ENDIF(KLU_FOUND) - IF(SUPERLUMT_FOUND) - ADD_SUBDIRECTORY(examples/sunlinsol/superlumt) - ENDIF(SUPERLUMT_FOUND) - IF(LAPACK_FOUND) - ADD_SUBDIRECTORY(examples/sunlinsol/lapackband) - ADD_SUBDIRECTORY(examples/sunlinsol/lapackdense) - ENDIF(LAPACK_FOUND) - ADD_SUBDIRECTORY(examples/sunlinsol/spgmr/serial) - ADD_SUBDIRECTORY(examples/sunlinsol/spfgmr/serial) - ADD_SUBDIRECTORY(examples/sunlinsol/spbcgs/serial) - ADD_SUBDIRECTORY(examples/sunlinsol/sptfqmr/serial) - ADD_SUBDIRECTORY(examples/sunlinsol/pcg/serial) - - IF(MPIC_FOUND) - ADD_SUBDIRECTORY(examples/nvector/parallel) - ADD_SUBDIRECTORY(examples/sunlinsol/spgmr/parallel) - ADD_SUBDIRECTORY(examples/sunlinsol/spfgmr/parallel) - ADD_SUBDIRECTORY(examples/sunlinsol/spbcgs/parallel) - ADD_SUBDIRECTORY(examples/sunlinsol/sptfqmr/parallel) - #ADD_SUBDIRECTORY(examples/sunlinsol/pcg/parallel) - ENDIF(MPIC_FOUND) - - IF(HYPRE_FOUND) - ADD_SUBDIRECTORY(examples/nvector/parhyp) - ENDIF() - - IF(PTHREADS_FOUND) - ADD_SUBDIRECTORY(examples/nvector/pthreads) - ENDIF() - - IF(OPENMP_FOUND) - ADD_SUBDIRECTORY(examples/nvector/C_openmp) - ENDIF() - - IF(PETSC_FOUND) - ADD_SUBDIRECTORY(examples/nvector/petsc) - ENDIF() - - IF(CUDA_FOUND) - ADD_SUBDIRECTORY(examples/nvector/cuda) - ENDIF(CUDA_FOUND) - - IF(RAJA_FOUND) - ADD_SUBDIRECTORY(examples/nvector/raja) - ENDIF(RAJA_FOUND) - -ENDIF(EXAMPLES_ENABLED) - -# --------------------------------------------------------------- -# Install configuration header files and license file -# --------------------------------------------------------------- - -# install configured header file -INSTALL( - FILES ${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h - DESTINATION include/sundials - ) - -# install configured header file for Fortran 90 -INSTALL( - FILES ${PROJECT_BINARY_DIR}/include/sundials/sundials_fconfig.h - DESTINATION include/sundials - ) - -# install license file -INSTALL( - FILES ${PROJECT_SOURCE_DIR}/LICENSE - DESTINATION .) diff --git a/scripts/replace-cmake/sundials-4.1.0/CMakeLists.txt b/scripts/replace-cmake/sundials-4.1.0/CMakeLists.txt deleted file mode 100644 index fc8acbddc9..0000000000 --- a/scripts/replace-cmake/sundials-4.1.0/CMakeLists.txt +++ /dev/null @@ -1,1151 +0,0 @@ -# --------------------------------------------------------------- -# Programmer: Radu Serban, David J. Gardner, Cody J. Balos, -# and Slaven Peles @ LLNL -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2019, Lawrence Livermore National Security -# and Southern Methodist University. -# All rights reserved. -# -# See the top-level LICENSE and NOTICE files for details. -# -# SPDX-License-Identifier: BSD-3-Clause -# SUNDIALS Copyright End -# --------------------------------------------------------------- -# Top level CMakeLists.txt for SUNDIALS (for cmake build system) -# --------------------------------------------------------------- - -# --------------------------------------------------------------- -# Initial commands -# --------------------------------------------------------------- - -# Require a fairly recent cmake version -cmake_minimum_required(VERSION 3.1.3) - -# Libraries linked via full path no longer produce linker search paths -# Allows examples to build -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -# MACOSX_RPATH is enabled by default -# Fixes dynamic loading on OSX -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) # Added in CMake 3.0 -else() - if(APPLE) - set(CMAKE_MACOSX_RPATH 1) - endif() -endif() - -# Project SUNDIALS (initially only C supported) -# sets PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR variables -PROJECT(sundials C) - -# Set some variables with info on the SUNDIALS project -SET(PACKAGE_BUGREPORT "woodward6@llnl.gov") -SET(PACKAGE_NAME "SUNDIALS") -SET(PACKAGE_STRING "SUNDIALS 4.1.0") -SET(PACKAGE_TARNAME "sundials") - -# set SUNDIALS version numbers -# (use "" for the version label if none is needed) -SET(PACKAGE_VERSION_MAJOR "4") -SET(PACKAGE_VERSION_MINOR "1") -SET(PACKAGE_VERSION_PATCH "0") -SET(PACKAGE_VERSION_LABEL "") - -IF(PACKAGE_VERSION_LABEL) - SET(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}-${PACKAGE_VERSION_LABEL}") -ELSE() - SET(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}") -ENDIF() - -SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) - -# Prohibit in-source build -IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - MESSAGE(FATAL_ERROR "In-source build prohibited.") -ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - -# Hide some cache variables -MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) - -# Always show the C compiler and flags -MARK_AS_ADVANCED(CLEAR - CMAKE_C_COMPILER - CMAKE_C_FLAGS) - -# Specify the VERSION and SOVERSION for shared libraries - -SET(arkodelib_VERSION "3.1.0") -SET(arkodelib_SOVERSION "3") - -SET(cvodelib_VERSION "4.1.0") -SET(cvodelib_SOVERSION "4") - -SET(cvodeslib_VERSION "4.1.0") -SET(cvodeslib_SOVERSION "4") - -SET(idalib_VERSION "4.1.0") -SET(idalib_SOVERSION "4") - -SET(idaslib_VERSION "3.1.0") -SET(idaslib_SOVERSION "3") - -SET(kinsollib_VERSION "4.1.0") -SET(kinsollib_SOVERSION "4") - -SET(cpodeslib_VERSION "0.0.0") -SET(cpodeslib_SOVERSION "0") - -SET(nveclib_VERSION "4.1.0") -SET(nveclib_SOVERSION "4") - -SET(sunmatrixlib_VERSION "2.1.0") -SET(sunmatrixlib_SOVERSION "2") - -SET(sunlinsollib_VERSION "2.1.0") -SET(sunlinsollib_SOVERSION "2") - -SET(sunnonlinsollib_VERSION "1.1.0") -SET(sunnonlinsollib_SOVERSION "1") - -# Specify the location of additional CMAKE modules -SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/config) - -# Get correct build paths automatically, but expose CMAKE_INSTALL_LIBDIR -# as a regular cache variable so that a user can more easily see what -# the library dir was set to be by GNUInstallDirs. -INCLUDE(GNUInstallDirs) -MARK_AS_ADVANCED(CLEAR CMAKE_INSTALL_LIBDIR) - -# --------------------------------------------------------------- -# Which modules to build? -# --------------------------------------------------------------- - -# For each SUNDIALS solver available (i.e. for which we have the -# sources), give the user the option of enabling/disabling it. - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/arkode") - OPTION(BUILD_ARKODE "Build the ARKODE library" ON) -ELSE() - SET(BUILD_ARKODE OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cvode") - OPTION(BUILD_CVODE "Build the CVODE library" ON) -ELSE() - SET(BUILD_CVODE OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cvodes") - OPTION(BUILD_CVODES "Build the CVODES library" ON) -ELSE() - SET(BUILD_CVODES OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/ida") - OPTION(BUILD_IDA "Build the IDA library" ON) -ELSE() - SET(BUILD_IDA OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/idas") - OPTION(BUILD_IDAS "Build the IDAS library" ON) -ELSE() - SET(BUILD_IDAS OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/kinsol") - OPTION(BUILD_KINSOL "Build the KINSOL library" ON) -ELSE() - SET(BUILD_KINSOL OFF) -ENDIF() - -# CPODES is always OFF for now. (commented out for Release); ToDo: better way to do this? -#IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes") -# OPTION(BUILD_CPODES "Build the CPODES library" OFF) -#ELSE() -# SET(BUILD_CPODES OFF) -#ENDIF() - -# --------------------------------------------------------------- -# MACRO definitions -# --------------------------------------------------------------- -INCLUDE(CMakeParseArguments) # can be removed when CMake 3.5+ is required -INCLUDE(SundialsCMakeMacros) -INCLUDE(SundialsAddF2003InterfaceLibrary) -INCLUDE(SundialsAddTest) -INCLUDE(SundialsAddTestInstall) - -# --------------------------------------------------------------- -# Check for deprecated SUNDIALS CMake options/variables -# --------------------------------------------------------------- -INCLUDE(SundialsDeprecated) - -# --------------------------------------------------------------- -# xSDK specific options -# --------------------------------------------------------------- -INCLUDE(SundialsXSDK) - -# --------------------------------------------------------------- -# Build specific C flags -# --------------------------------------------------------------- - -# Hide all build type specific flags -MARK_AS_ADVANCED(FORCE - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_RELWITHDEBINFO) - -# Only show flags for the current build type if it is set -# NOTE: Build specific flags are appended those in CMAKE_C_FLAGS -IF(CMAKE_BUILD_TYPE) - IF(CMAKE_BUILD_TYPE MATCHES "Debug") - MESSAGE("Appending C debug flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_DEBUG) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "MinSizeRel") - MESSAGE("Appending C min size release flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_MINSIZEREL) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "Release") - MESSAGE("Appending C release flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_RELEASE) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") - MESSAGE("Appending C release with debug info flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_RELWITHDEBINFO) - ENDIF() -ENDIF() - -# --------------------------------------------------------------- -# Option to specify precision (realtype) -# --------------------------------------------------------------- - -SET(DOCSTR "single, double, or extended") -SHOW_VARIABLE(SUNDIALS_PRECISION STRING "${DOCSTR}" "double") - -# prepare substitution variable PRECISION_LEVEL for sundials_config.h -STRING(TOUPPER ${SUNDIALS_PRECISION} SUNDIALS_PRECISION) -SET(PRECISION_LEVEL "#define SUNDIALS_${SUNDIALS_PRECISION}_PRECISION 1") - -# prepare substitution variable FPRECISION_LEVEL for sundials_fconfig.h -IF(SUNDIALS_PRECISION MATCHES "SINGLE") - SET(FPRECISION_LEVEL "4") -ENDIF(SUNDIALS_PRECISION MATCHES "SINGLE") -IF(SUNDIALS_PRECISION MATCHES "DOUBLE") - SET(FPRECISION_LEVEL "8") -ENDIF(SUNDIALS_PRECISION MATCHES "DOUBLE") -IF(SUNDIALS_PRECISION MATCHES "EXTENDED") - SET(FPRECISION_LEVEL "16") -ENDIF(SUNDIALS_PRECISION MATCHES "EXTENDED") - -# --------------------------------------------------------------- -# Option to specify index type -# --------------------------------------------------------------- - -SET(DOCSTR "Signed 64-bit (64) or signed 32-bit (32) integer") -SHOW_VARIABLE(SUNDIALS_INDEX_SIZE STRING "${DOCSTR}" "64") -SET(DOCSTR "Integer type to use for indices in SUNDIALS") -SHOW_VARIABLE(SUNDIALS_INDEX_TYPE STRING "${DOCSTR}" "") -MARK_AS_ADVANCED(SUNDIALS_INDEX_TYPE) -include(SundialsIndexSize) - -# --------------------------------------------------------------- -# Enable Fortran interface? -# --------------------------------------------------------------- - -# Fortran interface is disabled by default -SET(DOCSTR "Enable Fortran 77 interfaces") -OPTION(F77_INTERFACE_ENABLE "${DOCSTR}" OFF) - -# Check that at least one solver with a Fortran 77 interface is built -IF(NOT BUILD_ARKODE AND NOT BUILD_CVODE AND NOT BUILD_IDA AND NOT BUILD_KINSOL) - IF(F77_INTERFACE_ENABLE) - PRINT_WARNING("Enabled packages do not support Fortran 77 interface" "Disabling F77 interface") - FORCE_VARIABLE(F77_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(F77_INTERFACE_ENABLE) -ENDIF() - -# Fortran 2003 interface is disabled by default -SET(DOCSTR "Enable Fortran 2003 interfaces") -OPTION(F2003_INTERFACE_ENABLE "${DOCSTR}" OFF) - -# Check that at least one solver with a Fortran 2003 interface is built -IF(NOT BUILD_CVODE) - IF(F2003_INTERFACE_ENABLE) - PRINT_WARNING("Enabled packages do not support Fortran 2003 interface" "Disabling F2003 interface") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(F2003_INTERFACE_ENABLE) -ENDIF() - -IF(F2003_INTERFACE_ENABLE) - # F2003 interface only supports double precision - IF(NOT (SUNDIALS_PRECISION MATCHES "DOUBLE")) - PRINT_WARNING("F2003 interface is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling F2003 interface") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - - # F2003 interface only supports 64-bit indices - IF(NOT (SUNDIALS_INDEX_SIZE MATCHES "64")) - PRINT_WARNING("F2003 interface is not compatible with ${SUNDIALS_INDEX_SIZE}-bit indicies" - "Disabling F2003 interface") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - - # Put all F2003 modules into one build directory - SET(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/fortran") - - # Allow a user to set where the Fortran modules will be installed - SET(DOCSTR "Directory where Fortran module files are installed") - SHOW_VARIABLE(Fortran_INSTALL_MODDIR DIRECTORY "${DOCSTR}" "fortran") -ENDIF() - -# --------------------------------------------------------------- -# Options to build static and/or shared libraries -# --------------------------------------------------------------- - -OPTION(BUILD_STATIC_LIBS "Build static libraries" ON) -OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) - -# Make sure we build at least one type of libraries -IF(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) - PRINT_WARNING("Both static and shared library generation were disabled" - "Building static libraries was re-enabled") - FORCE_VARIABLE(BUILD_STATIC_LIBS BOOL "Build static libraries" ON) -ENDIF(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) - -# --------------------------------------------------------------- -# Option to use the generic math libraries (UNIX only) -# --------------------------------------------------------------- - -IF(UNIX) - OPTION(USE_GENERIC_MATH "Use generic (std-c) math libraries" ON) - IF(USE_GENERIC_MATH) - # executables will be linked against -lm - SET(EXTRA_LINK_LIBS -lm) - # prepare substitution variable for sundials_config.h - SET(SUNDIALS_USE_GENERIC_MATH TRUE) - ENDIF(USE_GENERIC_MATH) -ENDIF(UNIX) - -# --------------------------------------------------------------- -# Check for POSIX timers -# --------------------------------------------------------------- -INCLUDE(SundialsPOSIXTimers) - -# =============================================================== -# Options for Parallelism -# =============================================================== - -# --------------------------------------------------------------- -# Enable MPI support? -# --------------------------------------------------------------- -OPTION(MPI_ENABLE "Enable MPI support" OFF) - -# --------------------------------------------------------------- -# Enable OpenMP support? -# --------------------------------------------------------------- -OPTION(OPENMP_ENABLE "Enable OpenMP support" OFF) - -# provide OPENMP_DEVICE_ENABLE option -OPTION(OPENMP_DEVICE_ENABLE "Enable OpenMP device offloading support" OFF) - -# Advanced option to skip OpenMP device offloading support check. -# This is needed for a specific compiler that doesn't correctly -# report its OpenMP spec date (with CMake >= 3.9). -OPTION(SKIP_OPENMP_DEVICE_CHECK "Skip the OpenMP device offloading support check" OFF) -MARK_AS_ADVANCED(FORCE SKIP_OPENMP_DEVICE_CHECK) - -# --------------------------------------------------------------- -# Enable Pthread support? -# --------------------------------------------------------------- -OPTION(PTHREAD_ENABLE "Enable Pthreads support" OFF) - -# ------------------------------------------------------------- -# Enable CUDA support? -# ------------------------------------------------------------- -OPTION(CUDA_ENABLE "Enable CUDA support" OFF) - -# ------------------------------------------------------------- -# Enable RAJA support? -# ------------------------------------------------------------- -OPTION(RAJA_ENABLE "Enable RAJA support" OFF) - - -# =============================================================== -# Options for external packages -# =============================================================== - -# --------------------------------------------------------------- -# Enable BLAS support? -# --------------------------------------------------------------- -OPTION(BLAS_ENABLE "Enable BLAS support" OFF) - -# --------------------------------------------------------------- -# Enable LAPACK/BLAS support? -# --------------------------------------------------------------- -OPTION(LAPACK_ENABLE "Enable Lapack support" OFF) - -# LAPACK does not support extended precision -IF(LAPACK_ENABLE AND SUNDIALS_PRECISION MATCHES "EXTENDED") - PRINT_WARNING("LAPACK is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling LAPACK") - FORCE_VARIABLE(LAPACK_ENABLE BOOL "LAPACK is disabled" OFF) -ENDIF() - -# LAPACK does not support 64-bit integer index types -IF(LAPACK_ENABLE AND SUNDIALS_INDEX_SIZE MATCHES "64") - PRINT_WARNING("LAPACK is not compatible with ${SUNDIALS_INDEX_SIZE} integers" - "Disabling LAPACK") - SET(LAPACK_ENABLE OFF CACHE BOOL "LAPACK is disabled" FORCE) -ENDIF() - -# --------------------------------------------------------------- -# Enable SuperLU_MT support? -# --------------------------------------------------------------- -OPTION(SUPERLUMT_ENABLE "Enable SUPERLUMT support" OFF) - -# SuperLU_MT does not support extended precision -IF(SUPERLUMT_ENABLE AND SUNDIALS_PRECISION MATCHES "EXTENDED") - PRINT_WARNING("SuperLU_MT is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling SuperLU_MT") - FORCE_VARIABLE(SUPERLUMT_ENABLE BOOL "SuperLU_MT is disabled" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable KLU support? -# --------------------------------------------------------------- -OPTION(KLU_ENABLE "Enable KLU support" OFF) - -# KLU does not support single or extended precision -IF(KLU_ENABLE AND - (SUNDIALS_PRECISION MATCHES "SINGLE" OR SUNDIALS_PRECISION MATCHES "EXTENDED")) - PRINT_WARNING("KLU is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling KLU") - FORCE_VARIABLE(KLU_ENABLE BOOL "KLU is disabled" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable hypre Vector support? -# --------------------------------------------------------------- -OPTION(HYPRE_ENABLE "Enable hypre support" OFF) - -# Using hypre requres building with MPI enabled -IF(HYPRE_ENABLE AND NOT MPI_ENABLE) - PRINT_WARNING("MPI not enabled - Disabling hypre" - "Set MPI_ENABLE to ON to use parhyp") - FORCE_VARIABLE(HYPRE_ENABLE BOOL "Enable hypre support" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable PETSc support? -# --------------------------------------------------------------- -OPTION(PETSC_ENABLE "Enable PETSc support" OFF) - -# Using PETSc requires building with MPI enabled -IF(PETSC_ENABLE AND NOT MPI_ENABLE) - PRINT_WARNING("MPI not enabled - Disabling PETSc" - "Set MPI_ENABLE to ON to use PETSc") - FORCE_VARIABLE(PETSC_ENABLE BOOL "Enable PETSc support" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable Trilinos support? -# --------------------------------------------------------------- -OPTION(Trilinos_ENABLE "Enable Trilinos support" OFF) - - -# =============================================================== -# Options for examples -# =============================================================== - -# --------------------------------------------------------------- -# Enable examples? -# --------------------------------------------------------------- - -# Enable C examples (on by default) -OPTION(EXAMPLES_ENABLE_C "Build SUNDIALS C examples" ON) - -# C++ examples (off by default, unless Trilinos is enabled) -SET(DOCSTR "Build C++ examples") -OPTION(EXAMPLES_ENABLE_CXX "${DOCSTR}" ${Trilinos_ENABLE}) - -# F77 examples (on by default) are an option only if the Fortran -# interface is enabled -SET(DOCSTR "Build SUNDIALS Fortran examples") -IF(F77_INTERFACE_ENABLE) - SHOW_VARIABLE(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" ON) - # Fortran 77 examples do not support single or extended precision - IF(EXAMPLES_ENABLE_F77 AND (SUNDIALS_PRECISION MATCHES "EXTENDED" OR SUNDIALS_PRECISION MATCHES "SINGLE")) - PRINT_WARNING("F77 examples are not compatible with ${SUNDIALS_PRECISION} precision" - "EXAMPLES_ENABLE_F77") - FORCE_VARIABLE(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" OFF) - ENDIF() -ELSE() - # set back to OFF (in case was ON) - IF(EXAMPLES_ENABLE_F77) - PRINT_WARNING("EXAMPLES_ENABLE_F77 is ON but F77_INTERFACE_ENABLE is OFF" - "Disabling EXAMPLES_ENABLE_F77") - FORCE_VARIABLE(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(EXAMPLES_ENABLE_F77) -ENDIF() - -# F90 examples (on by default) are an option only if a Fortran interface is enabled. -SET(DOCSTR "Build SUNDIALS F90 examples") -IF(F77_INTERFACE_ENABLE OR F2003_INTERFACE_ENABLE) - SHOW_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" ON) - # Fortran 90 examples do not support extended precision - IF(EXAMPLES_ENABLE_F90 AND (SUNDIALS_PRECISION MATCHES "EXTENDED")) - PRINT_WARNING("F90 examples are not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling EXAMPLES_ENABLE_F90") - FORCE_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" OFF) - ENDIF() -ELSE() - # set back to OFF (in case was ON) - IF(EXAMPLES_ENABLE_F90) - PRINT_WARNING("EXAMPLES_ENABLE_F90 is ON but both F77 and F2003 interfaces are OFF" - "Disabling EXAMPLES_ENABLE_F90") - FORCE_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(EXAMPLES_ENABLE_F90) -ENDIF() - -# CUDA examples (off by default) -SET(DOCSTR "Build SUNDIALS CUDA examples") -IF(CUDA_ENABLE) - OPTION(EXAMPLES_ENABLE_CUDA "${DOCSTR}" OFF) -ELSE() - IF(EXAMPLES_ENABLE_CUDA) - PRINT_WARNING("EXAMPLES_ENABLE_CUDA is ON but CUDA_ENABLE is OFF" - "Disabling EXAMPLES_ENABLE_CUDA") - FORCE_VARIABLE(EXAMPLES_ENABLE_CUDA BOOL "${DOCSTR}" OFF) - ENDIF() -ENDIF() - -# If any of the above examples are enabled set EXAMPLES_ENABLED to TRUE -IF(EXAMPLES_ENABLE_C OR - EXAMPLES_ENABLE_F77 OR - EXAMPLES_ENABLE_CXX OR - EXAMPLES_ENABLE_F90 OR - EXAMPLES_ENABLE_CUDA) - SET(EXAMPLES_ENABLED TRUE) -ELSE() - SET(EXAMPLES_ENABLED FALSE) -ENDIF() - -# --------------------------------------------------------------- -# Install examples? -# --------------------------------------------------------------- - -# Enable installing examples by default -SET(DOCSTR "Install SUNDIALS examples") -IF(EXAMPLES_ENABLED) - OPTION(EXAMPLES_INSTALL "${DOCSTR}" ON) -ELSE() - FORCE_VARIABLE(EXAMPLES_INSTALL BOOL "${DOCSTR}" OFF) - HIDE_VARIABLE(EXAMPLES_INSTALL) -ENDIF() - -# If examples are to be exported, check where we should install them. -IF(EXAMPLES_INSTALL) - - SHOW_VARIABLE(EXAMPLES_INSTALL_PATH PATH - "Output directory for installing example files" - "${CMAKE_INSTALL_PREFIX}/examples") - - IF(NOT EXAMPLES_INSTALL_PATH) - PRINT_WARNING("The example installation path is empty" - "Example installation path was reset to its default value") - SET(EXAMPLES_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/examples" CACHE STRING - "Output directory for installing example files" FORCE) - ENDIF() - -ELSE() - - HIDE_VARIABLE(EXAMPLES_INSTALL_PATH) - -ENDIF() - - -# ============================================================================== -# Advanced (hidden) options -# ============================================================================== - -# ------------------------------------------------------------------------------ -# Manually specify the Fortran name-mangling scheme -# -# The build system tries to infer the Fortran name-mangling scheme using a -# Fortran compiler and defaults to using lower case and one underscore if the -# scheme can not be determined. If a working Fortran compiler is not available -# or the user needs to override the inferred or default scheme, the following -# options specify the case and number of appended underscores corresponding to -# the Fortran name-mangling scheme of symbol names that do not themselves -# contain underscores. This is all we really need for the FCMIX and LAPACK -# interfaces. A working Fortran compiler is only necessary for building Fortran -# example programs. -# ------------------------------------------------------------------------------ - -# The case to use in the name-mangling scheme -show_variable(SUNDIALS_F77_FUNC_CASE STRING - "case of Fortran function names (lower/upper)" - "") - -# The number of underscores of appended in the name-mangling scheme -show_variable(SUNDIALS_F77_FUNC_UNDERSCORES STRING - "number of underscores appended to Fortran function names (none/one/two)" - "") - -# Hide the name-mangling varibales as advanced options -mark_as_advanced(FORCE SUNDIALS_F77_FUNC_CASE) -mark_as_advanced(FORCE SUNDIALS_F77_FUNC_UNDERSCORES) - -# If used, both case and underscores must be set -if((NOT SUNDIALS_F77_FUNC_CASE) AND SUNDIALS_F77_FUNC_UNDERSCORES) - message(FATAL_ERROR - "If SUNDIALS_F77_FUNC_UNDERSCORES is set, SUNDIALS_F77_FUNC_CASE must also be set.") -endif() - -if(SUNDIALS_F77_FUNC_CASE AND (NOT SUNDIALS_F77_FUNC_UNDERSCORES)) - message(FATAL_ERROR - "If SUNDIALS_F77_FUNC_CASE is set, SUNDIALS_F77_FUNC_UNDERSCORES must also be set.") -endif() - -# ------------------------------------------------------------------------------ -# Include development examples in regression tests? -# -# NOTE: Development examples are currently used for internal testing and may -# produce erroneous failures when run on different systems as the pass/fail -# status is determined by comparing the output against a saved output file. -# ------------------------------------------------------------------------------ -OPTION(SUNDIALS_DEVTESTS "Include development tests in make test" OFF) -MARK_AS_ADVANCED(FORCE SUNDIALS_DEVTESTS) - -# =============================================================== -# Add any platform specifc settings -# =============================================================== - -IF(APPLE) - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") -ENDIF(APPLE) - -# =============================================================== -# Fortran and C++ settings -# =============================================================== - -# --------------------------------------------------------------- -# A Fortran compiler is needed to: -# (a) Determine the name-mangling scheme if FCMIX, BLAS, or -# LAPACK are enabled -# (b) Compile example programs if F77 or F90 examples are enabled -# --------------------------------------------------------------- - -# Do we need a Fortran name-mangling scheme? -if(F77_INTERFACE_ENABLE OR BLAS_ENABLE OR LAPACK_ENABLE) - set(NEED_FORTRAN_NAME_MANGLING TRUE) -endif() - -# Did the user provide a name-mangling scheme? -if(SUNDIALS_F77_FUNC_CASE AND SUNDIALS_F77_FUNC_UNDERSCORES) - - STRING(TOUPPER ${SUNDIALS_F77_FUNC_CASE} SUNDIALS_F77_FUNC_CASE) - STRING(TOUPPER ${SUNDIALS_F77_FUNC_UNDERSCORES} SUNDIALS_F77_FUNC_UNDERSCORES) - - # Based on the given case and number of underscores, set the C preprocessor - # macro definitions. Since SUNDIALS never uses symbols names containing - # underscores we set the name-mangling schemes to be the same. In general, - # names of symbols with and without underscore may be mangled differently - # (e.g. g77 mangles mysub to mysub_ and my_sub to my_sub__) - if(SUNDIALS_F77_FUNC_CASE MATCHES "LOWER") - if(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "NONE") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name") - elseif(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "ONE") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name ## _") - SET(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name ## _") - elseif(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "TWO") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name ## __") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name ## __") - else() - message(FATAL_ERROR "Invalid SUNDIALS_F77_FUNC_UNDERSCORES option.") - endif() - elseif(SUNDIALS_F77_FUNC_CASE MATCHES "UPPER") - if(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "NONE") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME") - elseif(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "ONE") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME ## _") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## _") - elseif(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "TWO") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME ## __") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## __") - else() - message(FATAL_ERROR "Invalid SUNDIALS_F77_FUNC_UNDERSCORES option.") - endif() - else() - message(FATAL_ERROR "Invalid SUNDIALS_F77_FUNC_CASE option.") - endif() - - # name-mangling scheme has been manually set - set(NEED_FORTRAN_NAME_MANGLING FALSE) - -endif() - -# Do we need a Fortran compiler? -if(F2003_INTERFACE_ENABLE OR EXAMPLES_ENABLE_F77 OR EXAMPLES_ENABLE_F90 OR NEED_FORTRAN_NAME_MANGLING) - include(SundialsFortran) -endif() - -# Ensure that F90 compiler is found if F90 examples are enabled -if (EXAMPLES_ENABLE_F90 AND (NOT F90_FOUND)) - PRINT_WARNING("Compiler with F90 support not found" "Disabling F90 Examples") - SET(DOCSTR "Build F90 examples") - FORCE_VARIABLE(EXAMPLES_ENABLE_F90 "${DOCSTR}" OFF) -endif() - -# Ensure that F90 compiler found if F2003 interface is enabled -if (F2003_INTERFACE_ENABLE AND (NOT F90_FOUND)) - PRINT_WARNING("Compiler with F90 support not found" "Disabling F2003 Interface") - SET(DOCSTR "Enable Fortran 2003 interfaces") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) -endif() - -# F2003 interface requires ISO_C_BINDING -IF(F2003_INTERFACE_ENABLE AND (NOT Fortran_COMPILER_SUPPORTS_ISOCBINDING)) - PRINT_WARNING("Fortran compiler does not provide ISO_C_BINDING support" - "Disabling F2003 interface") - SET(DOCSTR "Enable Fortran 2003 interfaces") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) -ENDIF() - - -# --------------------------------------------------------------- -# A C++ compiler is needed if: -# (a) C++ examples are enabled -# (b) CUDA is enabled -# (c) RAJA is enabled -# (d) Trilinos is enabled -# --------------------------------------------------------------- - -if(EXAMPLES_ENABLE_CXX OR CUDA_ENABLE OR RAJA_ENABLE OR Trilinos_ENABLE) - include(SundialsCXX) -endif() - -# --------------------------------------------------------------- -# Setup CUDA. Since CUDA is its own language we do this -# separate from the TPLs. -# --------------------------------------------------------------- - -if(CUDA_ENABLE) - find_package(CUDA) - if (CUDA_FOUND) - set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -lineinfo") - else() - message(STATUS "Disabling CUDA support, could not find CUDA.") - set(CUDA_ENABLE OFF) - endif() -endif(CUDA_ENABLE) - -# --------------------------------------------------------------- -# Now that all languages are setup, we can configure them more. -# --------------------------------------------------------------- - -# C++11 is needed if: -# (a) CUDA is enabled -# C++11 should not be enabled if -# (a) RAJA is enabled (they provide a std flag) -if (CXX_FOUND AND CUDA_ENABLE AND CUDA_FOUND AND (NOT RAJA_ENABLE)) - USE_CXX_STD(11) -endif() - -# --------------------------------------------------------------- -# Decide how to compile MPI codes. We must check for MPI if -# MPI is enabled or if Trilinos is enabled because the Trilinos -# examples may need MPI without us turning on the MPI SUNDIALS -# components. -# --------------------------------------------------------------- - -if(MPI_ENABLE OR Trilinos_ENABLE) - include(SundialsMPI) -endif() - -if(MPI_ENABLE) - if(NOT MPI_C_FOUND) - print_warning("MPI not functional" "Parallel support will not be provided") - else() - set(IS_MPI_ENABLED "#ifndef SUNDIALS_MPI_ENABLED\n#define SUNDIALS_MPI_ENABLED 1\n#endif") - endif() -endif() - -# always define FMPI_COMM_F2C in sundials_fconfig.h file -if(MPIC_MPI2) - set(F77_MPI_COMM_F2C "#define SUNDIALS_MPI_COMM_F2C 1") - set(FMPI_COMM_F2C ".true.") -else() - set(F77_MPI_COMM_F2C "#define SUNDIALS_MPI_COMM_F2C 0") - set(FMPI_COMM_F2C ".false.") -endif() - -# ------------------------------------------------------------- -# Find OpenMP -# ------------------------------------------------------------- - -if(OPENMP_ENABLE OR OPENMP_DEVICE_ENABLE) - - include(SundialsOpenMP) - - # turn off OPENMP_ENABLE and OPENMP_DEVICE_ENABLE if OpenMP is not found - if(NOT OPENMP_FOUND) - print_warning("Could not determine OpenMP compiler flags" "Disabling OpenMP support") - force_variable(OPENMP_ENABLE BOOL "Enable OpenMP support" OFF) - force_variable(OPENMP_DEVICE_ENABLE BOOL "Enable OpenMP device offloading support" OFF) - endif() - - # turn off OPENMP_DEVICE_ENABLE if offloading is not supported - if(OPENMP_DEVICE_ENABLE AND (NOT OPENMP_SUPPORTS_DEVICE_OFFLOADING)) - print_warning("OpenMP found does not support device offloading" - "Disabling OpenMP device offloading support") - force_variable(OPENMP_DEVICE_ENABLE BOOL "Enable OpenMP device offloading support" OFF) - endif() - -endif() - -# ------------------------------------------------------------- -# Find PThreads -# ------------------------------------------------------------- - -IF(PTHREAD_ENABLE) - FIND_PACKAGE(Threads) - IF(CMAKE_USE_PTHREADS_INIT) - message(STATUS "Using Pthreads") - SET(PTHREADS_FOUND TRUE) - # SGS - ELSE() - message(STATUS "Disabling Pthreads support, could not determine compiler flags") - endif() -ENDIF(PTHREAD_ENABLE) - -# ------------------------------------------------------------- -# Find RAJA -# ------------------------------------------------------------- - -# disable RAJA if CUDA is not enabled/working -if(RAJA_ENABLE AND (NOT CUDA_FOUND)) - PRINT_WARNING("CUDA is required for RAJA support" "Please enable CUDA and RAJA") - FORCE_VARIABLE(RAJA_ENABLE BOOL "RAJA disabled" OFF) -endif() - -if(RAJA_ENABLE) - # Look for CMake configuration file in RAJA installation - find_package(RAJA) - if (RAJA_FOUND) - include_directories(${RAJA_INCLUDE_DIR}) - set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${RAJA_NVCC_FLAGS}) - else() - PRINT_WARNING("RAJA configuration not found" - "Please set RAJA_DIR to provide path to RAJA CMake configuration file.") - endif() -endif(RAJA_ENABLE) - -# =============================================================== -# Find (and test) external packages -# =============================================================== - -# --------------------------------------------------------------- -# Find (and test) the BLAS libraries -# --------------------------------------------------------------- - -# If BLAS is needed, first try to find the appropriate -# libraries and linker flags needed to link against them. - -IF(BLAS_ENABLE) - - # find BLAS - INCLUDE(SundialsBlas) - - # show after include so FindBlas can locate BLAS_LIBRARIES if necessary - SHOW_VARIABLE(BLAS_LIBRARIES STRING "Blas libraries" "${BLAS_LIBRARIES}") - - IF(BLAS_LIBRARIES AND NOT BLAS_FOUND) - PRINT_WARNING("BLAS not functional" - "BLAS support will not be provided") - ELSE() - #set sundials_config.h symbol via sundials_config.in - SET(SUNDIALS_BLAS TRUE) - ENDIF() - -ELSE() - - HIDE_VARIABLE(BLAS_LIBRARIES) - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the Lapack libraries -# --------------------------------------------------------------- - -# If LAPACK is needed, first try to find the appropriate -# libraries and linker flags needed to link against them. - -IF(LAPACK_ENABLE) - - # find LAPACK and BLAS Libraries - INCLUDE(SundialsLapack) - - # show after include so FindLapack can locate LAPCK_LIBRARIES if necessary - SHOW_VARIABLE(LAPACK_LIBRARIES STRING "Lapack and Blas libraries" "${LAPACK_LIBRARIES}") - - IF(LAPACK_LIBRARIES AND NOT LAPACK_FOUND) - PRINT_WARNING("LAPACK not functional" - "Blas/Lapack support will not be provided") - ELSE() - #set sundials_config.h symbol via sundials_config.in - SET(SUNDIALS_BLAS_LAPACK TRUE) - ENDIF() - -ELSE() - - HIDE_VARIABLE(LAPACK_LIBRARIES) - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the SUPERLUMT libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for SuperLU_MT integer type - -# If SUPERLUMT is needed, first try to find the appropriate -# libraries to link against them. - -IF(SUPERLUMT_ENABLE) - - # Show SuperLU_MT options and set default thread type (Pthreads) - SHOW_VARIABLE(SUPERLUMT_THREAD_TYPE STRING "SUPERLUMT threading type: OpenMP or Pthread" "Pthread") - SHOW_VARIABLE(SUPERLUMT_INCLUDE_DIR PATH "SUPERLUMT include directory" "${SUPERLUMT_INCLUDE_DIR}") - SHOW_VARIABLE(SUPERLUMT_LIBRARY_DIR PATH "SUPERLUMT library directory" "${SUPERLUMT_LIBRARY_DIR}") - - INCLUDE(SundialsSuperLUMT) - - IF(SUPERLUMT_FOUND) - # sundials_config.h symbols - SET(SUNDIALS_SUPERLUMT TRUE) - SET(SUNDIALS_SUPERLUMT_THREAD_TYPE ${SUPERLUMT_THREAD_TYPE}) - INCLUDE_DIRECTORIES(${SUPERLUMT_INCLUDE_DIR}) - ENDIF() - - IF(SUPERLUMT_LIBRARIES AND NOT SUPERLUMT_FOUND) - PRINT_WARNING("SUPERLUMT not functional - support will not be provided" - "Double check spelling specified libraries (search is case sensitive)") - ENDIF(SUPERLUMT_LIBRARIES AND NOT SUPERLUMT_FOUND) - -ELSE() - - HIDE_VARIABLE(SUPERLUMT_THREAD_TYPE) - HIDE_VARIABLE(SUPERLUMT_LIBRARY_DIR) - HIDE_VARIABLE(SUPERLUMT_INCLUDE_DIR) - SET (SUPERLUMT_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the KLU libraries -# --------------------------------------------------------------- - -# If KLU is requested, first try to find the appropriate libraries to -# link against them. - -IF(KLU_ENABLE) - - SHOW_VARIABLE(KLU_INCLUDE_DIR PATH "KLU include directory" - "${KLU_INCLUDE_DIR}") - SHOW_VARIABLE(KLU_LIBRARY_DIR PATH - "Klu library directory" "${KLU_LIBRARY_DIR}") - - set(KLU_FOUND TRUE) - get_filename_component(PYBAMM_DIR ${PROJECT_SOURCE_DIR} DIRECTORY) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PYBAMM_DIR}) # use FindSuiteSparse.cmake that is in PyBaMM root - set(SuiteSparse_ROOT ${PYBAMM_DIR}/SuiteSparse-5.6.0) - find_package(SuiteSparse OPTIONAL_COMPONENTS KLU AMD COLAMD BTF) - include_directories(${SuiteSparse_INCLUDE_DIRS}) - set(KLU_LIBRARIES ${SuiteSparse_LIBRARIES}) - - - IF(KLU_LIBRARIES AND NOT KLU_FOUND) - PRINT_WARNING("KLU not functional - support will not be provided" - "Double check spelling of include path and specified libraries (search is case sensitive)") - ENDIF(KLU_LIBRARIES AND NOT KLU_FOUND) - -ELSE() - - HIDE_VARIABLE(KLU_LIBRARY_DIR) - HIDE_VARIABLE(KLU_INCLUDE_DIR) - SET (KLU_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF(KLU_ENABLE) - -# --------------------------------------------------------------- -# Find (and test) the hypre libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for hypre precision and integer type - -IF(HYPRE_ENABLE) - SHOW_VARIABLE(HYPRE_INCLUDE_DIR PATH "HYPRE include directory" - "${HYPRE_INCLUDE_DIR}") - SHOW_VARIABLE(HYPRE_LIBRARY_DIR PATH - "HYPRE library directory" "${HYPRE_LIBRARY_DIR}") - - INCLUDE(SundialsHypre) - - IF(HYPRE_FOUND) - # sundials_config.h symbol - SET(SUNDIALS_HYPRE TRUE) - INCLUDE_DIRECTORIES(${HYPRE_INCLUDE_DIR}) - ENDIF(HYPRE_FOUND) - - IF(HYPRE_LIBRARIES AND NOT HYPRE_FOUND) - PRINT_WARNING("HYPRE not functional - support will not be provided" - "Found hypre library, test code does not work") - ENDIF(HYPRE_LIBRARIES AND NOT HYPRE_FOUND) - -ELSE() - - HIDE_VARIABLE(HYPRE_INCLUDE_DIR) - HIDE_VARIABLE(HYPRE_LIBRARY_DIR) - SET (HYPRE_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the PETSc libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for PETSc precision and integer type - -IF(PETSC_ENABLE) - SHOW_VARIABLE(PETSC_INCLUDE_DIR PATH "PETSc include directory" - "${PETSC_INCLUDE_DIR}") - SHOW_VARIABLE(PETSC_LIBRARY_DIR PATH - "PETSc library directory" "${PETSC_LIBRARY_DIR}") - - INCLUDE(SundialsPETSc) - - IF(PETSC_FOUND) - # sundials_config.h symbol - SET(SUNDIALS_PETSC TRUE) - INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIR}) - ENDIF(PETSC_FOUND) - - IF(PETSC_LIBRARIES AND NOT PETSC_FOUND) - PRINT_WARNING("PETSC not functional - support will not be provided" - "Double check spelling specified libraries (search is case sensitive)") - ENDIF(PETSC_LIBRARIES AND NOT PETSC_FOUND) - -ELSE() - - HIDE_VARIABLE(PETSC_LIBRARY_DIR) - HIDE_VARIABLE(PETSC_INCLUDE_DIR) - SET (PETSC_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - -# ------------------------------------------------------------- -# Find Trilinos -# ------------------------------------------------------------- - -if(Trilinos_ENABLE) - include(SundialsTrilinos) - if(NOT Trilinos_FUNCTIONAL) - PRINT_WARNING("Trilinos not functional" "Verify the path to Trilinos and check the Trilinos installation") - endif() -endif(Trilinos_ENABLE) - - -# =============================================================== -# At this point all the configuration options are set. -# =============================================================== - -# --------------------------------------------------------------- -# Configure the header file sundials_config.h -# --------------------------------------------------------------- - -# All required substitution variables should be available at this point. -# Generate the header file and place it in the binary dir. -CONFIGURE_FILE( - ${PROJECT_SOURCE_DIR}/include/sundials/sundials_config.in - ${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h - ) -CONFIGURE_FILE( - ${PROJECT_SOURCE_DIR}/include/sundials/sundials_fconfig.in - ${PROJECT_BINARY_DIR}/include/sundials/sundials_fconfig.h - ) - -# Add the include directory in the source tree and the one in -# the binary tree (for the header file sundials_config.h) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - -# --------------------------------------------------------------- -# Enable testing and add source and example files to the build. -# --------------------------------------------------------------- - -# Enable testing -IF(EXAMPLES_ENABLED) - INCLUDE(SundialsTesting) -ENDIF() - -# Add selected packages and modules to the build -ADD_SUBDIRECTORY(src) - -# Add selected examples to the build -IF(EXAMPLES_ENABLED) - ADD_SUBDIRECTORY(examples) -ENDIF() - -# --------------------------------------------------------------- -# Install configuration header files and license file -# --------------------------------------------------------------- - -# install configured header file -INSTALL( - FILES ${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h - DESTINATION include/sundials - ) - -# install configured header file for Fortran 90 -INSTALL( - FILES ${PROJECT_BINARY_DIR}/include/sundials/sundials_fconfig.h - DESTINATION include/sundials - ) - -# install shared Fortran 2003 modules -IF(F2003_INTERFACE_ENABLE) - # While the .mod files get generated for static and shared - # libraries, they are identical. So only install one set - # of the .mod files. - IF(BUILD_STATIC_LIBS) - INSTALL( - DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_STATIC/ - DESTINATION ${Fortran_INSTALL_MODDIR} - ) - ELSE() - INSTALL( - DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_SHARED/ - DESTINATION ${Fortran_INSTALL_MODDIR} - ) - ENDIF() -ENDIF() - -# install license and notice files -INSTALL( - FILES ${PROJECT_SOURCE_DIR}/LICENSE - DESTINATION include/sundials - ) -INSTALL( - FILES ${PROJECT_SOURCE_DIR}/NOTICE - DESTINATION include/sundials - ) diff --git a/scripts/replace-cmake/sundials-5.0.0/CMakeLists.txt b/scripts/replace-cmake/sundials-5.0.0/CMakeLists.txt deleted file mode 100644 index fc8acbddc9..0000000000 --- a/scripts/replace-cmake/sundials-5.0.0/CMakeLists.txt +++ /dev/null @@ -1,1151 +0,0 @@ -# --------------------------------------------------------------- -# Programmer: Radu Serban, David J. Gardner, Cody J. Balos, -# and Slaven Peles @ LLNL -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2019, Lawrence Livermore National Security -# and Southern Methodist University. -# All rights reserved. -# -# See the top-level LICENSE and NOTICE files for details. -# -# SPDX-License-Identifier: BSD-3-Clause -# SUNDIALS Copyright End -# --------------------------------------------------------------- -# Top level CMakeLists.txt for SUNDIALS (for cmake build system) -# --------------------------------------------------------------- - -# --------------------------------------------------------------- -# Initial commands -# --------------------------------------------------------------- - -# Require a fairly recent cmake version -cmake_minimum_required(VERSION 3.1.3) - -# Libraries linked via full path no longer produce linker search paths -# Allows examples to build -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -# MACOSX_RPATH is enabled by default -# Fixes dynamic loading on OSX -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) # Added in CMake 3.0 -else() - if(APPLE) - set(CMAKE_MACOSX_RPATH 1) - endif() -endif() - -# Project SUNDIALS (initially only C supported) -# sets PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR variables -PROJECT(sundials C) - -# Set some variables with info on the SUNDIALS project -SET(PACKAGE_BUGREPORT "woodward6@llnl.gov") -SET(PACKAGE_NAME "SUNDIALS") -SET(PACKAGE_STRING "SUNDIALS 4.1.0") -SET(PACKAGE_TARNAME "sundials") - -# set SUNDIALS version numbers -# (use "" for the version label if none is needed) -SET(PACKAGE_VERSION_MAJOR "4") -SET(PACKAGE_VERSION_MINOR "1") -SET(PACKAGE_VERSION_PATCH "0") -SET(PACKAGE_VERSION_LABEL "") - -IF(PACKAGE_VERSION_LABEL) - SET(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}-${PACKAGE_VERSION_LABEL}") -ELSE() - SET(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}") -ENDIF() - -SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) - -# Prohibit in-source build -IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - MESSAGE(FATAL_ERROR "In-source build prohibited.") -ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - -# Hide some cache variables -MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) - -# Always show the C compiler and flags -MARK_AS_ADVANCED(CLEAR - CMAKE_C_COMPILER - CMAKE_C_FLAGS) - -# Specify the VERSION and SOVERSION for shared libraries - -SET(arkodelib_VERSION "3.1.0") -SET(arkodelib_SOVERSION "3") - -SET(cvodelib_VERSION "4.1.0") -SET(cvodelib_SOVERSION "4") - -SET(cvodeslib_VERSION "4.1.0") -SET(cvodeslib_SOVERSION "4") - -SET(idalib_VERSION "4.1.0") -SET(idalib_SOVERSION "4") - -SET(idaslib_VERSION "3.1.0") -SET(idaslib_SOVERSION "3") - -SET(kinsollib_VERSION "4.1.0") -SET(kinsollib_SOVERSION "4") - -SET(cpodeslib_VERSION "0.0.0") -SET(cpodeslib_SOVERSION "0") - -SET(nveclib_VERSION "4.1.0") -SET(nveclib_SOVERSION "4") - -SET(sunmatrixlib_VERSION "2.1.0") -SET(sunmatrixlib_SOVERSION "2") - -SET(sunlinsollib_VERSION "2.1.0") -SET(sunlinsollib_SOVERSION "2") - -SET(sunnonlinsollib_VERSION "1.1.0") -SET(sunnonlinsollib_SOVERSION "1") - -# Specify the location of additional CMAKE modules -SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/config) - -# Get correct build paths automatically, but expose CMAKE_INSTALL_LIBDIR -# as a regular cache variable so that a user can more easily see what -# the library dir was set to be by GNUInstallDirs. -INCLUDE(GNUInstallDirs) -MARK_AS_ADVANCED(CLEAR CMAKE_INSTALL_LIBDIR) - -# --------------------------------------------------------------- -# Which modules to build? -# --------------------------------------------------------------- - -# For each SUNDIALS solver available (i.e. for which we have the -# sources), give the user the option of enabling/disabling it. - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/arkode") - OPTION(BUILD_ARKODE "Build the ARKODE library" ON) -ELSE() - SET(BUILD_ARKODE OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cvode") - OPTION(BUILD_CVODE "Build the CVODE library" ON) -ELSE() - SET(BUILD_CVODE OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cvodes") - OPTION(BUILD_CVODES "Build the CVODES library" ON) -ELSE() - SET(BUILD_CVODES OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/ida") - OPTION(BUILD_IDA "Build the IDA library" ON) -ELSE() - SET(BUILD_IDA OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/idas") - OPTION(BUILD_IDAS "Build the IDAS library" ON) -ELSE() - SET(BUILD_IDAS OFF) -ENDIF() - -IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/kinsol") - OPTION(BUILD_KINSOL "Build the KINSOL library" ON) -ELSE() - SET(BUILD_KINSOL OFF) -ENDIF() - -# CPODES is always OFF for now. (commented out for Release); ToDo: better way to do this? -#IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes") -# OPTION(BUILD_CPODES "Build the CPODES library" OFF) -#ELSE() -# SET(BUILD_CPODES OFF) -#ENDIF() - -# --------------------------------------------------------------- -# MACRO definitions -# --------------------------------------------------------------- -INCLUDE(CMakeParseArguments) # can be removed when CMake 3.5+ is required -INCLUDE(SundialsCMakeMacros) -INCLUDE(SundialsAddF2003InterfaceLibrary) -INCLUDE(SundialsAddTest) -INCLUDE(SundialsAddTestInstall) - -# --------------------------------------------------------------- -# Check for deprecated SUNDIALS CMake options/variables -# --------------------------------------------------------------- -INCLUDE(SundialsDeprecated) - -# --------------------------------------------------------------- -# xSDK specific options -# --------------------------------------------------------------- -INCLUDE(SundialsXSDK) - -# --------------------------------------------------------------- -# Build specific C flags -# --------------------------------------------------------------- - -# Hide all build type specific flags -MARK_AS_ADVANCED(FORCE - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_RELWITHDEBINFO) - -# Only show flags for the current build type if it is set -# NOTE: Build specific flags are appended those in CMAKE_C_FLAGS -IF(CMAKE_BUILD_TYPE) - IF(CMAKE_BUILD_TYPE MATCHES "Debug") - MESSAGE("Appending C debug flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_DEBUG) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "MinSizeRel") - MESSAGE("Appending C min size release flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_MINSIZEREL) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "Release") - MESSAGE("Appending C release flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_RELEASE) - ELSEIF(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") - MESSAGE("Appending C release with debug info flags") - MARK_AS_ADVANCED(CLEAR CMAKE_C_FLAGS_RELWITHDEBINFO) - ENDIF() -ENDIF() - -# --------------------------------------------------------------- -# Option to specify precision (realtype) -# --------------------------------------------------------------- - -SET(DOCSTR "single, double, or extended") -SHOW_VARIABLE(SUNDIALS_PRECISION STRING "${DOCSTR}" "double") - -# prepare substitution variable PRECISION_LEVEL for sundials_config.h -STRING(TOUPPER ${SUNDIALS_PRECISION} SUNDIALS_PRECISION) -SET(PRECISION_LEVEL "#define SUNDIALS_${SUNDIALS_PRECISION}_PRECISION 1") - -# prepare substitution variable FPRECISION_LEVEL for sundials_fconfig.h -IF(SUNDIALS_PRECISION MATCHES "SINGLE") - SET(FPRECISION_LEVEL "4") -ENDIF(SUNDIALS_PRECISION MATCHES "SINGLE") -IF(SUNDIALS_PRECISION MATCHES "DOUBLE") - SET(FPRECISION_LEVEL "8") -ENDIF(SUNDIALS_PRECISION MATCHES "DOUBLE") -IF(SUNDIALS_PRECISION MATCHES "EXTENDED") - SET(FPRECISION_LEVEL "16") -ENDIF(SUNDIALS_PRECISION MATCHES "EXTENDED") - -# --------------------------------------------------------------- -# Option to specify index type -# --------------------------------------------------------------- - -SET(DOCSTR "Signed 64-bit (64) or signed 32-bit (32) integer") -SHOW_VARIABLE(SUNDIALS_INDEX_SIZE STRING "${DOCSTR}" "64") -SET(DOCSTR "Integer type to use for indices in SUNDIALS") -SHOW_VARIABLE(SUNDIALS_INDEX_TYPE STRING "${DOCSTR}" "") -MARK_AS_ADVANCED(SUNDIALS_INDEX_TYPE) -include(SundialsIndexSize) - -# --------------------------------------------------------------- -# Enable Fortran interface? -# --------------------------------------------------------------- - -# Fortran interface is disabled by default -SET(DOCSTR "Enable Fortran 77 interfaces") -OPTION(F77_INTERFACE_ENABLE "${DOCSTR}" OFF) - -# Check that at least one solver with a Fortran 77 interface is built -IF(NOT BUILD_ARKODE AND NOT BUILD_CVODE AND NOT BUILD_IDA AND NOT BUILD_KINSOL) - IF(F77_INTERFACE_ENABLE) - PRINT_WARNING("Enabled packages do not support Fortran 77 interface" "Disabling F77 interface") - FORCE_VARIABLE(F77_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(F77_INTERFACE_ENABLE) -ENDIF() - -# Fortran 2003 interface is disabled by default -SET(DOCSTR "Enable Fortran 2003 interfaces") -OPTION(F2003_INTERFACE_ENABLE "${DOCSTR}" OFF) - -# Check that at least one solver with a Fortran 2003 interface is built -IF(NOT BUILD_CVODE) - IF(F2003_INTERFACE_ENABLE) - PRINT_WARNING("Enabled packages do not support Fortran 2003 interface" "Disabling F2003 interface") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(F2003_INTERFACE_ENABLE) -ENDIF() - -IF(F2003_INTERFACE_ENABLE) - # F2003 interface only supports double precision - IF(NOT (SUNDIALS_PRECISION MATCHES "DOUBLE")) - PRINT_WARNING("F2003 interface is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling F2003 interface") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - - # F2003 interface only supports 64-bit indices - IF(NOT (SUNDIALS_INDEX_SIZE MATCHES "64")) - PRINT_WARNING("F2003 interface is not compatible with ${SUNDIALS_INDEX_SIZE}-bit indicies" - "Disabling F2003 interface") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) - ENDIF() - - # Put all F2003 modules into one build directory - SET(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/fortran") - - # Allow a user to set where the Fortran modules will be installed - SET(DOCSTR "Directory where Fortran module files are installed") - SHOW_VARIABLE(Fortran_INSTALL_MODDIR DIRECTORY "${DOCSTR}" "fortran") -ENDIF() - -# --------------------------------------------------------------- -# Options to build static and/or shared libraries -# --------------------------------------------------------------- - -OPTION(BUILD_STATIC_LIBS "Build static libraries" ON) -OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) - -# Make sure we build at least one type of libraries -IF(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) - PRINT_WARNING("Both static and shared library generation were disabled" - "Building static libraries was re-enabled") - FORCE_VARIABLE(BUILD_STATIC_LIBS BOOL "Build static libraries" ON) -ENDIF(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) - -# --------------------------------------------------------------- -# Option to use the generic math libraries (UNIX only) -# --------------------------------------------------------------- - -IF(UNIX) - OPTION(USE_GENERIC_MATH "Use generic (std-c) math libraries" ON) - IF(USE_GENERIC_MATH) - # executables will be linked against -lm - SET(EXTRA_LINK_LIBS -lm) - # prepare substitution variable for sundials_config.h - SET(SUNDIALS_USE_GENERIC_MATH TRUE) - ENDIF(USE_GENERIC_MATH) -ENDIF(UNIX) - -# --------------------------------------------------------------- -# Check for POSIX timers -# --------------------------------------------------------------- -INCLUDE(SundialsPOSIXTimers) - -# =============================================================== -# Options for Parallelism -# =============================================================== - -# --------------------------------------------------------------- -# Enable MPI support? -# --------------------------------------------------------------- -OPTION(MPI_ENABLE "Enable MPI support" OFF) - -# --------------------------------------------------------------- -# Enable OpenMP support? -# --------------------------------------------------------------- -OPTION(OPENMP_ENABLE "Enable OpenMP support" OFF) - -# provide OPENMP_DEVICE_ENABLE option -OPTION(OPENMP_DEVICE_ENABLE "Enable OpenMP device offloading support" OFF) - -# Advanced option to skip OpenMP device offloading support check. -# This is needed for a specific compiler that doesn't correctly -# report its OpenMP spec date (with CMake >= 3.9). -OPTION(SKIP_OPENMP_DEVICE_CHECK "Skip the OpenMP device offloading support check" OFF) -MARK_AS_ADVANCED(FORCE SKIP_OPENMP_DEVICE_CHECK) - -# --------------------------------------------------------------- -# Enable Pthread support? -# --------------------------------------------------------------- -OPTION(PTHREAD_ENABLE "Enable Pthreads support" OFF) - -# ------------------------------------------------------------- -# Enable CUDA support? -# ------------------------------------------------------------- -OPTION(CUDA_ENABLE "Enable CUDA support" OFF) - -# ------------------------------------------------------------- -# Enable RAJA support? -# ------------------------------------------------------------- -OPTION(RAJA_ENABLE "Enable RAJA support" OFF) - - -# =============================================================== -# Options for external packages -# =============================================================== - -# --------------------------------------------------------------- -# Enable BLAS support? -# --------------------------------------------------------------- -OPTION(BLAS_ENABLE "Enable BLAS support" OFF) - -# --------------------------------------------------------------- -# Enable LAPACK/BLAS support? -# --------------------------------------------------------------- -OPTION(LAPACK_ENABLE "Enable Lapack support" OFF) - -# LAPACK does not support extended precision -IF(LAPACK_ENABLE AND SUNDIALS_PRECISION MATCHES "EXTENDED") - PRINT_WARNING("LAPACK is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling LAPACK") - FORCE_VARIABLE(LAPACK_ENABLE BOOL "LAPACK is disabled" OFF) -ENDIF() - -# LAPACK does not support 64-bit integer index types -IF(LAPACK_ENABLE AND SUNDIALS_INDEX_SIZE MATCHES "64") - PRINT_WARNING("LAPACK is not compatible with ${SUNDIALS_INDEX_SIZE} integers" - "Disabling LAPACK") - SET(LAPACK_ENABLE OFF CACHE BOOL "LAPACK is disabled" FORCE) -ENDIF() - -# --------------------------------------------------------------- -# Enable SuperLU_MT support? -# --------------------------------------------------------------- -OPTION(SUPERLUMT_ENABLE "Enable SUPERLUMT support" OFF) - -# SuperLU_MT does not support extended precision -IF(SUPERLUMT_ENABLE AND SUNDIALS_PRECISION MATCHES "EXTENDED") - PRINT_WARNING("SuperLU_MT is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling SuperLU_MT") - FORCE_VARIABLE(SUPERLUMT_ENABLE BOOL "SuperLU_MT is disabled" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable KLU support? -# --------------------------------------------------------------- -OPTION(KLU_ENABLE "Enable KLU support" OFF) - -# KLU does not support single or extended precision -IF(KLU_ENABLE AND - (SUNDIALS_PRECISION MATCHES "SINGLE" OR SUNDIALS_PRECISION MATCHES "EXTENDED")) - PRINT_WARNING("KLU is not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling KLU") - FORCE_VARIABLE(KLU_ENABLE BOOL "KLU is disabled" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable hypre Vector support? -# --------------------------------------------------------------- -OPTION(HYPRE_ENABLE "Enable hypre support" OFF) - -# Using hypre requres building with MPI enabled -IF(HYPRE_ENABLE AND NOT MPI_ENABLE) - PRINT_WARNING("MPI not enabled - Disabling hypre" - "Set MPI_ENABLE to ON to use parhyp") - FORCE_VARIABLE(HYPRE_ENABLE BOOL "Enable hypre support" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable PETSc support? -# --------------------------------------------------------------- -OPTION(PETSC_ENABLE "Enable PETSc support" OFF) - -# Using PETSc requires building with MPI enabled -IF(PETSC_ENABLE AND NOT MPI_ENABLE) - PRINT_WARNING("MPI not enabled - Disabling PETSc" - "Set MPI_ENABLE to ON to use PETSc") - FORCE_VARIABLE(PETSC_ENABLE BOOL "Enable PETSc support" OFF) -ENDIF() - -# --------------------------------------------------------------- -# Enable Trilinos support? -# --------------------------------------------------------------- -OPTION(Trilinos_ENABLE "Enable Trilinos support" OFF) - - -# =============================================================== -# Options for examples -# =============================================================== - -# --------------------------------------------------------------- -# Enable examples? -# --------------------------------------------------------------- - -# Enable C examples (on by default) -OPTION(EXAMPLES_ENABLE_C "Build SUNDIALS C examples" ON) - -# C++ examples (off by default, unless Trilinos is enabled) -SET(DOCSTR "Build C++ examples") -OPTION(EXAMPLES_ENABLE_CXX "${DOCSTR}" ${Trilinos_ENABLE}) - -# F77 examples (on by default) are an option only if the Fortran -# interface is enabled -SET(DOCSTR "Build SUNDIALS Fortran examples") -IF(F77_INTERFACE_ENABLE) - SHOW_VARIABLE(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" ON) - # Fortran 77 examples do not support single or extended precision - IF(EXAMPLES_ENABLE_F77 AND (SUNDIALS_PRECISION MATCHES "EXTENDED" OR SUNDIALS_PRECISION MATCHES "SINGLE")) - PRINT_WARNING("F77 examples are not compatible with ${SUNDIALS_PRECISION} precision" - "EXAMPLES_ENABLE_F77") - FORCE_VARIABLE(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" OFF) - ENDIF() -ELSE() - # set back to OFF (in case was ON) - IF(EXAMPLES_ENABLE_F77) - PRINT_WARNING("EXAMPLES_ENABLE_F77 is ON but F77_INTERFACE_ENABLE is OFF" - "Disabling EXAMPLES_ENABLE_F77") - FORCE_VARIABLE(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(EXAMPLES_ENABLE_F77) -ENDIF() - -# F90 examples (on by default) are an option only if a Fortran interface is enabled. -SET(DOCSTR "Build SUNDIALS F90 examples") -IF(F77_INTERFACE_ENABLE OR F2003_INTERFACE_ENABLE) - SHOW_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" ON) - # Fortran 90 examples do not support extended precision - IF(EXAMPLES_ENABLE_F90 AND (SUNDIALS_PRECISION MATCHES "EXTENDED")) - PRINT_WARNING("F90 examples are not compatible with ${SUNDIALS_PRECISION} precision" - "Disabling EXAMPLES_ENABLE_F90") - FORCE_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" OFF) - ENDIF() -ELSE() - # set back to OFF (in case was ON) - IF(EXAMPLES_ENABLE_F90) - PRINT_WARNING("EXAMPLES_ENABLE_F90 is ON but both F77 and F2003 interfaces are OFF" - "Disabling EXAMPLES_ENABLE_F90") - FORCE_VARIABLE(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" OFF) - ENDIF() - HIDE_VARIABLE(EXAMPLES_ENABLE_F90) -ENDIF() - -# CUDA examples (off by default) -SET(DOCSTR "Build SUNDIALS CUDA examples") -IF(CUDA_ENABLE) - OPTION(EXAMPLES_ENABLE_CUDA "${DOCSTR}" OFF) -ELSE() - IF(EXAMPLES_ENABLE_CUDA) - PRINT_WARNING("EXAMPLES_ENABLE_CUDA is ON but CUDA_ENABLE is OFF" - "Disabling EXAMPLES_ENABLE_CUDA") - FORCE_VARIABLE(EXAMPLES_ENABLE_CUDA BOOL "${DOCSTR}" OFF) - ENDIF() -ENDIF() - -# If any of the above examples are enabled set EXAMPLES_ENABLED to TRUE -IF(EXAMPLES_ENABLE_C OR - EXAMPLES_ENABLE_F77 OR - EXAMPLES_ENABLE_CXX OR - EXAMPLES_ENABLE_F90 OR - EXAMPLES_ENABLE_CUDA) - SET(EXAMPLES_ENABLED TRUE) -ELSE() - SET(EXAMPLES_ENABLED FALSE) -ENDIF() - -# --------------------------------------------------------------- -# Install examples? -# --------------------------------------------------------------- - -# Enable installing examples by default -SET(DOCSTR "Install SUNDIALS examples") -IF(EXAMPLES_ENABLED) - OPTION(EXAMPLES_INSTALL "${DOCSTR}" ON) -ELSE() - FORCE_VARIABLE(EXAMPLES_INSTALL BOOL "${DOCSTR}" OFF) - HIDE_VARIABLE(EXAMPLES_INSTALL) -ENDIF() - -# If examples are to be exported, check where we should install them. -IF(EXAMPLES_INSTALL) - - SHOW_VARIABLE(EXAMPLES_INSTALL_PATH PATH - "Output directory for installing example files" - "${CMAKE_INSTALL_PREFIX}/examples") - - IF(NOT EXAMPLES_INSTALL_PATH) - PRINT_WARNING("The example installation path is empty" - "Example installation path was reset to its default value") - SET(EXAMPLES_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/examples" CACHE STRING - "Output directory for installing example files" FORCE) - ENDIF() - -ELSE() - - HIDE_VARIABLE(EXAMPLES_INSTALL_PATH) - -ENDIF() - - -# ============================================================================== -# Advanced (hidden) options -# ============================================================================== - -# ------------------------------------------------------------------------------ -# Manually specify the Fortran name-mangling scheme -# -# The build system tries to infer the Fortran name-mangling scheme using a -# Fortran compiler and defaults to using lower case and one underscore if the -# scheme can not be determined. If a working Fortran compiler is not available -# or the user needs to override the inferred or default scheme, the following -# options specify the case and number of appended underscores corresponding to -# the Fortran name-mangling scheme of symbol names that do not themselves -# contain underscores. This is all we really need for the FCMIX and LAPACK -# interfaces. A working Fortran compiler is only necessary for building Fortran -# example programs. -# ------------------------------------------------------------------------------ - -# The case to use in the name-mangling scheme -show_variable(SUNDIALS_F77_FUNC_CASE STRING - "case of Fortran function names (lower/upper)" - "") - -# The number of underscores of appended in the name-mangling scheme -show_variable(SUNDIALS_F77_FUNC_UNDERSCORES STRING - "number of underscores appended to Fortran function names (none/one/two)" - "") - -# Hide the name-mangling varibales as advanced options -mark_as_advanced(FORCE SUNDIALS_F77_FUNC_CASE) -mark_as_advanced(FORCE SUNDIALS_F77_FUNC_UNDERSCORES) - -# If used, both case and underscores must be set -if((NOT SUNDIALS_F77_FUNC_CASE) AND SUNDIALS_F77_FUNC_UNDERSCORES) - message(FATAL_ERROR - "If SUNDIALS_F77_FUNC_UNDERSCORES is set, SUNDIALS_F77_FUNC_CASE must also be set.") -endif() - -if(SUNDIALS_F77_FUNC_CASE AND (NOT SUNDIALS_F77_FUNC_UNDERSCORES)) - message(FATAL_ERROR - "If SUNDIALS_F77_FUNC_CASE is set, SUNDIALS_F77_FUNC_UNDERSCORES must also be set.") -endif() - -# ------------------------------------------------------------------------------ -# Include development examples in regression tests? -# -# NOTE: Development examples are currently used for internal testing and may -# produce erroneous failures when run on different systems as the pass/fail -# status is determined by comparing the output against a saved output file. -# ------------------------------------------------------------------------------ -OPTION(SUNDIALS_DEVTESTS "Include development tests in make test" OFF) -MARK_AS_ADVANCED(FORCE SUNDIALS_DEVTESTS) - -# =============================================================== -# Add any platform specifc settings -# =============================================================== - -IF(APPLE) - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") -ENDIF(APPLE) - -# =============================================================== -# Fortran and C++ settings -# =============================================================== - -# --------------------------------------------------------------- -# A Fortran compiler is needed to: -# (a) Determine the name-mangling scheme if FCMIX, BLAS, or -# LAPACK are enabled -# (b) Compile example programs if F77 or F90 examples are enabled -# --------------------------------------------------------------- - -# Do we need a Fortran name-mangling scheme? -if(F77_INTERFACE_ENABLE OR BLAS_ENABLE OR LAPACK_ENABLE) - set(NEED_FORTRAN_NAME_MANGLING TRUE) -endif() - -# Did the user provide a name-mangling scheme? -if(SUNDIALS_F77_FUNC_CASE AND SUNDIALS_F77_FUNC_UNDERSCORES) - - STRING(TOUPPER ${SUNDIALS_F77_FUNC_CASE} SUNDIALS_F77_FUNC_CASE) - STRING(TOUPPER ${SUNDIALS_F77_FUNC_UNDERSCORES} SUNDIALS_F77_FUNC_UNDERSCORES) - - # Based on the given case and number of underscores, set the C preprocessor - # macro definitions. Since SUNDIALS never uses symbols names containing - # underscores we set the name-mangling schemes to be the same. In general, - # names of symbols with and without underscore may be mangled differently - # (e.g. g77 mangles mysub to mysub_ and my_sub to my_sub__) - if(SUNDIALS_F77_FUNC_CASE MATCHES "LOWER") - if(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "NONE") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name") - elseif(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "ONE") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name ## _") - SET(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name ## _") - elseif(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "TWO") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) name ## __") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) name ## __") - else() - message(FATAL_ERROR "Invalid SUNDIALS_F77_FUNC_UNDERSCORES option.") - endif() - elseif(SUNDIALS_F77_FUNC_CASE MATCHES "UPPER") - if(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "NONE") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME") - elseif(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "ONE") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME ## _") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## _") - elseif(SUNDIALS_F77_FUNC_UNDERSCORES MATCHES "TWO") - set(F77_MANGLE_MACRO1 "#define SUNDIALS_F77_FUNC(name,NAME) NAME ## __") - set(F77_MANGLE_MACRO2 "#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## __") - else() - message(FATAL_ERROR "Invalid SUNDIALS_F77_FUNC_UNDERSCORES option.") - endif() - else() - message(FATAL_ERROR "Invalid SUNDIALS_F77_FUNC_CASE option.") - endif() - - # name-mangling scheme has been manually set - set(NEED_FORTRAN_NAME_MANGLING FALSE) - -endif() - -# Do we need a Fortran compiler? -if(F2003_INTERFACE_ENABLE OR EXAMPLES_ENABLE_F77 OR EXAMPLES_ENABLE_F90 OR NEED_FORTRAN_NAME_MANGLING) - include(SundialsFortran) -endif() - -# Ensure that F90 compiler is found if F90 examples are enabled -if (EXAMPLES_ENABLE_F90 AND (NOT F90_FOUND)) - PRINT_WARNING("Compiler with F90 support not found" "Disabling F90 Examples") - SET(DOCSTR "Build F90 examples") - FORCE_VARIABLE(EXAMPLES_ENABLE_F90 "${DOCSTR}" OFF) -endif() - -# Ensure that F90 compiler found if F2003 interface is enabled -if (F2003_INTERFACE_ENABLE AND (NOT F90_FOUND)) - PRINT_WARNING("Compiler with F90 support not found" "Disabling F2003 Interface") - SET(DOCSTR "Enable Fortran 2003 interfaces") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) -endif() - -# F2003 interface requires ISO_C_BINDING -IF(F2003_INTERFACE_ENABLE AND (NOT Fortran_COMPILER_SUPPORTS_ISOCBINDING)) - PRINT_WARNING("Fortran compiler does not provide ISO_C_BINDING support" - "Disabling F2003 interface") - SET(DOCSTR "Enable Fortran 2003 interfaces") - FORCE_VARIABLE(F2003_INTERFACE_ENABLE BOOL "${DOCSTR}" OFF) -ENDIF() - - -# --------------------------------------------------------------- -# A C++ compiler is needed if: -# (a) C++ examples are enabled -# (b) CUDA is enabled -# (c) RAJA is enabled -# (d) Trilinos is enabled -# --------------------------------------------------------------- - -if(EXAMPLES_ENABLE_CXX OR CUDA_ENABLE OR RAJA_ENABLE OR Trilinos_ENABLE) - include(SundialsCXX) -endif() - -# --------------------------------------------------------------- -# Setup CUDA. Since CUDA is its own language we do this -# separate from the TPLs. -# --------------------------------------------------------------- - -if(CUDA_ENABLE) - find_package(CUDA) - if (CUDA_FOUND) - set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -lineinfo") - else() - message(STATUS "Disabling CUDA support, could not find CUDA.") - set(CUDA_ENABLE OFF) - endif() -endif(CUDA_ENABLE) - -# --------------------------------------------------------------- -# Now that all languages are setup, we can configure them more. -# --------------------------------------------------------------- - -# C++11 is needed if: -# (a) CUDA is enabled -# C++11 should not be enabled if -# (a) RAJA is enabled (they provide a std flag) -if (CXX_FOUND AND CUDA_ENABLE AND CUDA_FOUND AND (NOT RAJA_ENABLE)) - USE_CXX_STD(11) -endif() - -# --------------------------------------------------------------- -# Decide how to compile MPI codes. We must check for MPI if -# MPI is enabled or if Trilinos is enabled because the Trilinos -# examples may need MPI without us turning on the MPI SUNDIALS -# components. -# --------------------------------------------------------------- - -if(MPI_ENABLE OR Trilinos_ENABLE) - include(SundialsMPI) -endif() - -if(MPI_ENABLE) - if(NOT MPI_C_FOUND) - print_warning("MPI not functional" "Parallel support will not be provided") - else() - set(IS_MPI_ENABLED "#ifndef SUNDIALS_MPI_ENABLED\n#define SUNDIALS_MPI_ENABLED 1\n#endif") - endif() -endif() - -# always define FMPI_COMM_F2C in sundials_fconfig.h file -if(MPIC_MPI2) - set(F77_MPI_COMM_F2C "#define SUNDIALS_MPI_COMM_F2C 1") - set(FMPI_COMM_F2C ".true.") -else() - set(F77_MPI_COMM_F2C "#define SUNDIALS_MPI_COMM_F2C 0") - set(FMPI_COMM_F2C ".false.") -endif() - -# ------------------------------------------------------------- -# Find OpenMP -# ------------------------------------------------------------- - -if(OPENMP_ENABLE OR OPENMP_DEVICE_ENABLE) - - include(SundialsOpenMP) - - # turn off OPENMP_ENABLE and OPENMP_DEVICE_ENABLE if OpenMP is not found - if(NOT OPENMP_FOUND) - print_warning("Could not determine OpenMP compiler flags" "Disabling OpenMP support") - force_variable(OPENMP_ENABLE BOOL "Enable OpenMP support" OFF) - force_variable(OPENMP_DEVICE_ENABLE BOOL "Enable OpenMP device offloading support" OFF) - endif() - - # turn off OPENMP_DEVICE_ENABLE if offloading is not supported - if(OPENMP_DEVICE_ENABLE AND (NOT OPENMP_SUPPORTS_DEVICE_OFFLOADING)) - print_warning("OpenMP found does not support device offloading" - "Disabling OpenMP device offloading support") - force_variable(OPENMP_DEVICE_ENABLE BOOL "Enable OpenMP device offloading support" OFF) - endif() - -endif() - -# ------------------------------------------------------------- -# Find PThreads -# ------------------------------------------------------------- - -IF(PTHREAD_ENABLE) - FIND_PACKAGE(Threads) - IF(CMAKE_USE_PTHREADS_INIT) - message(STATUS "Using Pthreads") - SET(PTHREADS_FOUND TRUE) - # SGS - ELSE() - message(STATUS "Disabling Pthreads support, could not determine compiler flags") - endif() -ENDIF(PTHREAD_ENABLE) - -# ------------------------------------------------------------- -# Find RAJA -# ------------------------------------------------------------- - -# disable RAJA if CUDA is not enabled/working -if(RAJA_ENABLE AND (NOT CUDA_FOUND)) - PRINT_WARNING("CUDA is required for RAJA support" "Please enable CUDA and RAJA") - FORCE_VARIABLE(RAJA_ENABLE BOOL "RAJA disabled" OFF) -endif() - -if(RAJA_ENABLE) - # Look for CMake configuration file in RAJA installation - find_package(RAJA) - if (RAJA_FOUND) - include_directories(${RAJA_INCLUDE_DIR}) - set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${RAJA_NVCC_FLAGS}) - else() - PRINT_WARNING("RAJA configuration not found" - "Please set RAJA_DIR to provide path to RAJA CMake configuration file.") - endif() -endif(RAJA_ENABLE) - -# =============================================================== -# Find (and test) external packages -# =============================================================== - -# --------------------------------------------------------------- -# Find (and test) the BLAS libraries -# --------------------------------------------------------------- - -# If BLAS is needed, first try to find the appropriate -# libraries and linker flags needed to link against them. - -IF(BLAS_ENABLE) - - # find BLAS - INCLUDE(SundialsBlas) - - # show after include so FindBlas can locate BLAS_LIBRARIES if necessary - SHOW_VARIABLE(BLAS_LIBRARIES STRING "Blas libraries" "${BLAS_LIBRARIES}") - - IF(BLAS_LIBRARIES AND NOT BLAS_FOUND) - PRINT_WARNING("BLAS not functional" - "BLAS support will not be provided") - ELSE() - #set sundials_config.h symbol via sundials_config.in - SET(SUNDIALS_BLAS TRUE) - ENDIF() - -ELSE() - - HIDE_VARIABLE(BLAS_LIBRARIES) - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the Lapack libraries -# --------------------------------------------------------------- - -# If LAPACK is needed, first try to find the appropriate -# libraries and linker flags needed to link against them. - -IF(LAPACK_ENABLE) - - # find LAPACK and BLAS Libraries - INCLUDE(SundialsLapack) - - # show after include so FindLapack can locate LAPCK_LIBRARIES if necessary - SHOW_VARIABLE(LAPACK_LIBRARIES STRING "Lapack and Blas libraries" "${LAPACK_LIBRARIES}") - - IF(LAPACK_LIBRARIES AND NOT LAPACK_FOUND) - PRINT_WARNING("LAPACK not functional" - "Blas/Lapack support will not be provided") - ELSE() - #set sundials_config.h symbol via sundials_config.in - SET(SUNDIALS_BLAS_LAPACK TRUE) - ENDIF() - -ELSE() - - HIDE_VARIABLE(LAPACK_LIBRARIES) - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the SUPERLUMT libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for SuperLU_MT integer type - -# If SUPERLUMT is needed, first try to find the appropriate -# libraries to link against them. - -IF(SUPERLUMT_ENABLE) - - # Show SuperLU_MT options and set default thread type (Pthreads) - SHOW_VARIABLE(SUPERLUMT_THREAD_TYPE STRING "SUPERLUMT threading type: OpenMP or Pthread" "Pthread") - SHOW_VARIABLE(SUPERLUMT_INCLUDE_DIR PATH "SUPERLUMT include directory" "${SUPERLUMT_INCLUDE_DIR}") - SHOW_VARIABLE(SUPERLUMT_LIBRARY_DIR PATH "SUPERLUMT library directory" "${SUPERLUMT_LIBRARY_DIR}") - - INCLUDE(SundialsSuperLUMT) - - IF(SUPERLUMT_FOUND) - # sundials_config.h symbols - SET(SUNDIALS_SUPERLUMT TRUE) - SET(SUNDIALS_SUPERLUMT_THREAD_TYPE ${SUPERLUMT_THREAD_TYPE}) - INCLUDE_DIRECTORIES(${SUPERLUMT_INCLUDE_DIR}) - ENDIF() - - IF(SUPERLUMT_LIBRARIES AND NOT SUPERLUMT_FOUND) - PRINT_WARNING("SUPERLUMT not functional - support will not be provided" - "Double check spelling specified libraries (search is case sensitive)") - ENDIF(SUPERLUMT_LIBRARIES AND NOT SUPERLUMT_FOUND) - -ELSE() - - HIDE_VARIABLE(SUPERLUMT_THREAD_TYPE) - HIDE_VARIABLE(SUPERLUMT_LIBRARY_DIR) - HIDE_VARIABLE(SUPERLUMT_INCLUDE_DIR) - SET (SUPERLUMT_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the KLU libraries -# --------------------------------------------------------------- - -# If KLU is requested, first try to find the appropriate libraries to -# link against them. - -IF(KLU_ENABLE) - - SHOW_VARIABLE(KLU_INCLUDE_DIR PATH "KLU include directory" - "${KLU_INCLUDE_DIR}") - SHOW_VARIABLE(KLU_LIBRARY_DIR PATH - "Klu library directory" "${KLU_LIBRARY_DIR}") - - set(KLU_FOUND TRUE) - get_filename_component(PYBAMM_DIR ${PROJECT_SOURCE_DIR} DIRECTORY) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PYBAMM_DIR}) # use FindSuiteSparse.cmake that is in PyBaMM root - set(SuiteSparse_ROOT ${PYBAMM_DIR}/SuiteSparse-5.6.0) - find_package(SuiteSparse OPTIONAL_COMPONENTS KLU AMD COLAMD BTF) - include_directories(${SuiteSparse_INCLUDE_DIRS}) - set(KLU_LIBRARIES ${SuiteSparse_LIBRARIES}) - - - IF(KLU_LIBRARIES AND NOT KLU_FOUND) - PRINT_WARNING("KLU not functional - support will not be provided" - "Double check spelling of include path and specified libraries (search is case sensitive)") - ENDIF(KLU_LIBRARIES AND NOT KLU_FOUND) - -ELSE() - - HIDE_VARIABLE(KLU_LIBRARY_DIR) - HIDE_VARIABLE(KLU_INCLUDE_DIR) - SET (KLU_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF(KLU_ENABLE) - -# --------------------------------------------------------------- -# Find (and test) the hypre libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for hypre precision and integer type - -IF(HYPRE_ENABLE) - SHOW_VARIABLE(HYPRE_INCLUDE_DIR PATH "HYPRE include directory" - "${HYPRE_INCLUDE_DIR}") - SHOW_VARIABLE(HYPRE_LIBRARY_DIR PATH - "HYPRE library directory" "${HYPRE_LIBRARY_DIR}") - - INCLUDE(SundialsHypre) - - IF(HYPRE_FOUND) - # sundials_config.h symbol - SET(SUNDIALS_HYPRE TRUE) - INCLUDE_DIRECTORIES(${HYPRE_INCLUDE_DIR}) - ENDIF(HYPRE_FOUND) - - IF(HYPRE_LIBRARIES AND NOT HYPRE_FOUND) - PRINT_WARNING("HYPRE not functional - support will not be provided" - "Found hypre library, test code does not work") - ENDIF(HYPRE_LIBRARIES AND NOT HYPRE_FOUND) - -ELSE() - - HIDE_VARIABLE(HYPRE_INCLUDE_DIR) - HIDE_VARIABLE(HYPRE_LIBRARY_DIR) - SET (HYPRE_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - -# --------------------------------------------------------------- -# Find (and test) the PETSc libraries -# --------------------------------------------------------------- - -# >>>>>>> NOTE: Need to add check for PETSc precision and integer type - -IF(PETSC_ENABLE) - SHOW_VARIABLE(PETSC_INCLUDE_DIR PATH "PETSc include directory" - "${PETSC_INCLUDE_DIR}") - SHOW_VARIABLE(PETSC_LIBRARY_DIR PATH - "PETSc library directory" "${PETSC_LIBRARY_DIR}") - - INCLUDE(SundialsPETSc) - - IF(PETSC_FOUND) - # sundials_config.h symbol - SET(SUNDIALS_PETSC TRUE) - INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIR}) - ENDIF(PETSC_FOUND) - - IF(PETSC_LIBRARIES AND NOT PETSC_FOUND) - PRINT_WARNING("PETSC not functional - support will not be provided" - "Double check spelling specified libraries (search is case sensitive)") - ENDIF(PETSC_LIBRARIES AND NOT PETSC_FOUND) - -ELSE() - - HIDE_VARIABLE(PETSC_LIBRARY_DIR) - HIDE_VARIABLE(PETSC_INCLUDE_DIR) - SET (PETSC_DISABLED TRUE CACHE INTERNAL "GUI - return when first set") - -ENDIF() - -# ------------------------------------------------------------- -# Find Trilinos -# ------------------------------------------------------------- - -if(Trilinos_ENABLE) - include(SundialsTrilinos) - if(NOT Trilinos_FUNCTIONAL) - PRINT_WARNING("Trilinos not functional" "Verify the path to Trilinos and check the Trilinos installation") - endif() -endif(Trilinos_ENABLE) - - -# =============================================================== -# At this point all the configuration options are set. -# =============================================================== - -# --------------------------------------------------------------- -# Configure the header file sundials_config.h -# --------------------------------------------------------------- - -# All required substitution variables should be available at this point. -# Generate the header file and place it in the binary dir. -CONFIGURE_FILE( - ${PROJECT_SOURCE_DIR}/include/sundials/sundials_config.in - ${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h - ) -CONFIGURE_FILE( - ${PROJECT_SOURCE_DIR}/include/sundials/sundials_fconfig.in - ${PROJECT_BINARY_DIR}/include/sundials/sundials_fconfig.h - ) - -# Add the include directory in the source tree and the one in -# the binary tree (for the header file sundials_config.h) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - -# --------------------------------------------------------------- -# Enable testing and add source and example files to the build. -# --------------------------------------------------------------- - -# Enable testing -IF(EXAMPLES_ENABLED) - INCLUDE(SundialsTesting) -ENDIF() - -# Add selected packages and modules to the build -ADD_SUBDIRECTORY(src) - -# Add selected examples to the build -IF(EXAMPLES_ENABLED) - ADD_SUBDIRECTORY(examples) -ENDIF() - -# --------------------------------------------------------------- -# Install configuration header files and license file -# --------------------------------------------------------------- - -# install configured header file -INSTALL( - FILES ${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h - DESTINATION include/sundials - ) - -# install configured header file for Fortran 90 -INSTALL( - FILES ${PROJECT_BINARY_DIR}/include/sundials/sundials_fconfig.h - DESTINATION include/sundials - ) - -# install shared Fortran 2003 modules -IF(F2003_INTERFACE_ENABLE) - # While the .mod files get generated for static and shared - # libraries, they are identical. So only install one set - # of the .mod files. - IF(BUILD_STATIC_LIBS) - INSTALL( - DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_STATIC/ - DESTINATION ${Fortran_INSTALL_MODDIR} - ) - ELSE() - INSTALL( - DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_SHARED/ - DESTINATION ${Fortran_INSTALL_MODDIR} - ) - ENDIF() -ENDIF() - -# install license and notice files -INSTALL( - FILES ${PROJECT_SOURCE_DIR}/LICENSE - DESTINATION include/sundials - ) -INSTALL( - FILES ${PROJECT_SOURCE_DIR}/NOTICE - DESTINATION include/sundials - ) From 45b85a7652aef8aac71c153eb0e9a2c027907754 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:35:40 +0530 Subject: [PATCH 76/95] #3049 add `pyproject.toml` to release workflows --- .github/release_workflow.md | 5 ++++- scripts/update_version.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/release_workflow.md b/.github/release_workflow.md index 1af23fca25..280a1c160f 100644 --- a/.github/release_workflow.md +++ b/.github/release_workflow.md @@ -9,6 +9,7 @@ This file contains the workflow required to make a `PyBaMM` release on GitHub an - `pybamm/version.py` - `docs/conf.py` - `CITATION.cff` + - `pyproject.toml` - `vcpkg.json` - `docs/_static/versions.json` - `CHANGELOG.md` @@ -32,6 +33,7 @@ If a new release candidate is required after the release of `rc0` - - `pybamm/version.py` - `docs/conf.py` - `CITATION.cff` + - `pyproject.toml` - `vcpkg.json` - `docs/_static/versions.json` - `CHANGELOG.md` @@ -53,6 +55,7 @@ Once satisfied with the release candidates - - `pybamm/version.py` - `docs/conf.py` - `CITATION.cff` + - `pyproject.toml` - `vcpkg.json` - `docs/_static/versions.json` - `CHANGELOG.md` @@ -70,7 +73,7 @@ Once satisfied with the release candidates - Some other essential things to check throughout the release process - - If updating our custom vcpkg registory entries [pybamm-team/sundials-vcpkg-registry](https://github.com/pybamm-team/sundials-vcpkg-registry) or [pybamm-team/casadi-vcpkg-registry](https://github.com/pybamm-team/casadi-vcpkg-registry) (used to build Windows wheels), make sure to update the baseline of the registories in vcpkg-configuration.json to the latest commit id. -- Update jax and jaxlib to the latest version in `pybamm.util` and `setup.py`, fixing any bugs that arise +- Update jax and jaxlib to the latest version in `pybamm.util` and `pyproject.toml`, fixing any bugs that arise - Make sure the URLs in `docs/_static/versions.json` are valid - As the release workflow is initiated by the `release` event, it's important to note that the default `GITHUB_REF` used by `actions/checkout` during the checkout process will correspond to the tag created during the release process. Consequently, the workflows will consistently build PyBaMM based on the commit associated with this tag. Should new commits be introduced to the `vYY.MM` branch, such as those addressing build issues, it becomes necessary to manually update this tag to point to the most recent commit - ``` diff --git a/scripts/update_version.py b/scripts/update_version.py index 003edee274..8a2d832e59 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -48,7 +48,7 @@ def update_version(): file.seek(0) file.write(replace_version) - # docs/source/_static/versions.json for readthedocs build + # docs/_static/versions.json for readthedocs build if "rc" not in release_version: with open( os.path.join(pybamm.root_dir(), "docs", "_static", "versions.json"), From 37c991d5907c22e7436c3d0299b463e3bb3b3ee0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:36:16 +0530 Subject: [PATCH 77/95] #3049 remove `setup.py` as CI cache dependency path --- .github/workflows/test_on_push.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 6821016e45..88ada069b4 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -90,7 +90,6 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: 'pip' - cache-dependency-path: setup.py - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 @@ -145,7 +144,6 @@ jobs: with: python-version: 3.11 cache: 'pip' - cache-dependency-path: setup.py - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -225,7 +223,6 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: 'pip' - cache-dependency-path: setup.py - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 @@ -281,7 +278,6 @@ jobs: with: python-version: 3.11 cache: 'pip' - cache-dependency-path: setup.py - name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11 run: pipx run nox -s doctests @@ -321,7 +317,6 @@ jobs: with: python-version: 3.11 cache: 'pip' - cache-dependency-path: setup.py - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 @@ -374,7 +369,6 @@ jobs: with: python-version: 3.11 cache: 'pip' - cache-dependency-path: setup.py - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 From 925d39005b81918bc0984f7b572232278da043b0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:36:36 +0530 Subject: [PATCH 78/95] #3049 add note about new file to manage deps --- docs/source/user_guide/installation/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user_guide/installation/index.rst b/docs/source/user_guide/installation/index.rst index 6338323e79..93e54c51fe 100644 --- a/docs/source/user_guide/installation/index.rst +++ b/docs/source/user_guide/installation/index.rst @@ -76,7 +76,7 @@ Optional Dependencies PyBaMM has a number of optional dependencies for different functionalities. If the optional dependency is not installed, PyBaMM will raise an ImportError when the method requiring that dependency is called. -If using pip, optional PyBaMM dependencies can be installed or managed in a file (e.g. requirements.txt or setup.py) +If you are using ``pip``, optional PyBaMM dependencies can be installed or managed in a file (e.g. requirements.txt, setup.py, or pyproject.toml) as optional extras (e.g.,``pybamm[dev,plot]``). All optional dependencies can be installed with ``pybamm[all]``, and specific sets of dependencies are listed in the sections below. From 1d16f5d6ee3feecb16abb191d1f621b312c22932 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:45:39 +0530 Subject: [PATCH 79/95] #3049 clarify usage of `cmake` and `casadi` In the build-time requirements for Windows, we don't use cmake and casadi from pip, but from other sources. This is because we use Visual Studio to compile. --- pyproject.toml | 4 ++-- setup.py | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c91d275789..002c29d76b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,8 +2,8 @@ requires = [ "setuptools", "wheel", + # On Windows, use the CasADi vcpkg registry and CMake bundled from MSVC "casadi>=3.6.0; platform_system!='Windows'", - # use CMake bundled from MSVC on Windows "cmake; platform_system!='Windows'", ] build-backend = "setuptools.build_meta" @@ -72,7 +72,7 @@ examples = [ # Plotting functionality plot = [ "imageio>=2.9.0", - # Note: matplotlib is loaded for debug plots, but to ensure pybamm runs + # Note: matplotlib is loaded for debug plots, but to ensure PyBaMM runs # on systems without an attached display, it should never be imported # outside of plot() methods. "matplotlib>=2.0", diff --git a/setup.py b/setup.py index a0180cb3e8..9cfc4df4ff 100644 --- a/setup.py +++ b/setup.py @@ -16,13 +16,11 @@ from distutils.command.build_ext import build_ext -# ---------- CMake steps for IDAKLU target (non-Windows) ------------------------------- - - default_lib_dir = ( "" if system() == "Windows" else os.path.join(os.getenv("HOME"), ".local") ) +# ---------- set environment variables for vcpkg on Windows ---------------------------- def set_vcpkg_environment_variables(): if not os.getenv("VCPKG_ROOT_DIR"): @@ -41,6 +39,7 @@ def set_vcpkg_environment_variables(): os.getenv("VCPKG_FEATURE_FLAGS"), ) +# ---------- CMakeBuild class (custom build_ext for IDAKLU target) --------------------- class CMakeBuild(build_ext): user_options = build_ext.user_options + [ @@ -119,6 +118,8 @@ def run(self): if os.path.isfile(os.path.join(build_dir, "CMakeError.log")): os.remove(os.path.join(build_dir, "CMakeError.log")) +# ---------- configuration for vcpkg on Windows ---------------------------------------- + build_env = os.environ if os.getenv("PYBAMM_USE_VCPKG"): ( @@ -130,26 +131,29 @@ def run(self): build_env["vcpkg_default_triplet"] = vcpkg_default_triplet build_env["vcpkg_feature_flags"] = vcpkg_feature_flags +# ---------- Run CMake and build IDAKLU module ----------------------------------------- + cmake_list_dir = os.path.abspath(os.path.dirname(__file__)) - print("-" * 10, "Running CMake for idaklu solver", "-" * 40) + print("-" * 10, "Running CMake for IDAKLU solver", "-" * 40) subprocess.run( ["cmake", cmake_list_dir] + cmake_args, cwd=build_dir, env=build_env - ) + , check=True) if os.path.isfile(os.path.join(build_dir, "CMakeError.log")): msg = ( - "cmake configuration steps encountered errors, and the idaklu module" + "cmake configuration steps encountered errors, and the IDAKLU module" " could not be built. Make sure dependencies are correctly " "installed. See " "https://docs.pybamm.org/en/latest/source/user_guide/installation/install-from-source.html" # noqa: E501 ) raise RuntimeError(msg) else: - print("-" * 10, "Building idaklu module", "-" * 40) + print("-" * 10, "Building IDAKLU module", "-" * 40) subprocess.run( ["cmake", "--build", ".", "--config", "Release"], cwd=build_dir, env=build_env, + check=True, ) # Move from build temp to final position @@ -218,7 +222,7 @@ def run(self): install.run(self) -# ---------- custom wheel build (non-Windows) ------------------------------------------ +# ---------- Custom class for building wheels ------------------------------------------ class bdist_wheel(orig.bdist_wheel): @@ -250,8 +254,7 @@ def compile_KLU(): # Return True if: # - Not running on Windows AND # - CMake is found AND - # - The pybind11 and casadi-headers directories are found - # in the PyBaMM project directory + # - The pybind11/ directory is found in the PyBaMM project directory CMakeFound = True PyBind11Found = True windows = (not system()) or system() == "Windows" From 15c4a8b086acc70f838c162797bad9f9d1ae4e0d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:51:48 +0530 Subject: [PATCH 80/95] #3049 update version to 23.9rc0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 002c29d76b..5f26d260de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta" [project] name = "pybamm" -version = "23.5" +version = "23.9rc0" license = { file = "LICENSE.txt" } description = "Python Battery Mathematical Modelling" authors = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] From 39ee77b465bffbeedc1de5bf576e201bb4f3aa44 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 17 Oct 2023 20:00:59 +0530 Subject: [PATCH 81/95] #3049 make cmake a bit verbose about sundials and suitesparse --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bea0b0e5a4..182fd489f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,7 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}) # Sundials find_package(SUNDIALS REQUIRED) -message("sundials ${SUNDIALS_INCLUDE_DIR} ${SUNDIALS_LIBRARIES}") +message("SUNDIALS found in ${SUNDIALS_INCLUDE_DIR}: ${SUNDIALS_LIBRARIES}") target_include_directories(idaklu PRIVATE ${SUNDIALS_INCLUDE_DIR}) target_link_libraries(idaklu PRIVATE ${SUNDIALS_LIBRARIES} casadi) @@ -98,6 +98,7 @@ if(DEFINED VCPKG_ROOT_DIR) find_package(SuiteSparse CONFIG REQUIRED) else() find_package(SuiteSparse REQUIRED) + message("SuiteSparse found in ${SuiteSparse_INCLUDE_DIRS}: ${SuiteSparse_LIBRARIES}") endif() include_directories(${SuiteSparse_INCLUDE_DIRS}) target_link_libraries(idaklu PRIVATE ${SuiteSparse_LIBRARIES}) From 62ed4c4e607f6f95c98b4193705ab2b0cfc6b2f9 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:59:32 +0530 Subject: [PATCH 82/95] #3049 add suggestions from code review Co-Authored-By: Saransh Chopra --- .github/workflows/publish_pypi.yml | 105 ++++++++++++++--------------- 1 file changed, 50 insertions(+), 55 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 29c352cf6c..8c07858825 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -1,7 +1,4 @@ -# name: Build and publish package to PyPI -name: Test building wheels -# Temporarily disable publishing to PyPI and enable -# building wheels on pull requests +name: Build and publish package to PyPI on: release: types: [published] @@ -33,15 +30,15 @@ jobs: - name: Clone pybind11 repo (no history) run: git clone --depth 1 --branch v2.11.1 https://github.com/pybind/pybind11.git - - name: Install vcpkg on windows + - name: Install vcpkg on Windows run: | cd C:\ rm -r -fo 'C:\vcpkg' - git clone https://github.com/microsoft/vcpkg --branch 2023.08.09 + git clone https://github.com/microsoft/vcpkg cd vcpkg .\bootstrap-vcpkg.bat - - name: Cache packages installed through vcpkg on windows + - name: Cache packages installed through vcpkg on Windows uses: actions/cache@v3 env: cache-name: vckpg_binary_cache @@ -54,13 +51,13 @@ jobs: uses: mxschmitt/action-tmate@v3 if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} - - name: Build 64 bits wheels on Windows + - name: Build 64-bit wheels on Windows run: pipx run cibuildwheel --output-dir wheelhouse env: CIBW_ENVIRONMENT: 'PYBAMM_USE_VCPKG=ON VCPKG_ROOT_DIR=C:\vcpkg VCPKG_DEFAULT_TRIPLET=x64-windows-static-md VCPKG_FEATURE_FLAGS=manifests,registries CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM=x64' CIBW_ARCHS: "AMD64" - - name: Upload windows wheels + - name: Upload Windows wheels uses: actions/upload-artifact@v3 with: name: windows_wheels @@ -109,8 +106,6 @@ jobs: python -m pip install cmake casadi numpy && python scripts/fix_casadi_rpath_mac.py && scripts/fix_suitesparse_rpath_mac.sh - # got error "re.error: multiple repeat at position 104" on python 3.7 when --require-archs added, so remove - # it for mac CIBW_REPAIR_WHEEL_COMMAND_MACOS: > delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} @@ -146,47 +141,47 @@ jobs: path: ./dist/*.tar.gz if-no-files-found: error - # publish_pypi: - # if: github.event_name != 'schedule' - # name: Upload package to PyPI - # needs: [build_wheels, build_windows_wheels, build_sdist] - # runs-on: ubuntu-latest - # steps: - # - name: Download all artifacts - # uses: actions/download-artifact@v3 - - # - name: Move all package files to files/ - # run: | - # mkdir files - # mv windows_wheels/* wheels/* sdist/* files/ - - # - name: Publish on PyPI - # if: github.event.inputs.target == 'pypi' || github.event_name == 'release' - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # user: __token__ - # password: ${{ secrets.PYPI_TOKEN }} - # packages-dir: files/ - - # - name: Publish on TestPyPI - # if: github.event.inputs.target == 'testpypi' - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # user: __token__ - # password: ${{ secrets.TESTPYPI_TOKEN }} - # packages-dir: files/ - # repository-url: https://test.pypi.org/legacy/ - - # open_failure_issue: - # needs: [build_windows_wheels, build_wheels, build_sdist] - # name: Open an issue if build fails - # if: ${{ always() && contains(needs.*.result, 'failure') }} - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: JasonEtco/create-an-issue@v2 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # LOGS: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - # with: - # filename: .github/wheel_failure.md + publish_pypi: + if: github.event_name != 'schedule' + name: Upload package to PyPI + needs: [build_wheels, build_windows_wheels, build_sdist] + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v3 + + - name: Move all package files to files/ + run: | + mkdir files + mv windows_wheels/* wheels/* sdist/* files/ + + - name: Publish on PyPI + if: github.event.inputs.target == 'pypi' || github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + packages-dir: files/ + + - name: Publish on TestPyPI + if: github.event.inputs.target == 'testpypi' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TESTPYPI_TOKEN }} + packages-dir: files/ + repository-url: https://test.pypi.org/legacy/ + + open_failure_issue: + needs: [build_windows_wheels, build_wheels, build_sdist] + name: Open an issue if build fails + if: ${{ always() && contains(needs.*.result, 'failure') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LOGS: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + filename: .github/wheel_failure.md From db91a889efd01ff8ce904298b088b1172cc988ab Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:07:08 +0530 Subject: [PATCH 83/95] #3049 clarify extension language --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7e9a0e94af..9f583e324d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -387,7 +387,7 @@ wherever code is called that uses that citation (for example, in functions or in ### Installation -Installation of PyBaMM and its dependencies is handled via [pip](https://pip.pypa.io/en/stable/) and [setuptools](http://setuptools.readthedocs.io/). It uses `CMake` to compile C extensions using [`pybind11`](https://pybind11.readthedocs.io/en/stable/) and [`casadi`](https://web.casadi.org/) (non-Windows). The installation process is described in detail in the [source installation](https://docs.pybamm.org/en/latest/source/user_guide/installation/install-from-source.html) page and is configured through the `CMakeLists.txt` file. +Installation of PyBaMM and its dependencies is handled via [pip](https://pip.pypa.io/en/stable/) and [setuptools](http://setuptools.readthedocs.io/). It uses `CMake` to compile C++ extensions using [`pybind11`](https://pybind11.readthedocs.io/en/stable/) and [`casadi`](https://web.casadi.org/) (non-Windows). The installation process is described in detail in the [source installation](https://docs.pybamm.org/en/latest/source/user_guide/installation/install-from-source.html) page and is configured through the `CMakeLists.txt` file. Configuration files: From 076860934c089d8fec07232593be7576c26223bf Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:07:35 +0530 Subject: [PATCH 84/95] #3049 include citation file in source distribution Co-Authored-By: Saransh Chopra --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 24ae488d04..bfc9d0e718 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ graft pybamm +include CITATION.cff prune tests exclude CHANGELOG.md CODE-OF-CONDUCT.md CONTRIBUTING.md GOVERNANCE.md CMakeLists.txt From f56e3664c3b7fcf9f3cf8434c2eaf1e6bf216875 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:08:32 +0530 Subject: [PATCH 85/95] #3049 remove note about requirements.txt Co-Authored-By: Saransh Chopra --- docs/source/user_guide/installation/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user_guide/installation/index.rst b/docs/source/user_guide/installation/index.rst index 93e54c51fe..0e9b02de01 100644 --- a/docs/source/user_guide/installation/index.rst +++ b/docs/source/user_guide/installation/index.rst @@ -76,7 +76,7 @@ Optional Dependencies PyBaMM has a number of optional dependencies for different functionalities. If the optional dependency is not installed, PyBaMM will raise an ImportError when the method requiring that dependency is called. -If you are using ``pip``, optional PyBaMM dependencies can be installed or managed in a file (e.g. requirements.txt, setup.py, or pyproject.toml) +If you are using ``pip``, optional PyBaMM dependencies can be installed or managed in a file (e.g., setup.py, or pyproject.toml) as optional extras (e.g.,``pybamm[dev,plot]``). All optional dependencies can be installed with ``pybamm[all]``, and specific sets of dependencies are listed in the sections below. From e311029ab5631bdae38b67e4011a80ed58fe8d0e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:13:21 +0530 Subject: [PATCH 86/95] #3049 fix docs indentation Co-Authored-By: Saransh Chopra --- docs/source/user_guide/installation/install-from-source.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user_guide/installation/install-from-source.rst b/docs/source/user_guide/installation/install-from-source.rst index d4de957b16..003c7f143a 100644 --- a/docs/source/user_guide/installation/install-from-source.rst +++ b/docs/source/user_guide/installation/install-from-source.rst @@ -106,7 +106,7 @@ Installing PyBaMM You should now have everything ready to build and install PyBaMM successfully. Using ``Nox`` (recommended) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: bash From 052a1637eb910d2ce87323cc1d56ebfd0cfade62 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:24:11 +0530 Subject: [PATCH 87/95] #3049 specify lower bounds for `setuptools` Co-Authored-By: Saransh Chopra --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f26d260de..32912383f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools", + "setuptools>=64", "wheel", # On Windows, use the CasADi vcpkg registry and CMake bundled from MSVC "casadi>=3.6.0; platform_system!='Windows'", From 5e587c0df28cd4c609f5b6c3fb3ead545bcdd415 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:37:19 +0530 Subject: [PATCH 88/95] #3049 cleanup and clarify user installation page --- docs/source/user_guide/installation/GNU-linux.rst | 2 +- docs/source/user_guide/installation/windows.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/user_guide/installation/GNU-linux.rst b/docs/source/user_guide/installation/GNU-linux.rst index e66c3c2291..ca95bbe1b5 100644 --- a/docs/source/user_guide/installation/GNU-linux.rst +++ b/docs/source/user_guide/installation/GNU-linux.rst @@ -6,7 +6,7 @@ GNU-Linux & MacOS Prerequisites ------------- -To use and/or contribute to PyBaMM, you must have Python 3.8, 3.9, 3.10, or 3.11 installed. +To use PyBaMM, you must have Python 3.8, 3.9, 3.10, or 3.11 installed. .. tab:: Debian-based distributions (Debian, Ubuntu, Linux Mint) diff --git a/docs/source/user_guide/installation/windows.rst b/docs/source/user_guide/installation/windows.rst index 6ff48293bd..5b104e91bd 100644 --- a/docs/source/user_guide/installation/windows.rst +++ b/docs/source/user_guide/installation/windows.rst @@ -6,7 +6,7 @@ Windows Prerequisites ------------- -To use and/or contribute to PyBaMM, you must have Python 3.8, 3.9, 3.10, or 3.11 installed. +To use PyBaMM, you must have Python 3.8, 3.9, 3.10, or 3.11 installed. To install Python 3 download the installation files from `Python’s website `__. Make sure to @@ -27,7 +27,7 @@ install PyBaMM. You can find a reminder of how to navigate the terminal We recommend to install PyBaMM within a virtual environment, in order not to alter any distribution python files. -To install virtualenv type: +To install ``virtualenv``, type: .. code:: bash From 3b00b181245827b1420b0fa4162b2cd401990635 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 22:57:33 +0530 Subject: [PATCH 89/95] #3049 fix whitespace in `pybamm-requires` session Co-Authored-By: Eric G. Kratz --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 4af892565f..45787b6f4e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -41,7 +41,7 @@ def run_pybamm_requires(session): """Download, compile, and install the build-time requirements for Linux and macOS: the SuiteSparse and SUNDIALS libraries.""" # noqa: E501 set_environment_variables(PYBAMM_ENV, session=session) if sys.platform != "win32": - session.install("wget", "cmake" , silent=False) + session.install("wget", "cmake", silent=False) session.run("python", "scripts/install_KLU_Sundials.py") if not os.path.exists("./pybind11"): session.run( From b49b6f331625587665e45f013459dee8c336d5be Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:00:28 +0530 Subject: [PATCH 90/95] #3049 code review suggestions from Eric do not install gcc or gfortran if they are already installed, just reinstall them Co-Authored-By: Eric G. Kratz --- .github/workflows/publish_pypi.yml | 2 +- .github/workflows/test_on_push.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 8c07858825..fda75d4489 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -85,7 +85,7 @@ jobs: if: matrix.os == 'macos-latest' run: | brew update - brew install gcc gfortran libomp graphviz openblas + brew install graphviz openblas libomp brew reinstall gcc python -m pip install cmake wget python scripts/install_KLU_Sundials.py diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 88ada069b4..5aac923da2 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -77,7 +77,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas gcc gfortran libomp + brew install graphviz openblas libomp brew reinstall gcc - name: Install Windows system dependencies @@ -210,7 +210,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas gcc gfortran libomp + brew install graphviz openblas libomp brew reinstall gcc - name: Install Windows system dependencies From 09c4942a7627e186762478d9161e84f38d0b71e0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:08:17 +0530 Subject: [PATCH 91/95] Bump new minimum versions of dependencies --- pyproject.toml | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 32912383f7..675a7de335 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,10 +32,11 @@ classifiers = [ "Topic :: Scientific/Engineering", ] dependencies = [ - "numpy>=1.16", - "scipy>=1.3", - "casadi>=3.6.0", - "xarray", + "numpy>=1.23.5", + "scipy>=1.9.3", + "casadi>=3.6.3", + "xarray>=2022.6.0", + "anytree>=2.12.0", ] [project.urls] @@ -71,11 +72,11 @@ examples = [ ] # Plotting functionality plot = [ - "imageio>=2.9.0", + "imageio>=2.32.0", # Note: matplotlib is loaded for debug plots, but to ensure PyBaMM runs # on systems without an attached display, it should never be imported # outside of plot() methods. - "matplotlib>=2.0", + "matplotlib>=3.6.0", ] # For the Citations class cite = [ @@ -83,7 +84,7 @@ cite = [ ] # To generate LaTeX strings latexify = [ - "sympy>=1.8", + "sympy>=1.12", ] # Battery Parameter eXchange format bpx = [ @@ -108,7 +109,7 @@ dev = [ ] # Reading CSV files pandas = [ - "pandas>=0.24", + "pandas>=1.5.0", ] # For the Jax solver. Note: these must be kept in sync with the versions defined in pybamm/util.py. jax = [ @@ -121,17 +122,9 @@ odes = [ ] # Contains all optional dependencies, except for odes, jax, and dev dependencies all = [ - "anytree>=2.4.3", - "autograd>=1.2", - "pandas>=0.24", - "scikit-fem>=0.2.0", - "imageio>=2.9.0", - "matplotlib>=2.0", - "pybtex>=0.24.0", - "sympy>=1.8", - "bpx", - "tqdm", - "jupyter", + "autograd>=1.6.2", + "scikit-fem>=8.1.0", + "pybamm[examples,plot,cite,latexify,bpx,tqdm,pandas]", ] [project.scripts] From cfc550b14d46621e01999a6209fc76200648921e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:38:47 +0530 Subject: [PATCH 92/95] A sentence about package data and extra files --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6944cce074..b9800dcd61 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -413,16 +413,17 @@ wherever code is called that uses that citation (for example, in functions or in ### Installation -Installation of PyBaMM and its dependencies is handled via [pip](https://pip.pypa.io/en/stable/) and [setuptools](http://setuptools.readthedocs.io/). It uses `CMake` to compile C++ extensions using [`pybind11`](https://pybind11.readthedocs.io/en/stable/) and [`casadi`](https://web.casadi.org/) (non-Windows). The installation process is described in detail in the [source installation](https://docs.pybamm.org/en/latest/source/user_guide/installation/install-from-source.html) page and is configured through the `CMakeLists.txt` file. +Installation of PyBaMM and its dependencies is handled via [pip](https://pip.pypa.io/en/stable/) and [setuptools](http://setuptools.readthedocs.io/). It uses `CMake` to compile C++ extensions using [`pybind11`](https://pybind11.readthedocs.io/en/stable/) and [`casadi`](https://web.casadi.org/). The installation process is described in detail in the [source installation](https://docs.pybamm.org/en/latest/source/user_guide/installation/install-from-source.html) page and is configured through the `CMakeLists.txt` file. Configuration files: ``` setup.py pyproject.toml +MANIFEST.in ``` -Note that this file must be kept in sync with the version number in [`pybamm/__init__.py`](https://github.com/pybamm-team/PyBaMM/blob/develop/pybamm/__init__.py). +Note: `MANIFEST.in` is used to include and exclude non-Python files and auxiliary package data for PyBaMM when distributing it. If a file is not included in `MANIFEST.in`, it will not be included in the source distribution (SDist) and subsequently not be included in the binary distribution (wheel). ### Continuous Integration using GitHub Actions From 0aa469b6f94cc69d57d9e47fd78187edf714233d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 21 Nov 2023 02:00:52 +0530 Subject: [PATCH 93/95] Install `nox` with `pip` instead of `pipx` --- .github/workflows/run_periodic_tests.yml | 5 ++++- .github/workflows/test_on_push.yml | 26 ++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index f182ffaf99..4545dc26df 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -72,9 +72,12 @@ jobs: if: matrix.os == 'windows-latest' run: choco install graphviz --version=2.38.0.20190211 + - name: Install nox + run: python -m pip install nox + - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' - run: pipx run nox -s pybamm-requires + run: python -m nox -s pybamm-requires - name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10, and for macOS and Windows with all Python versions if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11) || (matrix.os != 'ubuntu-latest') diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index a0e3ffe4b2..2f7f94c9bc 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -90,6 +90,9 @@ jobs: python-version: ${{ matrix.python-version }} cache: 'pip' + - name: Install nox + run: python -m pip install nox + - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 if: matrix.os != 'windows-latest' @@ -106,7 +109,7 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' - run: pipx run nox -s pybamm-requires + run: python -m nox -s pybamm-requires - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: python -m nox -s unit @@ -144,6 +147,9 @@ jobs: python-version: 3.11 cache: 'pip' + - name: Install nox + run: python -m pip install nox + - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 with: @@ -222,6 +228,9 @@ jobs: python-version: ${{ matrix.python-version }} cache: 'pip' + - name: Install nox + run: python -m pip install nox + - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 if: matrix.os != 'windows-latest' @@ -238,7 +247,7 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS if: matrix.os != 'windows-latest' - run: pipx run nox -s pybamm-requires + run: python -m nox -s pybamm-requires - name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: python -m nox -s integration @@ -277,6 +286,9 @@ jobs: python-version: 3.11 cache: 'pip' + - name: Install nox + run: python -m pip install nox + - name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11 run: python -m nox -s doctests @@ -316,6 +328,9 @@ jobs: python-version: 3.11 cache: 'pip' + - name: Install nox + run: python -m pip install nox + - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 with: @@ -333,7 +348,7 @@ jobs: run: python -m nox -s pybamm-requires - name: Run example notebooks tests for GNU/Linux with Python 3.11 - run: pipx run nox -s examples + run: python -m nox -s examples # Runs only on Ubuntu with Python 3.11 run_scripts_tests: @@ -368,6 +383,9 @@ jobs: python-version: 3.11 cache: 'pip' + - name: Install nox + run: python -m pip install nox + - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 with: @@ -385,4 +403,4 @@ jobs: run: python -m nox -s pybamm-requires - name: Run example scripts tests for GNU/Linux with Python 3.11 - run: pipx run nox -s scripts + run: python -m nox -s scripts From 8e91218d3a7ac3f59267dfcda602efd06c8b3d2c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 21 Nov 2023 02:16:45 +0530 Subject: [PATCH 94/95] Remove `brew update` from wheels and disable wheels on PRs --- .github/workflows/publish_pypi.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index fda75d4489..3073c95f09 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -2,7 +2,6 @@ name: Build and publish package to PyPI on: release: types: [published] - pull_request: schedule: # Run at 10 am UTC on day-of-month 1 and 15. - cron: "0 10 1,15 * *" @@ -84,7 +83,6 @@ jobs: - name: Install SuiteSparse and SUNDIALS on macOS if: matrix.os == 'macos-latest' run: | - brew update brew install graphviz openblas libomp brew reinstall gcc python -m pip install cmake wget From f1fd05f58b6f2e2918151429988cebb46059f5b0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 21 Nov 2023 04:34:29 +0530 Subject: [PATCH 95/95] Update version to 23.9 Co-authored-by: Eric G. Kratz --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 675a7de335..4569c7c6c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta" [project] name = "pybamm" -version = "23.9rc0" +version = "23.9" license = { file = "LICENSE.txt" } description = "Python Battery Mathematical Modelling" authors = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}]