From e8a11bae63ac8594ac412aa2563f536e68baa59a Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Mon, 25 Nov 2024 18:07:00 +0000 Subject: [PATCH] Change poetry to uv --- .github/workflows/ci.yml | 121 ++++++++++++++--------------- .github/workflows/docs.yml | 27 +++---- pyproject.toml | 155 ++++++++++++++++++++----------------- 3 files changed, 156 insertions(+), 147 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 504efd32..bfa6befa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,34 +12,37 @@ jobs: python-version: ['3.9','3.10','3.11','3.12'] steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install poetry - run: pipx install poetry - - - name: Install python dependencies - run: | - poetry env use ${{ matrix.python-version }} - poetry install --with dev --extras all - - - name: Run test suite - env: - # show timings of tests - PYTEST_ADDOPTS: "--durations=0" - run: poetry run pytest --run-extra-mlips --cov janus_core --cov-append . - - - name: Report coverage to Coveralls - uses: coverallsapp/github-action@v2 - with: - parallel: true - flag-name: run-${{ matrix.python-version }} - file: coverage.xml - base-path: janus_core + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + version: "0.5.4" + + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} + + - name: Install dependencies + run: uv sync --all-extras + + - name: Run test suite + env: + # show timings of tests + PYTEST_ADDOPTS: "--durations=0" + run: uv run pytest --run-extra-mlips --cov janus_core --cov-append . + + - name: Report coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + parallel: true + flag-name: run-${{ matrix.python-version }} + file: coverage.xml + base-path: janus_core coverage: needs: tests @@ -54,50 +57,46 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Check all sources documented - run: | - diff -y --suppress-common-lines \ - <(git ls-files janus_core/** | sed '/.py$/!d; s/\/__init__.py//; s#/#.#g; s/.py$//' | sort) \ - <(sed -nr '/automodule/{s/.*::\s*//;p}' docs/source/apidoc/* | sort) + - name: Check all sources documented + run: | + diff -y --suppress-common-lines \ + <(git ls-files janus_core/** | sed '/.py$/!d; s/\/__init__.py//; s#/#.#g; s/.py$//' | sort) \ + <(sed -nr '/automodule/{s/.*::\s*//;p}' docs/source/apidoc/* | sort) - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + version: "0.5.4" - - name: Install poetry - run: pipx install poetry + - name: Set up Python 3.11 + run: uv python install 3.11 - - name: Install python dependencies - run: | - poetry env use 3.11 - poetry install --with docs + - name: Install dependencies + run: uv sync - - name: Build docs - run: cd docs && poetry run make + - name: Build docs + run: cd docs && uv run make html pre-commit: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + version: "0.5.4" - - name: Install poetry - run: pipx install poetry + - name: Set up Python 3.11 + run: uv python install 3.11 - - name: Install python dependencies - run: | - poetry env use 3.11 - poetry install --with pre-commit,docs,dev --extras "chgnet m3gnet" + - name: Install dependencies + run: uv sync - - name: Run pre-commit - run: | - poetry run pre-commit install - poetry run pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) + - name: Run pre-commit + run: | + uv run pre-commit install + uv run pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7039eda9..acf9cadf 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -27,23 +27,16 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install poetry - run: | - apt update - apt upgrade -y - apt install -y pipx - pipx install poetry - - - name: add deps - run: | - apt install -y python3-dev build-essential - - - name: sphinx - run: | - export PATH="$HOME/.local/bin:$PATH" - poetry install --with docs - cd docs - poetry run make html + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + verson: "0.5.4" + + - name: Install dependencies + run: uv sync + + - name: Build docs + run: cd docs && uv run make html - name: upload uses: actions/upload-pages-artifact@v3 diff --git a/pyproject.toml b/pyproject.toml index bb3a729b..95eb2b05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,17 @@ -[tool.poetry] +[project] name = "janus-core" version = "0.6.6" description = "Tools for machine learnt interatomic potentials" authors = [ - "Elliott Kasoar", - "Federica Zanca", - "Harvey Devereux", - "Patrick Austin", - "David Mason", - "Jacob Wilkins", - "Alin M. Elena", + { name = "Elliott Kasoar" }, + { name = "Federica Zanca" }, + { name = "Harvey Devereux "}, + { name = "Patrick Austin" }, + { name = "David Mason" }, + { name = "Jacob Wilkins" }, + { name = "Alin M. Elena" }, ] -readme = "README.md" -packages = [{include = "janus_core"}] +requires-python = "<3.13,>=3.9" classifiers = [ "Programming Language :: Python", "Intended Audience :: Science/Research", @@ -20,71 +19,82 @@ classifiers = [ "Natural Language :: English", "Development Status :: 3 - Alpha", ] +readme = "README.md" + +dependencies = [ + "ase<4.0,>=3.23", + "codecarbon<3.0.0,>=2.5.0", + "mace-torch==0.3.8", + "numpy<2.0.0,>=1.26.4", + "phonopy<3.0.0,>=2.23.1", + "pyyaml<7.0.0,>=6.0.1", + "rich<14.0.0,>=13.9.1", + "seekpath<2.0.0,>=1.9.7", + "spglib<3.0.0,>=2.3.0", + "torch<=2.2,>=2.1", + "torch-dftd==0.4.0", + "typer<1.0.0,>=0.12.5", + "typer-config<2.0.0,>=1.4.0", +] + +[project.optional-dependencies] +alignn = [ + "alignn == 2024.5.27",] + +chgnet = [ + "chgnet == 0.3.8",] + +m3gnet = [ + "matgl == 1.1.3", + "dgl == 2.1.0", + "torchdata == 0.7.1",] + +sevennet = [ + "sevenn == 0.10.0", + "torch-geometric == 2.6.1",] + +all = [ + "janus-core[alignn]", + "janus-core[chgnet]", + "janus-core[m3gnet]", + "janus-core[sevennet]", +] + +[project.scripts] +janus = "janus_core.cli.janus:app" + +[project.urls] repository = "https://github.com/stfc/janus-core/" documentation = "https://stfc.github.io/janus-core/" -[tool.poetry.scripts] -janus = "janus_core.cli.janus:app" +[dependency-groups] +dev = [ + "coverage[toml]<8.0.0,>=7.4.1", + "pgtest<2.0.0,>=1.3.2", + "pytest<9.0,>=8.0", + "pytest-cov<5.0.0,>=4.1.0", + "tox<5.0.0,>=4.12.1", + "wheel<1.0,>=0.42", +] -[tool.poetry.dependencies] -ase = "^3.23" -codecarbon = "^2.5.0" -mace-torch = "0.3.8" -numpy = "^1.26.4" -phonopy = "^2.23.1" -python = "^3.9" -pyyaml = "^6.0.1" -rich = "^13.9.1" -seekpath = "^1.9.7" -spglib = "^2.3.0" -torch = ">= 2.1, <= 2.2" # Range required for dgl -torch-dftd = "0.4.0" -typer = "^0.12.5" -typer-config = "^1.4.0" - -alignn = { version = "2024.5.27", optional = true } -chgnet = {version = "0.3.8", optional = true} -dgl = { version = "2.1.0", optional = true } # Pin due to matgl installation issues -matgl = { version = "1.1.3", optional = true} -sevenn = { version = "0.10.0", optional = true } -torchdata = {version = "0.7.1", optional = true} # Pin due to dgl issue -torch_geometric = { version = "^2.5.3", optional = true } - -[tool.poetry.extras] -all = ["alignn", "chgnet", "matgl", "dgl", "torchdata", "sevenn", "torch_geometric"] -alignn = ["alignn"] -chgnet = ["chgnet"] -m3gnet = ["matgl", "dgl", "torchdata"] -sevennet = ["sevenn", "torch_geometric"] - -[tool.poetry.group.dev.dependencies] -coverage = {extras = ["toml"], version = "^7.4.1"} -pgtest = "^1.3.2" -pytest = "^8.0" -pytest-cov = "^4.1.0" -tox = "^4.12.1" -wheel = "^0.42" - -[tool.poetry.group.pre-commit] -optional = true -[tool.poetry.group.pre-commit.dependencies] -pre-commit = "^3.6.0" -ruff = "^0.7.4" - -[tool.poetry.group.docs] -optional = true -[tool.poetry.group.docs.dependencies] -furo = "^2024.1.29" -markupsafe = "<2.1" -numpydoc = "^1.6.0" -sphinx = "^7.2.6" -sphinxcontrib-contentui = "^0.2.5" -sphinxcontrib-details-directive = "^0.1" -sphinx-copybutton = "^0.5.2" +docs = [ + "furo<2025.0.0,>=2024.1.29", + "markupsafe<2.1", + "numpydoc<2.0.0,>=1.6.0", + "sphinx<8.0.0,>=7.2.6", + "sphinxcontrib-contentui<1.0.0,>=0.2.5", + "sphinxcontrib-details-directive<1.0,>=0.1", + "sphinx-copybutton<1.0.0,>=0.5.2", +] + +pre-commit = [ + "pre-commit<4.0.0,>=3.6.0", + "ruff<1.0.0,>=0.7.4", +] [build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" [tool.pytest.ini_options] # Configuration for [pytest](https://docs.pytest.org) @@ -149,3 +159,10 @@ exclude = [ ".__weakref__$", ".__repr__$", ] + +[tool.uv] +default-groups = [ + "dev", + "docs", + "pre-commit", +]