diff --git a/MANIFEST.in b/MANIFEST.in index 99b801e827..1902f6a74f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,15 +3,17 @@ include CHANGES COPYING COPYING.LESSER # Files from setup.py package_data that are not automatically added to source distributions recursive-include lib/iris/tests/results *.cml *.cdl *.txt *.xml *.json +recursive-exclude lib/iris/fileformats/_pyke_rules/compiled_krb * recursive-include lib/iris/etc * -include lib/iris/fileformats/_pyke_rules/*.k?b -include lib/iris/tests/stock*.npz +include lib/iris/fileformats/_pyke_rules/*.krb -include requirements/*.txt +recursive-include requirements * # File required to build docs recursive-include docs Makefile *.js *.png *.py *.rst -prune docs/build +prune docs/src/_build +prune docs/src/generated +prune docs/gallery_tests # Files required to build std_names module include tools/generate_std_names.py @@ -19,3 +21,4 @@ include etc/cf-standard-name-table.xml global-exclude *.pyc global-exclude __pycache__ +global-exclude iris_image_test_output diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index 7633bff9c2..1018e5b19a 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -173,6 +173,8 @@ This document explains the changes made to Iris for this release supported Python versions tested by `cirrus-ci`_ for documentation. (:pull:`4163`) +#. `@bjlittle`_ refactored ``setup.py`` into ``setup.cfg``. (:pull:`4168`) + .. comment Whatsnew author names (@github name) in alphabetical order. Note that, core dev names are automatically included by the common_links.inc: diff --git a/requirements/all.txt b/requirements/all.txt deleted file mode 100644 index 6d7bb942cf..0000000000 --- a/requirements/all.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Optional dependencies. - -mo_pack -nc-time-axis -pandas -pyugrid -stratify diff --git a/requirements/core.txt b/requirements/core.txt deleted file mode 100644 index 9e0c4fb1bb..0000000000 --- a/requirements/core.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Core dependencies. - -cartopy>=0.18 -cf-units>=2 -cftime<1.3.0 -dask[array]>=2 -matplotlib -netcdf4 -numpy>=1.14 -scipy -xxhash diff --git a/requirements/docs.txt b/requirements/docs.txt deleted file mode 100644 index f9de791213..0000000000 --- a/requirements/docs.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Documentation dependencies. - -sphinx -sphinx-copybutton -sphinx-gallery -sphinx_rtd_theme -sphinxcontrib-napoleon -sphinx-panels diff --git a/requirements/setup.txt b/requirements/setup.txt deleted file mode 100644 index 9232946a6a..0000000000 --- a/requirements/setup.txt +++ /dev/null @@ -1,4 +0,0 @@ -# Dependencies necessary to run setup.py of iris -# ---------------------------------------------- - -setuptools>=40.8.0 diff --git a/requirements/test.txt b/requirements/test.txt deleted file mode 100644 index 8a720c3e78..0000000000 --- a/requirements/test.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Test dependencies. - -asv -black==21.5b2 -filelock -imagehash>=4.0 -nose -pillow<7 -pre-commit -requests diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000..b27e0c53d8 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,95 @@ +[metadata] +author = SciTools Developers +author_email = scitools-iris-dev@googlegroups.com +classifiers = + Development Status :: 5 Production/Stable + Intended Audience :: Science/Research + License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) + Operating System :: MacOS + Operating System :: POSIX + Operating System :: POSIX :: Linux + Operating System :: Unix + Programming Language :: Python + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: Implementation :: CPython + Topic :: Scientific/Engineering + Topic :: Scientific/Engineering :: Atmospheric Science + Topic :: Scientific/Engineering :: Visualization +description = + A powerful, format-agnostic, community-driven Python package for analysing and visualising Earth science data +download_url = https://github.com/SciTools/iris +keywords = + cf-metadata + data-analysis + earth-science + grib + netcdf + meteorology + oceanography + space-weather + ugrid + visualisation +license = LGPL-3.0-or-later +license_file = COPYING.LESSER +long_description = file: README.md +long_description_content_type = text/markdown +name = scitools-iris +project_urls = + Code = https://github.com/SciTools/iris + Discussions = https://github.com/SciTools/iris/discussions + Documentation = https://scitools-iris.readthedocs.io/en/stable/ + Issues = https://github.com/SciTools/iris/issues +url = https://github.com/SciTools/iris +version = attr: iris.__version__ + +[options] +include_package_data = True +install_requires = + cartopy>=0.18 + cf-units>=2 + cftime<1.3.0 + dask[array]>=2 + matplotlib + netcdf4 + numpy>=1.14 + scipy + scitools-pyke + xxhash +packages = find: +package_dir = + =lib +python_requires = + >=3.7 +zip_safe = False + +[options.packages.find] +where = lib + +[options.extras_require] +docs = + sphinx + sphinx-copybutton + sphinx-gallery + sphinx_rtd_theme + sphinxcontrib-napoleon + sphinx-panels +test = + asv + black==21.5b2 + filelock + flake8 + imagehash>=4.0 + nose + pillow<7 + pre-commit + requests +all = + mo_pack + nc-time-axis + pandas + pyugrid + stratify + %(docs)s + %(test)s \ No newline at end of file diff --git a/setup.py b/setup.py index d6391e07a6..a767243df9 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ from contextlib import contextmanager -from distutils.util import convert_path import os from shutil import copyfile import sys @@ -10,50 +9,6 @@ from setuptools.command.build_py import build_py -PACKAGE_DIR = os.path.abspath(os.path.dirname(__file__)) -PYPI_NAME = "scitools-iris" - - -# Returns the package and all its sub-packages -def find_package_tree(root_path, root_package): - root_path = root_path.replace("/", os.path.sep) - packages = [root_package] - root_count = len(root_path.split(os.path.sep)) - for (dir_path, dir_names, file_names) in os.walk(convert_path(root_path)): - # Prune dir_names *in-place* to prevent unwanted directory recursion - for dir_name in list(dir_names): - contains_init_file = os.path.isfile( - os.path.join(dir_path, dir_name, "__init__.py") - ) - if not contains_init_file: - dir_names.remove(dir_name) - # Exclude compiled PyKE rules, but keep associated unit tests. - if dir_name == "compiled_krb" and "tests" not in dir_path: - dir_names.remove(dir_name) - if dir_names: - prefix = dir_path.split(os.path.sep)[root_count:] - packages.extend( - [ - ".".join([root_package] + prefix + [dir_name]) - for dir_name in dir_names - ] - ) - return packages - - -def file_walk_relative(top, remove=""): - """ - Returns a generator of files from the top of the tree, removing - the given prefix from the root/file result. - - """ - top = top.replace("/", os.path.sep) - remove = remove.replace("/", os.path.sep) - for root, dirs, files in os.walk(top): - for file in files: - yield os.path.join(root, file).replace(remove, "") - - @contextmanager def temporary_path(directory): """ @@ -74,26 +29,6 @@ def temporary_path(directory): from _runner import TestRunner # noqa: -def pip_requirements(*args): - requirements = [] - for name in args: - fname = os.path.join( - PACKAGE_DIR, "requirements", "{}.txt".format(name) - ) - if not os.path.exists(fname): - emsg = ( - f"Unable to find the {name!r} requirements file at {fname!r}." - ) - raise RuntimeError(emsg) - with open(fname, "r") as fh: - for line in fh: - line = line.strip() - if not line or line.startswith("#"): - continue - requirements.append(line) - return requirements - - class SetupTestRunner(TestRunner, Command): pass @@ -217,25 +152,6 @@ def run(self): return ExtendedCommand -def extract_version(): - version = None - fname = os.path.join(PACKAGE_DIR, "lib", "iris", "__init__.py") - with open(fname) as fi: - for line in fi: - if line.startswith("__version__"): - _, version = line.split("=") - version = version.strip()[1:-1] # Remove quotations - break - return version - - -def long_description(): - fname = os.path.join(PACKAGE_DIR, "README.md") - with open(fname, "rb") as fi: - result = fi.read().decode("utf-8") - return result - - custom_commands = { "test": SetupTestRunner, "develop": custom_cmd(develop_cmd, [build_std_names, compile_pyke_rules]), @@ -257,27 +173,5 @@ def long_description(): setup( - name=PYPI_NAME, - version=extract_version(), - url="http://scitools.org.uk/iris/", - author="UK Met Office", - author_email="scitools-iris-dev@googlegroups.com", - description="A powerful, format-agnostic, community-driven Python " - "package for analysing and visualising Earth science data", - long_description=long_description(), - long_description_content_type="text/markdown", - packages=find_package_tree("lib/iris", "iris"), - package_dir={"": "lib"}, - include_package_data=True, cmdclass=custom_commands, - zip_safe=False, - setup_requires=pip_requirements("setup"), - install_requires=pip_requirements("setup", "core"), - tests_require=[f"{PYPI_NAME}[test]"], - extras_require={ - "all": pip_requirements("all"), - "docs": pip_requirements("docs"), - "test": pip_requirements("test"), - }, - python_requires=">=3.7", )