From 232f9d95ce17aeeb6bfddb884d62c65e41292c98 Mon Sep 17 00:00:00 2001 From: phi-friday Date: Fri, 28 Feb 2025 01:03:22 +0900 Subject: [PATCH] upgrade poetry2.0 & apply pep621 (#545) * chore: upgrade poetry2.0 & apply pep621 * fix: replace poetry action(not support 2.0) * fix: exclude one matrix * chore: split numpy deps * fix: numpy constraints * fix: install root * chore: use install-poetry --- .github/workflows/build_docs.yml | 2 ++ .github/workflows/format_and_lint.yml | 2 ++ .github/workflows/run_tests.yml | 19 ++++++++-- pyproject.toml | 52 ++++++++++++++++----------- 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 43e7d988..4227baf1 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -28,6 +28,8 @@ jobs: run: sudo apt-get install -y pandoc - name: Install Poetry uses: snok/install-poetry@v1 + with: + version: 'latest' - name: Install package and test dependencies run: | poetry install --with dev,nbtools diff --git a/.github/workflows/format_and_lint.yml b/.github/workflows/format_and_lint.yml index 7a870481..a7fffe02 100644 --- a/.github/workflows/format_and_lint.yml +++ b/.github/workflows/format_and_lint.yml @@ -19,6 +19,8 @@ jobs: python-version: "3.9" - name: Install Poetry uses: snok/install-poetry@v1 + with: + version: 'latest' - name: Install dependencies run: | poetry install --with dev diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 8501d8cd..1475feb7 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -19,6 +19,9 @@ jobs: matrix: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] numpy-version: [">=1.25,<2", ">=2"] + exclude: + - python-version: "3.13" + numpy-version: ">=1.25,<2" # numpy<2 is not supported on Python 3.13 steps: - uses: actions/checkout@v3 @@ -26,12 +29,24 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v5 + with: + version: "latest" - name: Install Poetry uses: snok/install-poetry@v1 + with: + version: 'latest' - name: Install test dependencies run: | - poetry add "numpy${{ matrix.numpy-version }}" - poetry install --with dev,nbtools + poetry self add poetry-plugin-export + poetry export -f requirements.txt --with dev,nbtools --without-hashes --output requirements-dev.txt + echo "numpy${{ matrix.numpy-version }}" >> constraints.txt + uv pip compile requirements-dev.txt --output-file requirements.txt \ + --python-version ${{ matrix.python-version }} \ + --override constraints.txt + poetry run pip install -r requirements.txt + poetry install --only-root - name: Test with pytest run: | poetry run pytest --cov-report xml --cov=bayes_opt/ diff --git a/pyproject.toml b/pyproject.toml index 884c3ac4..a1ff1d7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,24 +1,36 @@ -[tool.poetry] +[project] name = "bayesian-optimization" version = "3.0.0b1" description = "Bayesian Optimization package" -authors = ["Fernando Nogueira"] -license = "MIT" +authors = [{ name = "Fernando Nogueira", email = "fmfnogueira@gmail.com" }] +license = { file = "LICENSE" } readme = "README.md" -packages = [{include = "bayes_opt"}] - -[tool.poetry.dependencies] -python = "^3.9" -scikit-learn = "^1.0.0" -numpy = ">=1.25" -scipy = [ - {version = "^1.0.0", python = "<3.13"}, - {version = "^1.14.1", python = ">=3.13"} +requires-python = ">=3.9,<4.0" +classifiers = [ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +dependencies = [ + "scikit-learn>=1.0.0,<2.0.0", + "numpy>=1.25; python_version<'3.13'", + "numpy>=2.1.3; python_version>='3.13'", + "scipy>=1.0.0,<2.0.0; python_version<'3.13'", + "scipy>=1.14.1,<2.0.0; python_version>='3.13'", + "colorama>=0.4.6,<1.0.0", ] -colorama = "^0.4.6" + +[tool.poetry] +requires-poetry = ">=2.0" +packages = [{ include = "bayes_opt" }] -[tool.poetry.group.dev] # for testing/developing +[tool.poetry.group.dev] # for testing/developing optional = true [tool.poetry.group.dev.dependencies] pytest = "^8.0.0" @@ -28,7 +40,7 @@ ruff = "0.6.6" pre-commit = "^3.7.1" -[tool.poetry.group.nbtools] # for running/converting notebooks +[tool.poetry.group.nbtools] # for running/converting notebooks optional = true [tool.poetry.group.nbtools.dependencies] nbformat = "^5.9.2" @@ -38,17 +50,17 @@ matplotlib = "^3.0" nbsphinx = "^0.9.4" sphinx-immaterial = "^0.12.0" sphinx = [ - {version = "^7.0.0", python = "<3.10"}, - {version = "^8.0.0", python = ">=3.10"} + { version = "^7.0.0", python = "<3.10" }, + { version = "^8.0.0", python = ">=3.10" }, ] sphinx-autodoc-typehints = [ - {version = "^2.3.0", python = "<3.10"}, - {version = "^2.4.0", python = ">=3.10"} + { version = "^2.3.0", python = "<3.10" }, + { version = "^2.4.0", python = ">=3.10" }, ] [build-system] -requires = ["poetry-core"] +requires = ["poetry-core>=2.0"] build-backend = "poetry.core.masonry.api" [tool.coverage.report]