From 90ff0432e67f16a8704a324fc469011d6ad7d3c7 Mon Sep 17 00:00:00 2001 From: james <81617086+je-cook@users.noreply.github.com> Date: Fri, 14 Nov 2025 08:59:31 +0000 Subject: [PATCH 1/5] move to modern build system --- .gitignore | 1 + pyproject.toml | 220 +++++++++++++++++++++++++++++++++++++++++++ requirements_dev.txt | 15 --- ruff.toml | 78 --------------- setup.py | 53 ----------- 5 files changed, 221 insertions(+), 146 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements_dev.txt delete mode 100644 ruff.toml delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 51e6de487d..fcb3136114 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ env-fork !tests/integration/data/large_tokamak_SIG_TF.json *.html !documentation/**/*.html +process/_version.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..1565bf3fb8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,220 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "vcs" +fallback-version = "0.0.0" + +[tool.hatch.build.hooks.vcs] +version-file = "process/_version.py" + +[tool.hatch.metadata] +allow-direct-references = true # remove after reference published + +[project] +name = "process" +authors = [{ name = "UKAEA" }] +description = "Power Reactor Optimisation Code for Environmental and Safety Studies" +readme = "README.md" +requires-python = ">=3.10" +license = "MIT" +dynamic = ["version"] +dependencies = [ + "numpy>=1.23", + "scipy>=1.10", + "cvxpy~=1.7.3", + "osqp>=1.0", + "pandas>=2.0", + "numba>=0.57", + "PyVMCON>=2.4.0,<2.5.0", + "CoolProp>=6.4", + "matplotlib>=2.1.1", + "seaborn>=0.12.2", + "tabulate", + ] +keywords = [] # TODO +classifiers = [ + "Programming Language :: Python", + "Development Status :: 4 - Beta", + "Natural Language :: English", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Scientific/Engineering :: Physics", +] + +[project.urls] +Homepage = "https://www.ukaea.org/service/process/" +Source = "https://github.com/ukaea/process" +Documentation = "https://ukaea.github.io/PROCESS" +Issues = "https://github.com/ukaea/process/issues" + +[project.optional-dependencies] +test = [ + "pytest>=5.4.1", + "requests>=2.30", + "testbook>=0.4", + "pytest-cov>=3.0.0", + "pytest-xdist>=2.5.0" +] +examples = ["pillow>=5.1.0", "jupyter==1.0.0", "pdf2image==1.16.0"] +plotly = ["plotly>=5.15.0,<6"] +docs = [ + "mkdocs>=1.1", + "mkdocs-material>=4.6.3", + "mkdocs-git-revision-date-localized-plugin >= 1.2", + "mkdocs-glightbox >= 0.3.4", + "pymdown-extensions>=6.3", + "bokeh>=3.4.0,<4", + "mkdocstrings==0.18.0", + "Jinja2>=3.0", + "mkdocs-jupyter>=0.24", +] +lint = ["pre-commit>=2.16.0", "ruff==0.9.3", "ty"] +all = ["process[test,docs,lint,examples,plotly]"] + +[tool.hatch.build.targets.wheel] +artifacts = [ + "process/data/lz_non_corona_14_elements/*.dat", + "process/io/*.png" +] + +[tool.hatch.envs.default] +features = ["dev", "test", "docs", "lint"] + +[tool.hatch.envs.test] +features = ["test"] +[[tool.hatch.envs.test.matrix]] +python = ["3.10", "3.11", "3.12", "3.13"] +[tool.hatch.envs.test.scripts] +tests = "pytest {args:tests}" +tests-cov = "pytest --cov process --cov-report html:htmlcov --cov-report xml {args:tests}" +tests-cov-private = "pytest --private --cov process --cov-report html:htmlcov --cov-report xml {args:tests}" + +[tool.hatch.envs.docs] +features = ["docs"] +[tool.hatch.envs.docs.scripts] +build = "mkdocs build" +serve = "mkdocs serve" +deploy = "mkdocs gh-deploy" + +[tool.hatch.envs.lint] +detached = true # Don't inherit from default (does not download project dependencies) +dependencies = ["pre-commit", "ruff", "ty"] + +[tool.hatch.envs.lint.scripts] +fmt = ["pre-commit run --all-files --hook-stage manual"] + +[tool.coverage.report] +exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] +"omit" = ["process/_version.py"] + +[tool.pytest.ini_options] +addopts = "--strict-markers -r fEX" + +[tool.ty.terminal] +output-format = "concise" + +[tool.ruff] +target-version = "py310" +line-length = 89 +output-format = "concise" +extend-exclude = ["env", ".env"] + +[tool.ruff.format] +preview = true + +[tool.ruff.lint.per-file-ignores] +# Tests can use magic values, assertions, and relative imports +"tests/**" = ["ARG"] + +[tool.ruff.lint.isort] +known-first-party = ["process"] + +[tool.ruff.lint.flake8-tidy-imports] +ban-relative-imports = "all" + +[tool.ruff.lint.pydocstyle] +convention = "numpy" + +[tool.ruff.lint.flake8-copyright] +notice-rgx = "(?i)# SPDX-FileCopyrightText:\\s\\d{4}(-(\\d{4}|present))*" + +[tool.ruff.lint.mccabe] +max-complexity = 12 + +[tool.ruff.lint.pylint] +# These should be made stricter +max-args = 17 +max-locals = 17 + +[tool.ruff.lint] +preview = true +extend-select = [ + "A", + "ARG", + "ASYNC", + "B", + "BLE", + "C4", + "COM", + "DTZ", + "EXE", + "F", + "FA", + "FLY", + "FURB", + "G", + "I", + "ICN", + "INT", + "ISC", + "LOG", + "N", + "NPY", + "PD", + "PERF", + "PGH", + "PIE", + "PYI", + "Q", + "RET", + "RSE", + "RUF", + "SIM", + "SLF", + "SLOT", + "T10", + "TID", + "UP", + "W", + "YTT", +] +ignore = ["COM812", "FBT", "G004", "PD901"] + +[tool.ruff.lint.pep8-naming] +ignore-names = [ + "*PROCESS*", + "*Bt*", + "*Bp*", + "*keV*", + "*MPa*", + "*H*", + "*T*", + "*D*", + "*He*", + "*Be*", + "C", + "N", + "O", + "Ne", + "Si", + "Ar", + "Fe", + "Ni", + "Kr", + "Xe", + "W", +] diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index 4864998084..0000000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,15 +0,0 @@ -# requirements_dev.txt includes the dependencies for running scripts on the CI -# e.g. documentation building and quality assurance (pre-commit). - -pre-commit>=2.16.0 -pytest-cov>=3.0.0 -pytest-xdist>=2.5.0 -mkdocs>=1.1 -mkdocs-material>=4.6.3 -mkdocs-git-revision-date-localized-plugin >= 1.2 -mkdocs-glightbox >= 0.3.4 -pymdown-extensions>=6.3 -bokeh>=3.4.0,<4 -mkdocstrings==0.18.0 -Jinja2>=3.0 -mkdocs-jupyter>=0.24 diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 9db7a11a87..0000000000 --- a/ruff.toml +++ /dev/null @@ -1,78 +0,0 @@ -extend-exclude = ["env", ".env"] -target-version = "py310" - -[lint] -extend-select = [ - "A", - "ARG", - "ASYNC", - "B", - "BLE", - "C4", - "COM", - "DTZ", - "EXE", - "F", - "FA", - "FLY", - "FURB", - "G", - "I", - "ICN", - "INT", - "ISC", - "LOG", - "N", - "NPY", - "PD", - "PERF", - "PGH", - "PIE", - "PYI", - "Q", - "RET", - "RSE", - "RUF", - "SIM", - "SLF", - "SLOT", - "T10", - "TID", - "UP", - "W", - "YTT", -] - -ignore = ["COM812", "FBT", "G004", "PD901"] - -[lint.per-file-ignores] -"tests/*" = ["ARG"] - -[lint.pep8-naming] -ignore-names = [ - "*PROCESS*", - "*Bt*", - "*Bp*", - "*keV*", - "*MPa*", - "*H*", - "*T*", - "*D*", - "*He*", - "*Be*", - "C", - "N", - "O", - "Ne", - "Si", - "Ar", - "Fe", - "Ni", - "Kr", - "Xe", - "W", -] - - -[format] -preview = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 0b055beb71..0000000000 --- a/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -import os -import platform -import site - -from setuptools import find_packages, setup - -MODULE_NAME = "process" -_install_loc = os.path.join(site.getsitepackages()[0], MODULE_NAME) -EXTRA_ARGS = [] -if platform.system() == "Darwin": - EXTRA_ARGS = ["-Wl,-rpath," + os.path.join(_install_loc, "lib")] - -setup_kwargs = { - "name": MODULE_NAME, - "version": "3.2.1", - "description": ( - "Power Reactor Optimisation Code for Environmental and Safety Studies" - ), - "url": "https://ccfe.ukaea.uk/resources/process/", - "author": "UKAEA", - "packages": find_packages(), - "package_dir": {"process": "process"}, - "package_data": { - "process": ["data/lz_non_corona_14_elements/*"], - "process.data.impuritydata": ["*"], - "process.io": ["*.png"], - }, - "test_suite": "pytest", - "python_requires": ">=3.10", - "install_requires": [ - "numpy>=1.23", - "scipy>=1.10", - "cvxpy~=1.7.3", - "osqp>=1.0", - "pandas>=2.0", - "numba>=0.57", - "PyVMCON>=2.4.0,<2.5.0", - "CoolProp>=6.4", - "matplotlib>=2.1.1", - "seaborn>=0.12.2", - "tabulate", - ], - "extras_require": { - "test": ["pytest>=5.4.1", "requests>=2.30", "testbook>=0.4"], - "examples": ["jupyter==1.0.0"], - "plotly": ["plotly>=5.15.0,<6"], - }, - "entry_points": {"console_scripts": ["process=process.main:main"]}, - "extra_link_args": EXTRA_ARGS, -} - -if __name__ == "__main__": - setup(**setup_kwargs) From 754ca395e1c4a78b39c3363e8891de43090647e9 Mon Sep 17 00:00:00 2001 From: james <81617086+je-cook@users.noreply.github.com> Date: Fri, 14 Nov 2025 09:01:54 +0000 Subject: [PATCH 2/5] remove references to requirements.txt --- .github/workflows/process.yml | 26 ++++++++----------------- documentation/development/pre-commit.md | 2 +- documentation/development/testing.md | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.github/workflows/process.yml b/.github/workflows/process.yml index 97e8785560..77117a597c 100644 --- a/.github/workflows/process.yml +++ b/.github/workflows/process.yml @@ -21,8 +21,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[test, examples]' - pip install -r requirements_dev.txt + pip install -e '.[lint, test, examples]' - name: Run unit tests run: | pytest --cov=process tests/unit -v \ @@ -44,8 +43,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[test]' - pip install -r requirements_dev.txt + pip install -e '.[docs, test, lint]' - name: Install poppler run: | sudo apt update @@ -63,8 +61,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[test, examples]' - pip install -r requirements_dev.txt + pip install -e '.[docs, test, lint, examples]' - name: Install poppler run: | sudo apt update @@ -91,8 +88,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[test]' - pip install -r requirements_dev.txt + pip install -e '.[docs, test, lint]' - name: Allow git commands to be run run: git config --global --add safe.directory '*' - name: Run regression tests @@ -107,9 +103,7 @@ jobs: with: python-version: '3.10' - name: Install PROCESS - run: pip install -e . - - name: Install dev dependencies - run: pip install -r requirements_dev.txt + run: pip install -e '.[lint, docs, test]' - name: Run regression input files run: python tracking/run_tracking_inputs.py run tests/regression/input_files - name: Move other files @@ -133,7 +127,7 @@ jobs: with: python-version: '3.10' - name: Install dev dependencies - run: pip install -r requirements_dev.txt + run: pip install '.[lint]' - name: Run pre-commit run: pre-commit run --all-files @@ -152,9 +146,7 @@ jobs: with: python-version: '3.10' - name: Install PROCESS - run: pip install -e . - - name: Install dev dependencies - run: pip install -r requirements_dev.txt + run: pip install -e '.[test, docs, lint]' - name: Setup SSH identity uses: webfactory/ssh-agent@v0.7.0 with: @@ -205,9 +197,7 @@ jobs: with: python-version: '3.10' - name: Install PROCESS - run: pip install -e . - - name: Install dev dependencies - run: pip install -r requirements_dev.txt + run: pip install -e '.[test, lint, docs]' - run: python scripts/vardes.py - run: git config --global --add safe.directory '*' - name: Download STF_TF.json files diff --git a/documentation/development/pre-commit.md b/documentation/development/pre-commit.md index 9a5d78d3f0..bb677bc027 100755 --- a/documentation/development/pre-commit.md +++ b/documentation/development/pre-commit.md @@ -43,7 +43,7 @@ pre-commit -h If pre-commit is not installed, then it can be installed by running: ```bash -pip install -r requirements_dev.txt +pip install '.[lint]' ``` in your environment, which will install all development dependencies including pre-commit. diff --git a/documentation/development/testing.md b/documentation/development/testing.md index 056287eb93..9eb2a91f8e 100644 --- a/documentation/development/testing.md +++ b/documentation/development/testing.md @@ -98,7 +98,7 @@ For a guide on contributing code to PROCESS, see `CONTRIBUTING.md`. Running the entire test suite can be time consuming, as by default it runs on a single core. `pytest-xdist` allows `pytest` tests to be distributed across multiple cores to speed up testing. -`pytest-xdist` should be installed already (included in `requirements.txt`), but if not it can be installed manually with: +`pytest-xdist` should be installed already (included in `test` extras; `pip install ".[test]"`), but if not it can be installed manually with: ```bash pip install pytest-xdist From d7a4b45d5774cb5dcf022adc24cfe4672a48bb57 Mon Sep 17 00:00:00 2001 From: james <81617086+je-cook@users.noreply.github.com> Date: Fri, 14 Nov 2025 10:37:48 +0000 Subject: [PATCH 3/5] forgot entry point --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 1565bf3fb8..5e2a0544aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,9 @@ docs = [ lint = ["pre-commit>=2.16.0", "ruff==0.9.3", "ty"] all = ["process[test,docs,lint,examples,plotly]"] +[project.scripts] +process = "process.main:main" + [tool.hatch.build.targets.wheel] artifacts = [ "process/data/lz_non_corona_14_elements/*.dat", From 6b48d4cf219dea0924396c5ac44caf1c99a384cb Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Thu, 18 Dec 2025 11:17:28 +0000 Subject: [PATCH 4/5] change setup.py to pyproject.toml --- process/data_structure/__init__.py | 2 +- pyproject.toml | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/process/data_structure/__init__.py b/process/data_structure/__init__.py index 034764b200..b84550ac61 100644 --- a/process/data_structure/__init__.py +++ b/process/data_structure/__init__.py @@ -1,4 +1,4 @@ -from . import ( +from process.data_structure import ( blanket_library, build_variables, buildings_variables, diff --git a/pyproject.toml b/pyproject.toml index 5e2a0544aa..a492082fce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,9 +9,6 @@ fallback-version = "0.0.0" [tool.hatch.build.hooks.vcs] version-file = "process/_version.py" -[tool.hatch.metadata] -allow-direct-references = true # remove after reference published - [project] name = "process" authors = [{ name = "UKAEA" }] @@ -33,7 +30,7 @@ dependencies = [ "seaborn>=0.12.2", "tabulate", ] -keywords = [] # TODO +keywords = ['fusion', 'optimisation'] classifiers = [ "Programming Language :: Python", "Development Status :: 4 - Beta", @@ -59,7 +56,7 @@ test = [ "pytest-cov>=3.0.0", "pytest-xdist>=2.5.0" ] -examples = ["pillow>=5.1.0", "jupyter==1.0.0", "pdf2image==1.16.0"] +examples = ["jupyter==1.0.0"] plotly = ["plotly>=5.15.0,<6"] docs = [ "mkdocs>=1.1", @@ -122,7 +119,7 @@ output-format = "concise" [tool.ruff] target-version = "py310" -line-length = 89 +line-length = 88 output-format = "concise" extend-exclude = ["env", ".env"] @@ -154,7 +151,7 @@ max-args = 17 max-locals = 17 [tool.ruff.lint] -preview = true +preview = false extend-select = [ "A", "ARG", From 4bc6ca87faf9b386538dc40d5f54d3ece2f06c0e Mon Sep 17 00:00:00 2001 From: je-cook <81617086+je-cook@users.noreply.github.com> Date: Tue, 23 Dec 2025 08:55:19 +0000 Subject: [PATCH 5/5] Restrict dependency installation to required deps Co-authored-by: Timothy <75321887+timothy-nunn@users.noreply.github.com> --- .github/workflows/process.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/process.yml b/.github/workflows/process.yml index 77117a597c..f509069a83 100644 --- a/.github/workflows/process.yml +++ b/.github/workflows/process.yml @@ -21,7 +21,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[lint, test, examples]' + pip install -e '.[test]' - name: Run unit tests run: | pytest --cov=process tests/unit -v \ @@ -43,7 +43,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[docs, test, lint]' + pip install -e '.[test]' - name: Install poppler run: | sudo apt update @@ -61,7 +61,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[docs, test, lint, examples]' + pip install -e '.[test, examples]' - name: Install poppler run: | sudo apt update @@ -88,7 +88,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[docs, test, lint]' + pip install -e '.[test]' - name: Allow git commands to be run run: git config --global --add safe.directory '*' - name: Run regression tests