Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for v0.9.9.0 release / manage version with setuptools_scm #220

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 0 additions & 4 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Check MANIFEST.in
run: |
$CONDA/bin/conda install -c conda-forge check-manifest
$CONDA/bin/check-manifest .
- name: Build distributions
run: |
$CONDA/bin/conda install pip setuptools wheel
Expand Down
21 changes: 0 additions & 21 deletions MANIFEST.in

This file was deleted.

11 changes: 9 additions & 2 deletions cfgrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.9.9.0.dev0"
try:
# NOTE: the `version.py` file must not be present in the git repository
# as it is generated by setuptools at install time
from .version import __version__
except ImportError:
# Local copy or not installed with setuptools
__version__ = "999"

# cfgrib core API depends on the ECMWF ecCodes C-library only
from .cfmessage import CfMessage
from .dataset import Dataset, DatasetBuildError, open_file, open_fileindex
from .messages import FileStream, Message
Expand All @@ -25,3 +30,5 @@
from .xarray_store import open_dataset, open_datasets
except ImportError:
pass

__all__ = ["__version__"]
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"setuptools_scm[toml]>=3.4",
"setuptools_scm_git_archive",
]

[tool.setuptools_scm]
write_to = "cfgrib/version.py"
write_to_template = '''
# don't change, don't track in version control
__version__ = "{version}"
'''

[tool.black]
line-length = 99

Expand Down
12 changes: 8 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[zest.releaser]
python-file-with-version = cfgrib/__init__.py

# exclude xarray_entrypoint for now
[mypy]

[mypy-cfgrib]
ignore_errors = True

# exclude xarray_entrypoint for now
[mypy-cfgrib.xarray_entrypoint]
ignore_errors = True

[zest.releaser]
python-file-with-version = cfgrib/version.py
create-wheel = yes
14 changes: 1 addition & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# limitations under the License.

import os
import re

import setuptools # type: ignore

Expand All @@ -25,19 +24,8 @@ def read(path: str) -> str:
return open(file_path).read()


# single-sourcing the package version using method 1 of:
# https://packaging.python.org/guides/single-sourcing-package-version/
def parse_version_from(path: str) -> str:
version_file = read(path)
version_match = re.search(r'^__version__ = "(.*)"', version_file, re.M)
if version_match is None or len(version_match.groups()) > 1:
raise ValueError("couldn't parse version")
return version_match.group(1)


setuptools.setup(
name="cfgrib",
version=parse_version_from("cfgrib/__init__.py"),
description="Python interface to map GRIB files to the NetCDF Common Data Model "
"following the CF Convention using ecCodes.",
long_description=read("README.rst") + read("CHANGELOG.rst"),
Expand All @@ -51,7 +39,7 @@ def parse_version_from(path: str) -> str:
python_requires=">=3.5",
extras_require={
"xarray": ["xarray>=0.12.0"],
"tests": ["dask[array]", "flake8", "pytest", "pytest-cov", "scipy", "xarray>=0.12.0",],
"tests": ["dask[array]", "flake8", "pytest", "pytest-cov", "scipy", "xarray>=0.12.0"],
},
zip_safe=True,
keywords="eccodes grib xarray",
Expand Down