Skip to content

Commit

Permalink
pybamm-team#3049 clean up some project configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Sep 4, 2023
1 parent 4a3a03c commit 7c64841
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 58 deletions.
49 changes: 14 additions & 35 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -56,14 +30,20 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
]

dependencies = [
"numpy>=1.16",
"scipy>=1.3",
"casadi>=3.6.0",
"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 = [
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -149,17 +129,13 @@ 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"
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"
Expand All @@ -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 = [
Expand All @@ -191,3 +167,6 @@ pybamm = [
"pybamm/CITATIONS.bib",
"pybamm/plotting/mplstyle",
]

[tool.setuptools.packages.find]
include = ["pybamm", "pybamm.*"]
30 changes: 7 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7c64841

Please sign in to comment.