From bd15815be6ce9ce1a122ae8860a15151b305ec2b Mon Sep 17 00:00:00 2001 From: Sandor Kertesz Date: Wed, 8 May 2024 16:40:01 +0100 Subject: [PATCH] Use pyproject.toml and src root dir (#9) * Use pyproject.toml and src root dir --- .github/workflows/legacy-ci.yml | 2 +- .gitignore | 1 + docs/conf.py | 2 +- pyproject.toml | 55 ++++++++++++++++++--- setup.cfg | 42 ---------------- {earthkit => src/earthkit}/geo/__init__.py | 2 +- {earthkit => src/earthkit}/geo/constants.py | 0 {earthkit => src/earthkit}/geo/distance.py | 2 +- {earthkit => src/earthkit}/geo/figure.py | 0 9 files changed, 52 insertions(+), 54 deletions(-) rename {earthkit => src/earthkit}/geo/__init__.py (96%) rename {earthkit => src/earthkit}/geo/constants.py (100%) rename {earthkit => src/earthkit}/geo/distance.py (99%) rename {earthkit => src/earthkit}/geo/figure.py (100%) diff --git a/.github/workflows/legacy-ci.yml b/.github/workflows/legacy-ci.yml index 21a5617..7c9786a 100644 --- a/.github/workflows/legacy-ci.yml +++ b/.github/workflows/legacy-ci.yml @@ -51,7 +51,7 @@ jobs: - name: Install Conda environment with Micromamba uses: mamba-org/provision-with-micromamba@v12 with: - environment-file: environment.yml + environment-file: tests/environment-unit-tests.yml environment-name: DEVELOP channels: conda-forge cache-env: true diff --git a/.gitignore b/.gitignore index 2a4b71c..4c3211e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # setuptools-scm version.py +_version.py # Sphinx automatic generation of API docs/_api/ diff --git a/docs/conf.py b/docs/conf.py index 7ce972c..a823deb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,7 @@ autodoc_typehints = "none" # autoapi configuration -autoapi_dirs = ["../earthkit/geo"] +autoapi_dirs = ["../src/earthkit/geo"] autoapi_ignore = ["*/version.py", "sphinxext/*"] autoapi_options = [ "members", diff --git a/pyproject.toml b/pyproject.toml index dc60f4a..f63f7fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,19 +1,58 @@ [build-system] -requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] +requires = ["setuptools>=61", "setuptools-scm>=8.0"] + +[project] +authors = [ + {name = "European Centre for Medium-Range Weather Forecasts (ECMWF)", email = "software.support@ecmwf.int"} +] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Operating System :: OS Independent" +] +dependencies = [ + "scipy" +] +description = "Geospatial computations" +dynamic = ["version"] +license = {text = "Apache License Version 2.0"} +name = "earthkit-geo" +readme = "README.md" +requires-python = ">= 3.8" + +[project.optional-dependencies] +test = [ + "pytest", + "pytest-cov" +] + +[project.urls] +Documentation = "https://earthkit-geo.readthedocs.io/" +Homepage = "https://github.com/ecmwf/earthkit-geo/" +Issues = "https://github.com/ecmwf/earthkit-geo.issues" +Repository = "https://github.com/ecmwf/earthkit-geo/" [tool.coverage.run] -branch = true +branch = "true" [tool.isort] profile = "black" [tool.pydocstyle] -add_ignore = ["D1", "D200", "D205", "D400", "D401", "D403"] +add_ignore = ["D1", "D200", "D205", "D400", "D401"] convention = "numpy" +[tool.setuptools.packages.find] +include = ["earthkit.geo"] +where = ["src/"] + [tool.setuptools_scm] -write_to = "earthkit/geo/version.py" -write_to_template = ''' -# Do not change! Do not track in version control! -__version__ = "{version}" -''' +version_file = "src/earthkit/geo/_version.py" diff --git a/setup.cfg b/setup.cfg index d0566dd..4736e11 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,45 +1,3 @@ -[metadata] -name = earthkit-geo -license = Apache License 2.0 -description = A format-agnostic Python interface for geospatial data -classifiers = - Development Status :: 2 - Pre-Alpha - Intended Audience :: Science/Research - License :: OSI Approved :: Apache Software License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Topic :: Scientific/Engineering -long_description_content_type=text/markdown -long_description = file: README.md -test_suite = tests - -[options] -packages = find_namespace: -install_requires = - scipy -include_package_data = True - -[options.packages.find] -include = earthkit.* - -[options.extras_require] -test = - pytest - pytest-cov - pytest-forked - pytest-timeout - nbformat - nbconvert - [flake8] max-line-length = 110 extend-ignore = E203, W503 - -[mypy] -strict = False -ignore_missing_imports = True diff --git a/earthkit/geo/__init__.py b/src/earthkit/geo/__init__.py similarity index 96% rename from earthkit/geo/__init__.py rename to src/earthkit/geo/__init__.py index 911ca41..c6b3b58 100644 --- a/earthkit/geo/__init__.py +++ b/src/earthkit/geo/__init__.py @@ -10,7 +10,7 @@ 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__ + from ._version import __version__ except ImportError: # pragma: no cover # Local copy or not installed with setuptools __version__ = "999" diff --git a/earthkit/geo/constants.py b/src/earthkit/geo/constants.py similarity index 100% rename from earthkit/geo/constants.py rename to src/earthkit/geo/constants.py diff --git a/earthkit/geo/distance.py b/src/earthkit/geo/distance.py similarity index 99% rename from earthkit/geo/distance.py rename to src/earthkit/geo/distance.py index 0a0af50..fc8a982 100644 --- a/earthkit/geo/distance.py +++ b/src/earthkit/geo/distance.py @@ -187,7 +187,7 @@ def _arclength_to_chordlength(arc_length): class GeoKDTree: def __init__(self, lats, lons): - """KDTree built from ``lats`` and ``lons``.""" + """Build a KDTree from ``lats`` and ``lons``.""" from scipy.spatial import KDTree lats = np.asarray(lats).flatten() diff --git a/earthkit/geo/figure.py b/src/earthkit/geo/figure.py similarity index 100% rename from earthkit/geo/figure.py rename to src/earthkit/geo/figure.py