From 5b6edef64f332326f66229210705f081b7dcb917 Mon Sep 17 00:00:00 2001 From: Jayaram Kancherla Date: Mon, 23 Dec 2024 10:05:46 -0800 Subject: [PATCH] Remove support for Python 3.8 (#29) - Added support for 3.13 --- .github/workflows/build-docs.yml | 22 ++++++------ .github/workflows/publish-pypi.yml | 56 +++++++++++++++--------------- .github/workflows/run-tests.yml | 39 ++++++--------------- .pre-commit-config.yaml | 32 +++++++++++++++++ CHANGELOG.md | 5 +++ docs/requirements.txt | 1 + pyproject.toml | 16 +++++++++ setup.cfg | 2 +- 8 files changed, 105 insertions(+), 68 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 3e242b6..2df289b 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -6,19 +6,17 @@ on: - "*" jobs: - test: + build_docs: name: Build docs runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - submodules: true + - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 + - name: Set up python + uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.12 cache: 'pip' - name: Set up HDF5 @@ -29,7 +27,10 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip setuptools - pip install cmake pybind11 numpy tox + DEPENDENCIES=$(python -c 'from setuptools.config.setupcfg import read_configuration as c; a = c("setup.cfg"); print(" ".join(a["options"]["install_requires"][1:]))') + pip install ${DEPENDENCIES} + DOCDEPENDENCIES=$(python -c 'with open("docs/requirements.txt") as a: available = list(a); print(" ".join(map(lambda x : x.strip(), filter(lambda x : not x.startswith("#"), available))))') + pip install ${DOCDEPENDENCIES} - name: Build docs run: | @@ -39,8 +40,9 @@ jobs: touch ./docs/_build/html/.nojekyll - name: GH Pages Deployment - uses: JamesIves/github-pages-deploy-action@4.1.3 + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages # The branch the action should deploy to. folder: ./docs/_build/html - clean: true # Automatically remove deleted files from the deploy branch + clean: true # Automatically remove deleted files from the deploy branch \ No newline at end of file diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 6225be9..6b2f949 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -11,19 +11,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build wheels uses: pypa/cibuildwheel@v2.16.2 env: CIBW_ARCHS: x86_64 - CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/artifactdb/prebuilt-hdf5/manylinux_x86_64:0.0.4 CIBW_MUSLLINUX_X86_64_IMAGE: ghcr.io/artifactdb/prebuilt-hdf5/musllinux_x86_64:0.0.4 CIBW_SKIP: pp* - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-wheels-ubuntu-x86_64 path: ./wheelhouse/*.whl build_macosx_x86_64: @@ -31,7 +32,7 @@ jobs: runs-on: macos-13 steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Grab prebuilt dependencies run: | @@ -42,22 +43,23 @@ jobs: uses: pypa/cibuildwheel@v2.16.2 env: CIBW_ARCHS: x86_64 - CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" CIBW_ENVIRONMENT: "MORE_CMAKE_OPTIONS=\"-DCMAKE_INSTALL_PREFIX=$(pwd)/installed -DCMAKE_OSX_ARCHITECTURES=x86_64\"" CIBW_BUILD_VERBOSITY: 3 CIBW_SKIP: pp* MACOSX_DEPLOYMENT_TARGET: 11.7 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-wheels-macos-x86_64 path: ./wheelhouse/*.whl build_macosx_arm64: name: Build wheels for macosx arm64 - runs-on: macos-13 + runs-on: macos-latest steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Grab prebuilt dependencies run: | @@ -68,13 +70,14 @@ jobs: uses: pypa/cibuildwheel@v2.16.2 env: CIBW_ARCHS: arm64 - CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" CIBW_ENVIRONMENT: "MORE_CMAKE_OPTIONS=\"-DCMAKE_INSTALL_PREFIX=$(pwd)/installed -DCMAKE_OSX_ARCHITECTURES=arm64\"" CIBW_BUILD_VERBOSITY: 3 MACOSX_DEPLOYMENT_TARGET: 13.0 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-wheels-maxos_arm64 path: ./wheelhouse/*.whl # build_windows_x86_64: @@ -82,65 +85,62 @@ jobs: # runs-on: windows-2019 # steps: # - name: Check out repository -# uses: actions/checkout@v3 - +# uses: actions/checkout@v4 +# # - name: Grab prebuilt dependencies # run: | # curl -L https://github.com/ArtifactDB/prebuilt-hdf5/releases/download/0.0.4/windows_x86_64.tar.gz > bundle.tar.gz # tar -xvf bundle.tar.gz # shell: bash - +# # - name: Store path # run: | # $wd = pwd # echo "INSTALL_DIR=$wd\\installed" >> $env:GITHUB_ENV # shell: powershell - +# # - name: Build wheels # uses: pypa/cibuildwheel@v2.16.2 # env: # CIBW_ARCHS: AMD64 -# CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" +# CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" # CIBW_ENVIRONMENT: "MORE_CMAKE_OPTIONS=\"-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}\" VERBOSE=1" # CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel" # CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" # CIBW_TEST_EXTRAS: "testing" # CIBW_TEST_COMMAND: "pytest {package}/tests" # CIBW_BUILD_VERBOSITY: 3 - -# - uses: actions/upload-artifact@v3 -# with: -# path: ./wheelhouse/*.whl + # - uses: actions/upload-artifact@v3 + # with: + # path: ./wheelhouse/*.whl build_sdist: name: Build source distribution runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Build sdist run: pipx run build --sdist - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-sdist path: dist/*.tar.gz upload_pypi: needs: [build_linux_x86_64, build_macosx_x86_64, build_macosx_arm64, build_sdist] runs-on: ubuntu-latest - # upload to PyPI on every tag starting with 'v' - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - # unpacks default artifact into dist/ - # if `name: artifact` is omitted, the action will create extra parent dir - name: artifact + pattern: cibw-* path: dist + merge-multiple: true - - uses: pypa/gh-action-pypi-publish@v1.8.3 + - uses: pypa/gh-action-pypi-publish@v1.12.2 with: user: __token__ password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 66ac95e..3ebf2f1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,56 +1,37 @@ -name: Run unit tests +name: Test the library on: push: - branches: [ master ] + branches: + - master pull_request: - branches: [ master ] jobs: test: - runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] name: Python ${{ matrix.python-version }} steps: - - uses: actions/checkout@v3 - with: - submodules: true + - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + - name: Setup Python + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: 'pip' + cache: "pip" - name: Set up HDF5 run: | sudo apt-get update sudo apt-get install libhdf5-dev - - name: Install Python dependencies - run: | - python -m pip install --upgrade pip setuptools - DEPENDENCIES=$(python -c 'from setuptools.config.setupcfg import read_configuration as c; a = c("setup.cfg"); print(" ".join(a["options"]["install_requires"][1:] + a["options"]["extras_require"]["testing"][1:]))') - pip install ${DEPENDENCIES} pybind11 + - name: Get latest CMake + uses: lukka/get-cmake@latest - # We do proper tests if we're on the master branch, or if we're creating a new release. - name: Test with tox - if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') run: | pip install tox tox - - # Otherwise we do some cached builds and tests for faster merging of PRs. - - name: Set up ccache - if: github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags') - uses: hendrikmuhs/ccache-action@v1.2 - - - name: Quickly build and test - if: github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags') - run: | - CC="ccache gcc" python setup.py install - pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a832683 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +exclude: '^docs/conf.py' + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: check-added-large-files + - id: check-ast + - id: check-json + - id: check-merge-conflict + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: mixed-line-ending + args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows + +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.8.2 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format + +## Check for misspells in documentation files: +# - repo: https://github.com/codespell-project/codespell +# rev: v2.2.5 +# hooks: +# - id: codespell diff --git a/CHANGELOG.md b/CHANGELOG.md index 4abd688..64185c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Version 0.4.0 + +- chore: Remove Python 3.8 (EOL). +- precommit: Replace docformatter with ruff's formatter. + ## Version 0.3.0 - Fixes to support NumPy 2.0 release. diff --git a/docs/requirements.txt b/docs/requirements.txt index daecbf1..c20cf60 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,5 @@ furo +myst-nb # Requirements file for ReadTheDocs, check .readthedocs.yml. # To build the module reference correctly, make sure every external package # under `install_requires` in `setup.cfg` is also listed here! diff --git a/pyproject.toml b/pyproject.toml index d03f072..e14ef48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,19 @@ build-backend = "setuptools.build_meta" # For smarter version schemes and other configuration options, # check out https://github.com/pypa/setuptools_scm version_scheme = "no-guess-dev" + +[tool.ruff] +line-length = 120 +src = ["src"] +exclude = ["tests"] +extend-ignore = ["F821"] + +[tool.ruff.pydocstyle] +convention = "google" + +[tool.ruff.format] +docstring-code-format = true +docstring-code-line-length = 20 + +[tool.ruff.per-file-ignores] +"__init__.py" = ["E402", "F401"] diff --git a/setup.cfg b/setup.cfg index 89811ea..79b5943 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,7 +41,7 @@ package_dir = =src # Require a min/specific Python version (comma-separated conditions) -python_requires = >=3.8 +python_requires = >=3.9 # Add here dependencies of your project (line-separated), e.g. requests>=2.2,<3.0. # Version specifiers like >=2.2,<3.0 avoid problems due to API changes in