From cba85766967ecc84c4a14d44ea9a69c38d82620a Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Sat, 11 Jan 2025 20:07:07 +0530 Subject: [PATCH 01/10] build: switch to hatchling backend with hatch-vcs - Replace setuptools with hatchling as build backend - Add hatch-vcs for Git tag-based versioning - Unify package versioning under a single source --- pyproject.toml | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a416544551..c4db497ce1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,11 @@ [build-system] requires = [ - "setuptools", + "hatchling>=1.13.0", + "hatch-vcs>=0.3.0", + "casadi>=3.6.7; platform_system!='Windows'", + "cmake; platform_system!='Windows'", ] -build-backend = "setuptools.build_meta" +build-backend = "hatchling.build" [project] name = "pybamm" @@ -86,7 +89,7 @@ cite = [ ] # Battery Parameter eXchange format bpx = [ - "bpx>=0.5.0,<0.6.0", + "bpx>=0.4.0", ] # Low-overhead progress bars tqdm = [ @@ -120,6 +123,10 @@ jax = [ "jax==0.4.27", "jaxlib==0.4.27", ] +# For MLIR expression evaluation (IDAKLU Solver) +iree = [ + "iree-compiler==20240507.886", +] # Contains all optional dependencies, except for jax, iree, and dev dependencies all = [ "scikit-fem>=8.1.0", @@ -146,6 +153,21 @@ ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" MSMR_Example = "pybamm.input.parameters.lithium_ion.MSMR_example_set:get_parameter_values" Chayambuka2022 = "pybamm.input.parameters.sodium_ion.Chayambuka2022:get_parameter_values" +[tool.hatch.version] +source = "vcs" +raw-options = { local_scheme = "no-local-version", version_scheme = "python-simplified-semver" } + +[tool.hatch.build] +packages = ["src/pybamm"] +include = [ + "src/pybamm/**/*.txt", + "src/pybamm/**/*.md", + "src/pybamm/**/*.csv", + "src/pybamm/**/*.py", + "src/pybamm/CITATIONS.bib", + "src/pybamm/plotting/mplstyle", +] + [tool.setuptools] include-package-data = true @@ -259,6 +281,11 @@ log_date_format = "%Y-%m-%d %H:%M:%S" source = ["src/pybamm"] concurrency = ["multiprocessing"] +[tool.repo-review] +ignore = [ + "PP003" +] + [tool.mypy] ignore_missing_imports = true allow_redefinition = true From a92c4c7580470382add6fe0791f004e0f1a121fc Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Tue, 14 Jan 2025 01:59:52 +0530 Subject: [PATCH 02/10] switch to hatchling without VCS integration - Replace setuptools with hatchling as build backend - Remove setuptools configurations - Revert to version 24.11.2 --- pyproject.toml | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c4db497ce1..642357420c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,6 @@ [build-system] requires = [ "hatchling>=1.13.0", - "hatch-vcs>=0.3.0", - "casadi>=3.6.7; platform_system!='Windows'", - "cmake; platform_system!='Windows'", ] build-backend = "hatchling.build" @@ -84,12 +81,11 @@ plot = [ "matplotlib>=3.6.0", ] cite = [ - "setuptools", # Fix for a pybtex issue "pybtex>=0.24.0", ] # Battery Parameter eXchange format bpx = [ - "bpx>=0.4.0", + "bpx>=0.5.0,<0.6.0", ] # Low-overhead progress bars tqdm = [ @@ -123,10 +119,7 @@ jax = [ "jax==0.4.27", "jaxlib==0.4.27", ] -# For MLIR expression evaluation (IDAKLU Solver) -iree = [ - "iree-compiler==20240507.886", -] + # Contains all optional dependencies, except for jax, iree, and dev dependencies all = [ "scikit-fem>=8.1.0", @@ -153,10 +146,6 @@ ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" MSMR_Example = "pybamm.input.parameters.lithium_ion.MSMR_example_set:get_parameter_values" Chayambuka2022 = "pybamm.input.parameters.sodium_ion.Chayambuka2022:get_parameter_values" -[tool.hatch.version] -source = "vcs" -raw-options = { local_scheme = "no-local-version", version_scheme = "python-simplified-semver" } - [tool.hatch.build] packages = ["src/pybamm"] include = [ @@ -168,25 +157,11 @@ include = [ "src/pybamm/plotting/mplstyle", ] -[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. # These are specified to be included in the SDist through MANIFEST.in. -[tool.setuptools.package-data] -pybamm = [ - "*.txt", - "*.md", - "*.csv", - "*.py", - "src/pybamm/CITATIONS.bib", - "src/pybamm/plotting/mplstyle", -] -[tool.setuptools.packages.find] -where = ["src"] [tool.ruff] extend-include = ["*.ipynb"] extend-exclude = ["__init__.py"] @@ -282,9 +257,6 @@ source = ["src/pybamm"] concurrency = ["multiprocessing"] [tool.repo-review] -ignore = [ - "PP003" -] [tool.mypy] ignore_missing_imports = true From 98a8e8686ad4671230d9a8e3af91937da163987b Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Tue, 14 Jan 2025 13:24:58 +0530 Subject: [PATCH 03/10] switch to hatch with automatic file handling - Replace setuptools with hatch as build backend - Remove setuptools configurations - Add automatic file handling in hatch config --- noxfile.py | 5 ----- pyproject.toml | 21 +++++---------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/noxfile.py b/noxfile.py index 5c1b263f97..8af1e2f346 100644 --- a/noxfile.py +++ b/noxfile.py @@ -37,7 +37,6 @@ def set_environment_variables(env_dict, session): def run_coverage(session): """Run the coverage tests and generate an XML report.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("setuptools", silent=False) session.install("coverage", silent=False) # Using plugin here since coverage runs unit tests on linux with latest python version. if "CI" in os.environ: @@ -50,7 +49,6 @@ def run_coverage(session): def run_integration(session): """Run the integration tests.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("setuptools", silent=False) if ( "CI" in os.environ and sys.version_info[:2] == (3, 12) @@ -80,7 +78,6 @@ def run_doctests(session): def run_unit(session): """Run the unit tests.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("setuptools", silent=False) session.install("-e", ".[all,dev,jax]", silent=False) session.run("python", "-m", "pytest", "-m", "unit") @@ -89,7 +86,6 @@ def run_unit(session): def run_examples(session): """Run the examples tests for Jupyter notebooks.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("setuptools", silent=False) session.install("-e", ".[all,dev,jax]", silent=False) notebooks_to_test = session.posargs if session.posargs else [] session.run( @@ -134,7 +130,6 @@ 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("setuptools", silent=False) session.install("-e", ".[all,dev,jax]", silent=False) session.run( "python", diff --git a/pyproject.toml b/pyproject.toml index 642357420c..b4fbf11022 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,6 +81,7 @@ plot = [ "matplotlib>=3.6.0", ] cite = [ + "setuptools", # Fix for a pybtex issue "pybtex>=0.24.0", ] # Battery Parameter eXchange format @@ -146,22 +147,12 @@ ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" MSMR_Example = "pybamm.input.parameters.lithium_ion.MSMR_example_set:get_parameter_values" Chayambuka2022 = "pybamm.input.parameters.sodium_ion.Chayambuka2022:get_parameter_values" -[tool.hatch.build] -packages = ["src/pybamm"] -include = [ - "src/pybamm/**/*.txt", - "src/pybamm/**/*.md", - "src/pybamm/**/*.csv", - "src/pybamm/**/*.py", - "src/pybamm/CITATIONS.bib", - "src/pybamm/plotting/mplstyle", +[tool.hatch] +build.targets.sdist.include = [ + "src/pybamm", + "CITATION.cff", ] -# 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.ruff] extend-include = ["*.ipynb"] extend-exclude = ["__init__.py"] @@ -256,8 +247,6 @@ log_date_format = "%Y-%m-%d %H:%M:%S" source = ["src/pybamm"] concurrency = ["multiprocessing"] -[tool.repo-review] - [tool.mypy] ignore_missing_imports = true allow_redefinition = true From f3e80305b684dbade025560b14c523692a148670 Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Sat, 11 Jan 2025 20:07:07 +0530 Subject: [PATCH 04/10] build: switch to hatchling backend with hatch-vcs - Replace setuptools with hatchling as build backend - Add hatch-vcs for Git tag-based versioning - Unify package versioning under a single source --- pyproject.toml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b4fbf11022..08491fbb17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,7 +86,7 @@ cite = [ ] # Battery Parameter eXchange format bpx = [ - "bpx>=0.5.0,<0.6.0", + "bpx>=0.4.0", ] # Low-overhead progress bars tqdm = [ @@ -120,7 +120,6 @@ jax = [ "jax==0.4.27", "jaxlib==0.4.27", ] - # Contains all optional dependencies, except for jax, iree, and dev dependencies all = [ "scikit-fem>=8.1.0", @@ -247,6 +246,11 @@ log_date_format = "%Y-%m-%d %H:%M:%S" source = ["src/pybamm"] concurrency = ["multiprocessing"] +[tool.repo-review] +ignore = [ + "PP003" +] + [tool.mypy] ignore_missing_imports = true allow_redefinition = true From 385674f67eaad64eabcffcb4e0aef5a4253df1eb Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Tue, 14 Jan 2025 01:59:52 +0530 Subject: [PATCH 05/10] switch to hatchling without VCS integration - Replace setuptools with hatchling as build backend - Remove setuptools configurations - Revert to version 24.11.2 --- pyproject.toml | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 08491fbb17..9fad0de7a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,12 +81,11 @@ plot = [ "matplotlib>=3.6.0", ] cite = [ - "setuptools", # Fix for a pybtex issue "pybtex>=0.24.0", ] # Battery Parameter eXchange format bpx = [ - "bpx>=0.4.0", + "bpx>=0.5.0,<0.6.0", ] # Low-overhead progress bars tqdm = [ @@ -120,6 +119,10 @@ jax = [ "jax==0.4.27", "jaxlib==0.4.27", ] +# For MLIR expression evaluation (IDAKLU Solver) +iree = [ + "iree-compiler==20240507.886", +] # Contains all optional dependencies, except for jax, iree, and dev dependencies all = [ "scikit-fem>=8.1.0", @@ -146,12 +149,40 @@ ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" MSMR_Example = "pybamm.input.parameters.lithium_ion.MSMR_example_set:get_parameter_values" Chayambuka2022 = "pybamm.input.parameters.sodium_ion.Chayambuka2022:get_parameter_values" -[tool.hatch] -build.targets.sdist.include = [ - "src/pybamm", - "CITATION.cff", +[tool.hatch.version] +source = "vcs" +raw-options = { local_scheme = "no-local-version", version_scheme = "python-simplified-semver" } + +[tool.hatch.build] +packages = ["src/pybamm"] +include = [ + "src/pybamm/**/*.txt", + "src/pybamm/**/*.md", + "src/pybamm/**/*.csv", + "src/pybamm/**/*.py", + "src/pybamm/CITATIONS.bib", + "src/pybamm/plotting/mplstyle", ] +[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. +# These are specified to be included in the SDist through MANIFEST.in. +[tool.setuptools.package-data] +pybamm = [ + "*.txt", + "*.md", + "*.csv", + "*.py", + "src/pybamm/CITATIONS.bib", + "src/pybamm/plotting/mplstyle", +] + +[tool.setuptools.packages.find] +where = ["src"] [tool.ruff] extend-include = ["*.ipynb"] extend-exclude = ["__init__.py"] @@ -247,9 +278,6 @@ source = ["src/pybamm"] concurrency = ["multiprocessing"] [tool.repo-review] -ignore = [ - "PP003" -] [tool.mypy] ignore_missing_imports = true From b3a5de50790fc117e3490eebbb40b280ffc4f3ff Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Tue, 14 Jan 2025 13:24:58 +0530 Subject: [PATCH 06/10] switch to hatch with automatic file handling - Replace setuptools with hatch as build backend - Remove setuptools configurations - Add automatic file handling in hatch config --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9fad0de7a7..fb47d14cec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,6 +81,7 @@ plot = [ "matplotlib>=3.6.0", ] cite = [ + "setuptools", # Fix for a pybtex issue "pybtex>=0.24.0", ] # Battery Parameter eXchange format @@ -277,8 +278,6 @@ log_date_format = "%Y-%m-%d %H:%M:%S" source = ["src/pybamm"] concurrency = ["multiprocessing"] -[tool.repo-review] - [tool.mypy] ignore_missing_imports = true allow_redefinition = true From 8adc0ead434f08a166f417e1baf6f007b08654c9 Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Wed, 22 Jan 2025 18:50:19 +0530 Subject: [PATCH 07/10] revert changes to the original state --- pyproject.toml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7627d2c114..12ddc45f5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,10 +120,7 @@ jax = [ "jax==0.4.27", "jaxlib==0.4.27", ] -# For MLIR expression evaluation (IDAKLU Solver) -iree = [ - "iree-compiler==20240507.886", -] + # Contains all optional dependencies, except for jax, iree, and dev dependencies all = [ "scikit-fem>=8.1.0", @@ -150,10 +147,6 @@ ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" MSMR_Example = "pybamm.input.parameters.lithium_ion.MSMR_example_set:get_parameter_values" Chayambuka2022 = "pybamm.input.parameters.sodium_ion.Chayambuka2022:get_parameter_values" -[tool.hatch.version] -source = "vcs" -raw-options = { local_scheme = "no-local-version", version_scheme = "python-simplified-semver" } - [tool.hatch.build] packages = ["src/pybamm"] include = [ From 3e1ca8146538e82a68c81da2012da33fbd2992e8 Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Thu, 23 Jan 2025 00:49:14 +0530 Subject: [PATCH 08/10] revert to original state before conflicts --- pyproject.toml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 12ddc45f5f..82a0884e4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,20 +147,12 @@ ECM_Example = "pybamm.input.parameters.ecm.example_set:get_parameter_values" MSMR_Example = "pybamm.input.parameters.lithium_ion.MSMR_example_set:get_parameter_values" Chayambuka2022 = "pybamm.input.parameters.sodium_ion.Chayambuka2022:get_parameter_values" -[tool.hatch.build] -packages = ["src/pybamm"] -include = [ - "src/pybamm/**/*.txt", - "src/pybamm/**/*.md", - "src/pybamm/**/*.csv", - "src/pybamm/**/*.py", - "src/pybamm/CITATIONS.bib", - "src/pybamm/plotting/mplstyle", +[tool.hatch] +build.targets.sdist.include = [ + "src/pybamm", + "CITATION.cff", ] -[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. From adc7e0c3670ad2bf9571ff4f02d8472dda874ed3 Mon Sep 17 00:00:00 2001 From: "Eric G. Kratz" Date: Wed, 22 Jan 2025 15:22:51 -0500 Subject: [PATCH 09/10] Update pyproject.toml --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 82a0884e4f..358e0cb6b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,7 +120,6 @@ jax = [ "jax==0.4.27", "jaxlib==0.4.27", ] - # Contains all optional dependencies, except for jax, iree, and dev dependencies all = [ "scikit-fem>=8.1.0", From 0b8db17b8442db54fc8e6207d70b519535b77872 Mon Sep 17 00:00:00 2001 From: Vidip Singh <112854574+vidipsingh@users.noreply.github.com> Date: Thu, 23 Jan 2025 20:52:44 +0530 Subject: [PATCH 10/10] remove setuptools references and MANIFEST.in --- MANIFEST.in | 7 ------- pyproject.toml | 16 ---------------- 2 files changed, 23 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index c1a77ac2f4..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -graft src -include CITATION.cff -prune tests - -exclude CHANGELOG.md CODE-OF-CONDUCT.md CONTRIBUTING.md all_contributors.md - -global-exclude __pycache__ *.py[cod] .venv diff --git a/pyproject.toml b/pyproject.toml index 358e0cb6b9..b34fcf9aeb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -152,22 +152,6 @@ build.targets.sdist.include = [ "CITATION.cff", ] -# 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", - "*.md", - "*.csv", - "*.py", - "src/pybamm/CITATIONS.bib", - "src/pybamm/plotting/mplstyle", -] - -[tool.setuptools.packages.find] -where = ["src"] [tool.ruff] extend-include = ["*.ipynb"] extend-exclude = ["__init__.py"]