diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index 6b976ca1..dc3ec890 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 9177aef6..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,21 +0,0 @@ -include *.grib -include *.grib2 -include *.rst -include *.yml -include .dockerignore -include Dockerfile -include LICENSE -include Makefile -include tox.ini -recursive-include cfgrib *.h -recursive-include ci *.in -recursive-include ci *.ps1 -recursive-include ci *.txt -recursive-include ci *.yml -recursive-include docs *.gitkeep -recursive-include docs *.py -recursive-include docs *.rst -recursive-include tests *.grib -recursive-include tests *.ipynb -recursive-include tests *.py -recursive-include tests *.yml diff --git a/cfgrib/__init__.py b/cfgrib/__init__.py index 778575b1..fa949633 100644 --- a/cfgrib/__init__.py +++ b/cfgrib/__init__.py @@ -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 @@ -25,3 +30,5 @@ from .xarray_store import open_dataset, open_datasets except ImportError: pass + +__all__ = ["__version__"] diff --git a/pyproject.toml b/pyproject.toml index cfc95b0d..e70545d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/setup.cfg b/setup.cfg index d6932e3c..88f57ca1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/setup.py b/setup.py index 9a315a57..5e666b47 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,6 @@ # limitations under the License. import os -import re import setuptools # type: ignore @@ -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"), @@ -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",