From d61285510f569342fdd21d30ddda2f8653473926 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Tue, 5 Apr 2022 15:56:21 -0700 Subject: [PATCH 1/3] update np.typing import --- .github/workflows/pypipublish.yaml | 89 +++++++++++++++++++++++++----- requirements.txt | 2 +- xarray_schema/types.py | 3 +- 3 files changed, 76 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pypipublish.yaml b/.github/workflows/pypipublish.yaml index 8703473..a70a8ed 100644 --- a/.github/workflows/pypipublish.yaml +++ b/.github/workflows/pypipublish.yaml @@ -1,26 +1,85 @@ -name: Upload Python Package - +name: Build distribution on: release: - types: [created] + types: + - published + push: jobs: - deploy: + build-artifacts: runs-on: ubuntu-latest + if: github.repository == 'carbonplan/xarray-schema' steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3.1.0 + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v3 + name: Install Python with: - python-version: "3.x" + python-version: 3.9 + - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install setuptools setuptools-scm wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + python -m pip install setuptools setuptools-scm wheel twine check-manifest + + - name: Build tarball and wheels + run: | + git clean -xdf + git restore -SW . + python -m build --sdist --wheel . + + - name: Check built artifacts run: | - python setup.py sdist bdist_wheel - twine upload dist/* + python -m twine check dist/* + pwd + if [ -f dist/xarray-schema-unknown.tar.gz ]; then + echo "❌ INVALID VERSION NUMBER" + exit 1 + else + echo "✅ Looks good" + fi + - uses: actions/upload-artifact@v2 + with: + name: releases + path: dist + + test-built-dist: + needs: build-artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v3 + name: Install Python + with: + python-version: 3.9 + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist + - name: List contents of built dist + run: | + ls -ltrh + ls -ltrh dist + + - name: Verify the built dist/wheel is valid + if: github.event_name == 'push' + run: | + python -m pip install --upgrade pip + python -m pip install dist/xarray-schema*.whl + python -c "import xarray-schema; print(xarray-schema.__version__)" + + upload-to-pypi: + needs: test-built-dist + if: github.event_name == 'release' + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + verbose: true diff --git a/requirements.txt b/requirements.txt index 3215cff..36846b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ xarray>=0.16 -numpy>=1.20 +numpy>=1.21 diff --git a/xarray_schema/types.py b/xarray_schema/types.py index d2bacb7..bd76b89 100644 --- a/xarray_schema/types.py +++ b/xarray_schema/types.py @@ -1,8 +1,7 @@ from typing import Dict, Tuple, Union -import numpy as np +from numpy.typing import DTypeLike # noqa: F401 -DTypeLike = np.typing.DTypeLike DimsT = Tuple[Union[str, None]] ShapeT = Tuple[Union[int, None]] ChunksT = Union[bool, Dict[str, Union[int, None]]] From 4592ed0685f46d43a597ed9984e0f4557bd98c63 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Tue, 5 Apr 2022 15:59:10 -0700 Subject: [PATCH 2/3] fix dist check --- .github/workflows/pypipublish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypipublish.yaml b/.github/workflows/pypipublish.yaml index a70a8ed..e6c86f7 100644 --- a/.github/workflows/pypipublish.yaml +++ b/.github/workflows/pypipublish.yaml @@ -65,7 +65,7 @@ jobs: if: github.event_name == 'push' run: | python -m pip install --upgrade pip - python -m pip install dist/xarray-schema*.whl + python -m pip install dist/xarray_schema*.whl python -c "import xarray-schema; print(xarray-schema.__version__)" upload-to-pypi: From 22e85b98a7905427001d66f82af9e364401b59f3 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Tue, 5 Apr 2022 16:02:31 -0700 Subject: [PATCH 3/3] fix import --- .github/workflows/pypipublish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypipublish.yaml b/.github/workflows/pypipublish.yaml index e6c86f7..abf36b9 100644 --- a/.github/workflows/pypipublish.yaml +++ b/.github/workflows/pypipublish.yaml @@ -66,7 +66,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install dist/xarray_schema*.whl - python -c "import xarray-schema; print(xarray-schema.__version__)" + python -c "import xarray_schema; print(xarray_schema.__version__)" upload-to-pypi: needs: test-built-dist