Skip to content

Commit

Permalink
Update PyPI workflow to build and upload intake-esm artifacts (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Mar 1, 2024
1 parent 1e6229d commit 141425b
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 91 deletions.
71 changes: 60 additions & 11 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,84 @@
name: Publish intake-esm to PyPI
name: Build and Upload intake-esm to PyPI

on:
release:
types:
- published
push:

jobs:
deploy:
if: github.repository == 'intake/intake-esm'
build-artifacts:
runs-on: ubuntu-latest
if: github.repository == 'intake/intake-esm'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
fetch-depth: 0
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
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: Test the artifacts
- name: Check built artifacts
run: |
python -m twine check dist/*
pwd
if [ -f dist/intake-esm-unknown.tar.gz ]; then
echo "❌ INVALID VERSION NUMBER"
exit 1
else
echo "✅ Looks good"
fi
- uses: actions/upload-artifact@v4
with:
name: releases
path: dist

test-built-dist:
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.11"
- uses: actions/download-artifact@v4
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/intake_esm*.whl
python -c "import intake_esm; print(intake_esm.__version__)"
upload-to-pypi:
needs: test-built-dist
if: github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: releases
path: dist
- name: Publish package to PyPI
uses: pypa/[email protected]
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
verbose: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,4 @@ tests/test_collections/*.nc
dask-worker-space/

CMIP6-MRI-ESM2-0*
intake_esm/_version.py
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ include LICENSE
include README.md
include requirements.txt
include pyproject.toml
include intake_esm/py.typed
include intake_esm/_version.py

recursive-include docs/source *
include docs/Makefile docs/make.bat
Expand Down
15 changes: 6 additions & 9 deletions intake_esm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
""" Top-level module for intake_esm. """
# Import intake first to avoid circular imports during discovery.
import intake
from pkg_resources import DistributionNotFound, get_distribution

from . import tutorial
from .core import esm_datastore
from .derived import DerivedVariableRegistry, default_registry
from .utils import set_options, show_versions

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound: # pragma: no cover
__version__ = '0.0.0' # pragma: no cover
from intake_esm import tutorial
from intake_esm.core import esm_datastore
from intake_esm.derived import DerivedVariableRegistry, default_registry
from intake_esm.utils import set_options, show_versions

from intake_esm._version import __version__
Empty file added intake_esm/py.typed
Empty file.
73 changes: 64 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,65 @@
[tool.black]
line-length = 100
target-version = ['py310']
skip-string-normalization = true

[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]

[tool.pytest.ini_options]
console_output_style = "count"
addopts = "--cov=./ --cov-report=xml --verbose"
markers = "network: tests requiring a network connection"
[project]
name = "intake-esm"
description = "An intake plugin for parsing an Earth System Model (ESM) catalog and loading netCDF files and/or Zarr stores into Xarray datasets."
readme = "README.md"
license = {text="Apache Software License 2.0"}
requires-python = ">=3.10"
maintainers = [
{ name = "NCAR XDev Team", email = "[email protected]" },
]
keywords = [
"catalog",
"intake",
"xarray",
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
]

dynamic = ["version", "dependencies"]

[tool.setuptools.dynamic]

dependencies = { file = ["requirements.txt"] }
optional-dependencies = { dev = { file = ["requirements-dev.txt"] } }

[project.entry-points."intake.drivers"]
esm_datasource = "intake_esm.source:ESMDataSource"
esm_datastore = "intake_esm.core:esm_datastore"

[project.urls]
Documentation = "https://intake-esm.readthedocs.io"
Homepage = "https://intake-esm.readthedocs.io"
Source = "https://github.com/intake/intake-esm"
Tracker = "https://github.com/intake/intake-esm/issues"


[tool.setuptools.packages.find]
include = ["intake_esm*"]

[tool.setuptools.package-data]
intake_esm = ["py.typed"]



[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "node-and-date"
fallback_version = "999"
write_to = "intake_esm/_version.py"
write_to_template = '__version__ = "{version}"'



Expand Down Expand Up @@ -82,3 +132,8 @@ docstring-code-format = true

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.pytest.ini_options]
console_output_style = "count"
addopts = "--cov=./ --cov-report=xml --verbose"
markers = "network: tests requiring a network connection"
62 changes: 0 additions & 62 deletions setup.py

This file was deleted.

0 comments on commit 141425b

Please sign in to comment.