diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f04bc2c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +--- +name: build + +# yamllint disable-line rule:truthy +on: + pull_request: + push: + branches: + - master + - "release/**" + tags: + - "v*" + +env: + DEFAULT_PYTHON: "3.11" + +jobs: + build: + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + version: "latest" + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Install dependencies + run: uv sync --group dev + - name: Run tests + run: uv run pytest --cov src/dccp tests + + - name: build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + run: uv build + + - name: publish + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 407f1ec..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,51 +0,0 @@ ---- -name: Release - -# yamllint disable-line rule:truthy -on: - release: - types: - - published - -env: - DEFAULT_PYTHON: "3.12" - -jobs: - release: - name: Releasing to PyPi - runs-on: ubuntu-latest - environment: - name: release - url: https://pypi.org/p/cvx-package-template - permissions: - contents: write - id-token: write - steps: - - name: โคต๏ธ Check out code from GitHub - uses: actions/checkout@v4.2.2 - - name: ๐Ÿ— Install uv - uses: astral-sh/setup-uv@v4 - with: - version: "latest" - python-version: ${{ env.DEFAULT_PYTHON }} - - name: ๐Ÿ— Install dependencies - run: uv sync - - name: ๐Ÿ— Set package version - run: | - version="${{ github.event.release.tag_name }}" - version="${version,,}" - version="${version#v}" - # Update version in pyproject.toml using sed - sed -i "s/^version = .*/version = \"${version}\"/" pyproject.toml - - name: ๐Ÿ— Build package - run: uv build - - name: ๐Ÿš€ Publish to PyPi - uses: pypa/gh-action-pypi-publish@v1.12.4 - with: - verbose: true - print-hash: true - - name: โœ๏ธ Sign published artifacts - uses: sigstore/gh-action-sigstore-python@v3.0.1 - with: - inputs: ./dist/*.tar.gz ./dist/*.whl - release-signing-artifacts: true diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 00adcba..9cedfc2 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -18,7 +18,7 @@ jobs: matrix: include: - python-version: "3.11" - cvxpy-version: "1.6.7" + cvxpy-version: "1.9.0" - python-version: "3.11" cvxpy-version: "latest" - python-version: "3.12" diff --git a/.gitignore b/.gitignore index 7f51aad..10ba67d 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ target/ # uv uv.lock +src/dccp/_version.py # autodocs docs/src/api diff --git a/pyproject.toml b/pyproject.toml index 516a527..7d28f24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] name = "dccp" -version = "2.0.0" +dynamic = ["version"] description = "A CVXPY extension for difference of convex programs." readme = "README.md" license = { text = "GPLv3" } @@ -18,7 +18,7 @@ maintainers = [ { name = "Stefan de Lange", email = "langestefan@msn.com" }, ] requires-python = ">=3.11" -dependencies = ["cvxpy>=1.6.7"] +dependencies = ["cvxpy>=1.9.0"] keywords = ["convex optimization", "cvxpy", "mathematical programming"] classifiers = [ "Development Status :: 5 - Production/Stable", @@ -165,5 +165,11 @@ max-complexity = 25 ] [tool.codespell] -ignore-words-list = "fro" +ignore-words-list = "coo,fro" skip = "pyproject.toml" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/dccp/_version.py" diff --git a/tests/test_cvxpy_compat.py b/tests/test_cvxpy_compat.py index 5f7c823..ae6c8d9 100644 --- a/tests/test_cvxpy_compat.py +++ b/tests/test_cvxpy_compat.py @@ -3,9 +3,10 @@ from __future__ import annotations import cvxpy as cp +from cvxpy.constraints.zero import Equality from cvxpy.reductions.solution import Solution -from dccp.problem import Equality, _set_problem_status +from dccp.problem import _set_problem_status class TestCvxpyCompatibility: