From 553e5ee2592068569de2ef8560a95008116b52aa Mon Sep 17 00:00:00 2001 From: Max Jones <14077947+maxrjones@users.noreply.github.com> Date: Sat, 7 Jan 2023 20:07:58 -0500 Subject: [PATCH] Update packaging configuration and workflow (#147) * Add separate workflow for uploading to TestPyPI * Remove version_scheme for Test PyPI * Remove cache step * Use node_and_date * Remove setup.py --- .github/workflows/main.yaml | 10 ++--- .github/workflows/pypi-release.yaml | 2 +- .github/workflows/testpypi-release.yaml | 56 +++++++++++++++++++++++++ README.rst | 2 +- pyproject.toml | 9 ++-- setup.py | 4 -- 6 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/testpypi-release.yaml delete mode 100644 setup.py diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8154b96..e571983 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -5,6 +5,10 @@ on: branches: main pull_request: branches: main + paths-ignore: + - ".github/workflows/*-release.yaml" + - "asv_bench/**" + - "doc/**" schedule: - cron: "0 0 * * *" @@ -54,12 +58,6 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: x64 - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/dev-requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - run: | python -m pip install -e .[dev] python -m pip install --no-deps --upgrade \ diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 98fe528..9b5232d 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -36,7 +36,7 @@ jobs: # Change setuptools-scm local_scheme to "no-local-version" so the # local part of the version isn't included, making the version string # compatible with PyPI. - sed --in-place "s/dirty-tag/no-local-version/g" pyproject.toml + sed --in-place "s/node-and-date/no-local-version/g" pyproject.toml - name: Build tarball and wheels run: | diff --git a/.github/workflows/testpypi-release.yaml b/.github/workflows/testpypi-release.yaml new file mode 100644 index 0000000..9d6b177 --- /dev/null +++ b/.github/workflows/testpypi-release.yaml @@ -0,0 +1,56 @@ +name: Build and Upload xbatcher to TestPyPI +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + publish-testpypi: + name: Publish to Test PyPI + runs-on: ubuntu-latest + if: github.repository == 'xarray-contrib/xbatcher' + + steps: + - name: Checkout + uses: actions/checkout@v3.2.0 + with: + # fetch all history so that setuptools-scm works + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4.3.1 + with: + python-version: "3.10" + + - name: Install dependencies + run: python -m pip install build + + - name: Fix up version string for TestPyPI + if: ${{ !startsWith(github.ref, 'refs/tags') }} + run: | + sed --in-place "s/node-and-date/no-local-version/g" pyproject.toml + + - name: Build tarball and wheels + run: | + python -m build + echo "Generated files:" + ls -lh dist/ + + - name: Verify the built dist/wheel is valid + run: | + python -m pip install --upgrade pip + python -m pip install dist/xbatcher*.whl + python -m xbatcher.util.print_versions + + - name: Publish package to TestPyPI + uses: pypa/gh-action-pypi-publish@v1.6.4 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + # verbose: true diff --git a/README.rst b/README.rst index a9d858e..8efc168 100644 --- a/README.rst +++ b/README.rst @@ -56,7 +56,7 @@ Or from source as:: for more details. Documentation ------------- +------------- Documentation is hosted on ReadTheDocs: https://xbatcher.readthedocs.org diff --git a/pyproject.toml b/pyproject.toml index e741d94..8811a94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ - "setuptools>=61", - "setuptools-scm" + "setuptools>=64", + "setuptools-scm[toml]>=6.2" ] build-backend = "setuptools.build_meta" @@ -54,13 +54,12 @@ repository = "https://github.com/xarray-contrib/xbatcher" include = ["xbatcher*"] [tool.setuptools_scm] -version_scheme = "post-release" -local_scheme = "dirty-tag" +local_scheme = "node-and-date" fallback_version = "999" [tool.isort] profile = "black" -known_third_party = ["numpy", "pytest", "setuptools", "sphinx_autosummary_accessors", "torch", "xarray"] +known_third_party = ["numpy", "pytest", "sphinx_autosummary_accessors", "torch", "xarray"] [tool.pytest.ini_options] log_cli = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 088d7e4..0000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -from setuptools import setup - -setup(use_scm_version={"fallback_version": "999"})