Skip to content

Commit 3b5ac13

Browse files
authored
Remove pkg resources (#273)
1 parent dd2aae7 commit 3b5ac13

File tree

6 files changed

+33
-11
lines changed

6 files changed

+33
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ share/python-wheels/
2626
.installed.cfg
2727
*.egg
2828
MANIFEST
29+
cf_xarray/_version.py
2930

3031
# PyInstaller
3132
# Usually these files are written by a python script from a template

MANIFEST.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
11
graft cf_xarray/data
2+
exclude cf_xarray/_version.py
3+
4+
prune ci
5+
prune doc
6+
prune *.egg-info
7+
prune .binder/
8+
prune .github/
9+
10+
exclude CITATION.cff
11+
exclude .deepsource.toml
12+
exclude .tributors
13+
exclude .zenodo.json
14+
exclude *.yml
15+
exclude *.yaml
16+
exclude .gitignore

cf_xarray/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Any, Dict, Iterable
44
from xml.etree import ElementTree
55

6-
from pkg_resources import DistributionNotFound, get_distribution
76
from xarray import DataArray
87

98

@@ -94,7 +93,9 @@ def parse_cf_standard_name_table(source=None):
9493

9594

9695
def _get_version():
96+
__version__ = "unknown"
9797
try:
98-
return get_distribution("cf_xarray").version
99-
except DistributionNotFound:
100-
return "unknown"
98+
from ._version import __version__
99+
except ImportError:
100+
pass
101+
return __version__

doc/examples/introduction.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,9 @@
648648
"## Feature: Rewriting arguments\n",
649649
"\n",
650650
"`cf_xarray` can rewrite arguments for a large number of xarray functions. By\n",
651-
"this I mean that instead of specifying say `dim=\"lon\"`, you can pass `dim=\"X\"` or\n",
652-
"`dim=\"longitude\"` and `cf_xarray` will rewrite that to `dim=\"lon\"` based on the\n",
653-
"attributes present in the dataset.\n",
651+
"this I mean that instead of specifying say `dim=\"lon\"`, you can pass `dim=\"X\"`\n",
652+
"or `dim=\"longitude\"` and `cf_xarray` will rewrite that to `dim=\"lon\"` based on\n",
653+
"the attributes present in the dataset.\n",
654654
"\n",
655655
"Here are a few examples\n"
656656
]

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ python_requires = >=3.6
1111
install_requires =
1212
numpy >= 1.15
1313
pandas >= 0.25
14-
setuptools >= 41.2 # For pkg_resources
1514
xarray
1615
setup_requires =
1716
setuptools >= 41.2
@@ -42,7 +41,7 @@ skip_gitignore = true
4241
force_to_top = true
4342
default_section = THIRDPARTY
4443
known_first_party = cf_xarray
45-
known_third_party = dask,matplotlib,numpy,pandas,pint,pkg_resources,pytest,setuptools,sphinx_autosummary_accessors,xarray
44+
known_third_party = dask,matplotlib,numpy,pandas,pint,pytest,setuptools,sphinx_autosummary_accessors,xarray
4645

4746
# Most of the numerical computing stack doesn't have type annotations yet.
4847
[mypy-affine.*]

setup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
from setuptools import setup
33

44
setup(
5-
use_scm_version=True,
6-
setup_requires=["setuptools_scm"],
5+
# The package metadata is specified in setup.cfg but GitHub's downstream dependency graph
6+
# does not work unless we put the name this here too.
7+
name="cf_xarray",
8+
use_scm_version={
9+
"write_to": "cf_xarray/_version.py",
10+
"write_to_template": '__version__ = "{version}"',
11+
"tag_regex": r"^(?P<prefix>v)?(?P<version>[^\+]+)(?P<suffix>.*)?$",
12+
},
713
description="A lightweight convenience wrapper for using CF attributes on xarray objects. ",
814
url="https://cf-xarray.readthedocs.io",
915
)

0 commit comments

Comments
 (0)