diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5adb464..6cb9c22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,20 +12,20 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" - - name: Install Twine - run: sudo pip install twine + - name: Install Twine and Build + run: sudo pip install twine build - name: Create the distribution run: | git fetch --prune --unshallow --tags - sudo python setup.py sdist bdist_wheel + sudo python3 -m build - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 @@ -39,10 +39,10 @@ jobs: shell: bash -l {0} steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" @@ -53,13 +53,13 @@ jobs: activate-environment: "" miniconda-version: "latest" - - name: Install the Mamba Dependencies - run: | + - name: Install the Conda Dependencies + run: | conda config --set always_yes yes --set auto_update_conda false conda update conda - conda install mamba -n base -c conda-forge conda install -n base conda-libmamba-solver - mamba install python=3.9 "conda-build=3.21" colorama pip ruamel ruamel.yaml rich mamba jsonschema -c conda-forge + conda install python=3.9 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge + git fetch --prune --unshallow --tags pip install -e . # run install twice due to client-size to ensure all files downloaded @@ -67,16 +67,15 @@ jobs: # git tags MUST be fetched otherwise output will be blank # bash variables cannot be used in github actions, must use actions specific syntax and methods - name: Build the Anaconda Package - id: mambabuild + id: condabuild run: | - mamba install anaconda-client + conda install anaconda-client conda config --set anaconda_upload no --set solver libmamba echo yes | anaconda login --username ${{ secrets.ANACONDA_CLOUD_USERNAME }} --password ${{ secrets.ANACONDA_CLOUD_PASSWORD }} - git fetch --prune --unshallow --tags - VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c conda-forge -c stanfordcvxgrp --numpy 1.16.4 - echo '::set-output name=gitversion::$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)' + VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c anaconda -c conda-forge -c stanfordcvxgrp + echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT - name: Upload the Anaconda Package id: condaload run: | - anaconda upload -u stanfordcvxgrp /usr/share/miniconda3/conda-bld/noarch/qss-${{ steps.mambabuild.outputs.gitversion }}-*.tar.bz2 + anaconda upload -u stanfordcvxgrp /usr/share/miniconda3/conda-bld/noarch/qss-${{ steps.condabuild.outputs.gitversion }}-*.tar.bz2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9efaa47..e98edfe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,56 +1,59 @@ name: Main Test + on: - pull_request: - push: - branches: - - master - tags: - - '*' + push: + pull_request: + branches: [main] + types: [opened, edited, reopened] jobs: run-tests: runs-on: ubuntu-latest + environment: test + strategy: + fail-fast: false + matrix: + python-version: [ "3.10", "3.11", "3.12" ] steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: ${{ matrix.python-version }} - - name: Install Dependencies - run: | - sudo python -m pip install -r requirements.txt - python -m pip install pytest - python -m pip install -e . + - name: Install Python Dependencies + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + uv pip install --system --break-system-packages -r requirements.txt + uv pip install --system --break-system-packages pytest pytest-cov pytest-github-report pytest-github-actions-annotate-failures -# Current unit test is not consistent. Occasionally fails despite usually passing. Needs to be fixed. - name: Run Unit Tests - run: | - python -m pytest --import-mode=append tests/ + env: + pytest_github_report: true + pytest_verbosity: 2 + run: pytest -v --cov=src --cov-report=xml --cov-report=term-missing --color=yes tests/ test-build-pypi: - needs: run-tests runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" - - name: Install Twine - run: sudo pip install twine + - name: Install Twine and Build + run: sudo pip install twine build - name: Create the distribution run: | git fetch --prune --unshallow --tags - sudo python setup.py sdist bdist_wheel + sudo python3 -m build test-build-conda: - needs: run-tests runs-on: ubuntu-latest # sets default shell to remove need for source to run the conda shell defaults: @@ -58,27 +61,27 @@ jobs: shell: bash -l {0} steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" - name: Install Miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: auto-activate-base: true activate-environment: "" miniconda-version: "latest" - - name: Install the Mamba Dependencies - run: | + - name: Install the Conda Dependencies + run: | conda config --set always_yes yes --set auto_update_conda false conda update conda - conda install mamba -n base -c conda-forge conda install -n base conda-libmamba-solver - mamba install python=3.9 "conda-build=3.21" colorama pip ruamel ruamel.yaml rich mamba jsonschema -c conda-forge + conda install python=3.9 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge + git fetch --prune --unshallow --tags pip install -e . @@ -87,10 +90,10 @@ jobs: # git tags MUST be fetched otherwise output will be blank # bash variables cannot be used in github actions, must use actions specific syntax and methods - name: Build the Anaconda Package - id: mambabuild + id: condabuild run: | - mamba install anaconda-client + conda install anaconda-client + conda clean --all conda config --set anaconda_upload no --set solver libmamba - git fetch --prune --unshallow --tags - VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c conda-forge -c stanfordcvxgrp --numpy 1.16.4 - echo '::set-output name=gitversion::$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)' + VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)test conda build . -c conda-forge -c stanfordcvxgrp + echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT diff --git a/conda_recipe/meta.yaml b/conda_recipe/meta.yaml index 7d567b6..db59174 100644 --- a/conda_recipe/meta.yaml +++ b/conda_recipe/meta.yaml @@ -5,7 +5,7 @@ package: version: {{ environ.get('VERSION_FROM_GIT_TAG') }} source: - git_url: https://github.com/cvxgrp/qss + path: .. # checked out repo instead of main repo branch build: noarch: python @@ -16,27 +16,30 @@ requirements: host: - pip - python >=3.6 - - scipy - - numpy >=1.16 - - qdldl-python - - cvxpy - - matplotlib run: - pip - python - - scipy - - numpy >=1.16 + - scipy==1.13.1 + - numpy - qdldl-python - cvxpy - matplotlib +test: + imports: + - qss + commands: + - pip check + requires: + - pip + about: home: https://github.com/cvxgrp/qss - license: BSD - license_family: BSD - license_file: - summary: QSS Quadratic-Seperable Solver + license: Apache + license_family: Apache + license_file: LICENSE + summary: QSS Quadratic-Separable Solver doc_url: dev_url: @@ -44,3 +47,4 @@ extra: recipe-maintainers: - lukevolpatti - Thistleman + - pluflou diff --git a/pyproject.toml b/pyproject.toml index a7a6804..56782ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,48 @@ [build-system] -requires = ["setuptools>=61.0.0", "wheel"] -build-backend = "setuptools.build_meta" \ No newline at end of file +requires = ["setuptools>=64.0", "setuptools-scm[toml]"] +build-backend = "setuptools.build_meta" + +[project] +name = "qss" +description = "QSS: Quadratic-Separable Solver" +readme = "README.md" +license.file = "LICENSE" +authors = [ + { name = "Luke Volpatti", email = "bennetm@stanford.edu" }, +] +maintainers = [ + { name = "Sara Miskovich", email = "smiskov@slac.stanford.edu" }, +] +requires-python = ">=3.6" + +dependencies = [ + "scipy==1.13.1", + "numpy", + "cvxpy", + "qdldl", + "matplotlib" +] + +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", +] +dynamic = ["version"] +[tool.setuptools_scm] + +[tool.setuptools.packages.find] +include = ["qss*"] + +[project.urls] +Homepage = "https://github.com/cvxgrp/qss" +"Bug Tracker" = "https://github.com/cvxgrp/qss/issues" diff --git a/requirements.txt b/requirements.txt index 5eab1bc..543f3de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ numpy -scipy +scipy==1.13.1 qdldl cvxpy matplotlib diff --git a/setup.py b/setup.py deleted file mode 100644 index a768c04..0000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -from setuptools import setup -import subprocess - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -# get all the git tags from the cmd line that follow our versioning pattern -git_tags = subprocess.Popen( - ["git", "tag", "--list", "v*[0-9]", "--sort=version:refname"], - stdout=subprocess.PIPE, -) -tags = git_tags.stdout.read() -git_tags.stdout.close() -tags = tags.decode("utf-8").split("\n") -tags.sort() - -# PEP 440 won't accept the v in front, so here we remove it, strip the new line and decode the byte stream -VERSION_FROM_GIT_TAG = tags[-1][1:] - -setup( - name="qss", - version=VERSION_FROM_GIT_TAG, - author="Luke Volpatti", - description="QSS: Quadratic-Separable Solver", - long_description=long_description, - long_description_content_type="text/markdown", - install_requires=["numpy", "scipy", "qdldl", "cvxpy"], - url="https://github.com/lukevolpatti/qss", - project_urls={ - "Bug Tracker": "https://github.com/lukevolpatti/qss/issues", - }, - license="Apache 2.0", - packages=["qss"], - python_requires=">=3.6", -)