Skip to content

Commit 924fe3f

Browse files
ocefpafhuard
andauthored
Modernize the package a bit (#248)
* 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 <[email protected]> --------- Co-authored-by: David Huard <[email protected]>
1 parent 7d702f8 commit 924fe3f

17 files changed

+132
-130
lines changed

.git_archival.txt

-1
This file was deleted.

.gitattributes

-1
This file was deleted.

.github/workflows/ci.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
matrix:
2323
include:
2424
# Warning: Unless in quotations, numbers below are read as floats. 3.10 < 3.2
25-
- python-version: '3.7'
26-
esmf-version: 8.1
2725
- python-version: '3.8'
2826
esmf-version: 8.2
2927
- python-version: '3.9'
@@ -77,7 +75,7 @@ jobs:
7775
access_token: ${{ github.token }}
7876
- uses: actions/checkout@v3
7977
- name: Create conda environment
80-
uses: mamba-org/provision-with-micromamba@main
78+
uses: mamba-org/provision-with-micromamba@v15
8179
with:
8280
cache-downloads: true
8381
micromamba-version: 'latest'

.github/workflows/pypi.yaml

+31-24
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,55 @@
1-
name: Upload xesmf to PyPI
1+
name: Publish to PyPI
22

33
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
48
release:
59
types:
610
- published
711

12+
defaults:
13+
run:
14+
shell: bash
15+
816
jobs:
9-
deploy:
17+
packages:
1018
runs-on: ubuntu-latest
1119
steps:
1220
- uses: actions/checkout@v3
13-
- name: Get tags
14-
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
15-
shell: bash
1621

1722
- name: Set up Python
1823
uses: actions/setup-python@v4
1924
with:
2025
python-version: '3.x'
2126

22-
- name: Install dependencies
27+
- name: Get tags
28+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
29+
30+
- name: Install build tools
2331
run: |
24-
python -m pip install --upgrade pip
25-
python -m pip install setuptools setuptools-scm wheel twine check-manifest
32+
python -m pip install --upgrade build
2633
27-
- name: Build tarball and wheels
34+
- name: Build binary wheel
35+
run: python -m build --sdist --wheel . --outdir dist
36+
37+
- name: CheckFiles
2838
run: |
29-
python setup.py sdist
30-
python -m pip wheel . -w dist --no-deps
39+
ls dist
40+
python -m pip install --upgrade check-manifest
41+
check-manifest --verbose
3142
32-
- name: Test the artifacts
43+
- name: Test wheels
3344
run: |
34-
python -m check_manifest --verbose
45+
# We cannot run this step b/c esmpy is not available on PyPI
46+
# cd dist && python -m pip install *.whl && cd ..
47+
python -m pip install --upgrade build twine
3548
python -m twine check dist/*
3649
37-
# FIXME: failing at the moment b/c we don't have PyPI ownership
38-
# - name: Publish
39-
# env:
40-
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
41-
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
42-
# run: |
43-
# python -m twine upload dist/*
44-
45-
- name: upload artifacs
46-
uses: actions/upload-artifact@v3
50+
- name: Publish a Python distribution to PyPI
51+
if: success() && github.event_name == 'release'
52+
uses: pypa/gh-action-pypi-publish@release/v1
4753
with:
48-
path: dist/*
54+
user: __token__
55+
password: ${{ secrets.PYPI_TOKEN }}

.pre-commit-config.yaml

+18-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
- id: double-quote-string-fixer
1414

1515
- repo: https://github.com/psf/black
16-
rev: 22.12.0
16+
rev: 23.3.0
1717
hooks:
1818
- id: black
1919

@@ -37,7 +37,7 @@ repos:
3737
- id: isort
3838

3939
- repo: https://github.com/pre-commit/mirrors-prettier
40-
rev: v3.0.0-alpha.4
40+
rev: v3.0.0-alpha.6
4141
hooks:
4242
- id: prettier
4343

@@ -52,3 +52,19 @@ repos:
5252
'--keep-execution-count',
5353
'--keep-empty',
5454
]
55+
56+
- repo: https://github.com/tox-dev/pyproject-fmt
57+
rev: 0.9.2
58+
hooks:
59+
- id: pyproject-fmt
60+
61+
ci:
62+
autofix_commit_msg: |
63+
[pre-commit.ci] auto fixes from pre-commit.com hooks
64+
65+
for more information, see https://pre-commit.ci
66+
autofix_prs: false
67+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
68+
autoupdate_schedule: monthly
69+
skip: []
70+
submodules: false

MANIFEST.in

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ include *.rst
33

44
graft xesmf
55

6-
prune doc
7-
prune ci
8-
prune binder
6+
prune .github
97
prune *.egg-info
8+
prune binder
9+
prune ci
10+
prune doc
1011

11-
exclude *.yml
1212
exclude *.yaml
13-
exclude .*.toml
13+
exclude *.yml
1414
exclude .*.txt
1515
exclude .gitignore
16+
exclude .pre-commit-config.yaml
17+
exclude .prettierrc.toml
1618
exclude xesmf/_version.py

pyproject.toml

+61-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,68 @@
11
[build-system]
2-
requires = ["setuptools>=41.2", "setuptools_scm", "wheel", "setuptools_scm_git_archive"]
32
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools>=41.2",
5+
"setuptools_scm",
6+
"wheel",
7+
]
8+
9+
[project]
10+
name = "xesmf"
11+
description = "Universal Regridder for Geospatial Data"
12+
license = {text = "MIT"}
13+
authors = [
14+
{name = "Jiawei Zhuang", email = "[email protected]"},
15+
]
16+
requires-python = ">=3.8"
17+
classifiers = [
18+
'Development Status :: 4 - Beta',
19+
'License :: OSI Approved :: MIT License',
20+
'Operating System :: OS Independent',
21+
'Intended Audience :: Science/Research',
22+
'Programming Language :: Python',
23+
'Programming Language :: Python :: 3',
24+
'Programming Language :: Python :: 3.7',
25+
'Programming Language :: Python :: 3.8',
26+
'Programming Language :: Python :: 3.9',
27+
'Programming Language :: Python :: 3.10',
28+
'Topic :: Scientific/Engineering',
29+
]
30+
dynamic = [
31+
"dependencies",
32+
"readme",
33+
"version",
34+
]
35+
[project.urls]
36+
documentation = "https://xesmf.readthedocs.io/en/latest/"
37+
homepage = "https://github.com/pangeo-data/xESMF"
38+
repository = "https://github.com/pangeo-data/xESMF"
39+
40+
[tool.setuptools]
41+
packages = ["xesmf", "xesmf.tests"]
42+
license-files = ["LICENSE"]
43+
44+
[tool.setuptools.dynamic]
45+
dependencies = {file = ["requirements.txt"]}
46+
readme = {file = "README.rst", content-type = "text/x-rst"}
47+
48+
[tool.setuptools_scm]
49+
write_to = "xesmf/_version.py"
50+
write_to_template = "__version__ = '{version}'"
451

552
[tool.black]
653
line-length = 100
754
target-version = ['py38']
855
skip-string-normalization = true
56+
57+
[tool.isort]
58+
known_first_party = "xesmf"
59+
known_third_party = ["cf_xarray", "cftime", "dask", "numba", "numpy", "pytest", "shapely", "sparse", "xarray"]
60+
multi_line_output = 3
61+
include_trailing_comma = true
62+
force_grid_wrap = 0
63+
combine_as_imports = true
64+
line_length = 100
65+
skip = [
66+
"setup.py",
67+
"doc/conf.py",
68+
]

readthedocs.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
build:
2-
image: latest
3-
41
version: 2
52

3+
build:
4+
os: ubuntu-22.04
5+
tools:
6+
python: '3.8'
7+
68
python:
79
install:
810
- requirements: doc/requirements.txt

requirements.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cf-xarray>=0.5.1
2+
# We cannot list this here b/c it is not on PyPI.
3+
#esmpy>=8.0.0
4+
numba >=0.55.2
5+
numpy>=1.16
6+
shapely
7+
sparse>=0.8.0
8+
xarray>=0.16.2

setup.cfg

-12
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,3 @@ max-line-length = 100
88
max-complexity = 18
99
select = B,C,E,F,W,T4,B9
1010
extend-ignore = E203,E501,E402,W605
11-
12-
[isort]
13-
known_first_party = xesmf
14-
known_third_party = cf_xarray,cftime,dask,numba,numpy,pytest,setuptools,shapely,sparse,xarray
15-
multi_line_output = 3
16-
include_trailing_comma = True
17-
force_grid_wrap = 0
18-
combine_as_imports = True
19-
line_length = 100
20-
skip =
21-
doc/conf.py
22-
setup.py

setup.py

-66
This file was deleted.

xesmf/backend.py

-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ def esmf_regrid_build(
420420

421421
# conservative regridding needs cell corner information
422422
if method in ['conservative', 'conservative_normed']:
423-
424423
if not isinstance(sourcegrid, ESMF.Mesh) and not sourcegrid.has_corners:
425424
raise ValueError(
426425
'source grid has no corner information. ' 'cannot use conservative regridding.'

xesmf/frontend.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030

3131
def as_2d_mesh(lon, lat):
32-
3332
if (lon.ndim, lat.ndim) == (2, 2):
3433
assert lon.shape == lat.shape, 'lon and lat should have same shape'
3534
elif (lon.ndim, lat.ndim) == (1, 1):

0 commit comments

Comments
 (0)