Skip to content

Commit

Permalink
Modernize the package a bit (#248)
Browse files Browse the repository at this point in the history
* udpate PyPI GHA

* remove setuptools_scm_git_archive

* bump to 3.8 b/c that's what is used as min

* update and add config

* fix identation

* run pre-commit

* move some configs to pyproject.toml

* move setup.py to pyproject.toml

* don't use main

* fix typo

* let's rely only on the version file

* tweak for a smaller sdist

* fix license

* list tests

* don't list esmpy

* no numba on py311

* drop py37 from the CIS

* py38 as min

* run pre-commit

* Update .github/workflows/pypi.yaml

Co-authored-by: David Huard <huard.david@ouranos.ca>

---------

Co-authored-by: David Huard <huard.david@ouranos.ca>
  • Loading branch information
ocefpaf and huard committed Apr 3, 2023
1 parent 7d702f8 commit 924fe3f
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 130 deletions.
1 change: 0 additions & 1 deletion .git_archival.txt

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
matrix:
include:
# Warning: Unless in quotations, numbers below are read as floats. 3.10 < 3.2
- python-version: '3.7'
esmf-version: 8.1
- python-version: '3.8'
esmf-version: 8.2
- python-version: '3.9'
Expand Down Expand Up @@ -77,7 +75,7 @@ jobs:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- name: Create conda environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/provision-with-micromamba@v15
with:
cache-downloads: true
micromamba-version: 'latest'
Expand Down
55 changes: 31 additions & 24 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
name: Upload xesmf to PyPI
name: Publish to PyPI

on:
pull_request:
push:
branches:
- main
release:
types:
- published

defaults:
run:
shell: bash

jobs:
deploy:
packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
shell: bash

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Install build tools
run: |
python -m pip install --upgrade pip
python -m pip install setuptools setuptools-scm wheel twine check-manifest
python -m pip install --upgrade build
- name: Build tarball and wheels
- name: Build binary wheel
run: python -m build --sdist --wheel . --outdir dist

- name: CheckFiles
run: |
python setup.py sdist
python -m pip wheel . -w dist --no-deps
ls dist
python -m pip install --upgrade check-manifest
check-manifest --verbose
- name: Test the artifacts
- name: Test wheels
run: |
python -m check_manifest --verbose
# We cannot run this step b/c esmpy is not available on PyPI
# cd dist && python -m pip install *.whl && cd ..
python -m pip install --upgrade build twine
python -m twine check dist/*
# FIXME: failing at the moment b/c we don't have PyPI ownership
# - name: Publish
# env:
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# run: |
# python -m twine upload dist/*

- name: upload artifacs
uses: actions/upload-artifact@v3
- name: Publish a Python distribution to PyPI
if: success() && github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
path: dist/*
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
20 changes: 18 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: double-quote-string-fixer

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black

Expand All @@ -37,7 +37,7 @@ repos:
- id: isort

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
rev: v3.0.0-alpha.6
hooks:
- id: prettier

Expand All @@ -52,3 +52,19 @@ repos:
'--keep-execution-count',
'--keep-empty',
]

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 0.9.2
hooks:
- id: pyproject-fmt

ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: false
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: monthly
skip: []
submodules: false
12 changes: 7 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ include *.rst

graft xesmf

prune doc
prune ci
prune binder
prune .github
prune *.egg-info
prune binder
prune ci
prune doc

exclude *.yml
exclude *.yaml
exclude .*.toml
exclude *.yml
exclude .*.txt
exclude .gitignore
exclude .pre-commit-config.yaml
exclude .prettierrc.toml
exclude xesmf/_version.py
62 changes: 61 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,68 @@
[build-system]
requires = ["setuptools>=41.2", "setuptools_scm", "wheel", "setuptools_scm_git_archive"]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=41.2",
"setuptools_scm",
"wheel",
]

[project]
name = "xesmf"
description = "Universal Regridder for Geospatial Data"
license = {text = "MIT"}
authors = [
{name = "Jiawei Zhuang", email = "jiaweizhuang@g.harvard.edu"},
]
requires-python = ">=3.8"
classifiers = [
'Development Status :: 4 - Beta',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Intended Audience :: Science/Research',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Scientific/Engineering',
]
dynamic = [
"dependencies",
"readme",
"version",
]
[project.urls]
documentation = "https://xesmf.readthedocs.io/en/latest/"
homepage = "https://github.com/pangeo-data/xESMF"
repository = "https://github.com/pangeo-data/xESMF"

[tool.setuptools]
packages = ["xesmf", "xesmf.tests"]
license-files = ["LICENSE"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
readme = {file = "README.rst", content-type = "text/x-rst"}

[tool.setuptools_scm]
write_to = "xesmf/_version.py"
write_to_template = "__version__ = '{version}'"

[tool.black]
line-length = 100
target-version = ['py38']
skip-string-normalization = true

[tool.isort]
known_first_party = "xesmf"
known_third_party = ["cf_xarray", "cftime", "dask", "numba", "numpy", "pytest", "shapely", "sparse", "xarray"]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
combine_as_imports = true
line_length = 100
skip = [
"setup.py",
"doc/conf.py",
]
8 changes: 5 additions & 3 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
build:
image: latest

version: 2

build:
os: ubuntu-22.04
tools:
python: '3.8'

python:
install:
- requirements: doc/requirements.txt
Expand Down
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cf-xarray>=0.5.1
# We cannot list this here b/c it is not on PyPI.
#esmpy>=8.0.0
numba >=0.55.2
numpy>=1.16
shapely
sparse>=0.8.0
xarray>=0.16.2
12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,3 @@ max-line-length = 100
max-complexity = 18
select = B,C,E,F,W,T4,B9
extend-ignore = E203,E501,E402,W605

[isort]
known_first_party = xesmf
known_third_party = cf_xarray,cftime,dask,numba,numpy,pytest,setuptools,shapely,sparse,xarray
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
combine_as_imports = True
line_length = 100
skip =
doc/conf.py
setup.py
66 changes: 0 additions & 66 deletions setup.py

This file was deleted.

1 change: 0 additions & 1 deletion xesmf/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ def esmf_regrid_build(

# conservative regridding needs cell corner information
if method in ['conservative', 'conservative_normed']:

if not isinstance(sourcegrid, ESMF.Mesh) and not sourcegrid.has_corners:
raise ValueError(
'source grid has no corner information. ' 'cannot use conservative regridding.'
Expand Down
1 change: 0 additions & 1 deletion xesmf/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@


def as_2d_mesh(lon, lat):

if (lon.ndim, lat.ndim) == (2, 2):
assert lon.shape == lat.shape, 'lon and lat should have same shape'
elif (lon.ndim, lat.ndim) == (1, 1):
Expand Down
Loading

0 comments on commit 924fe3f

Please sign in to comment.