From 98595e43e7fde39f0b24c326bfd1c91b972f5525 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Wed, 2 Jun 2021 08:52:26 +0100 Subject: [PATCH 1/7] refactor setup.py to setup.cfg --- MANIFEST.in | 11 +++-- requirements/all.txt | 7 --- requirements/core.txt | 11 ----- requirements/docs.txt | 8 ---- requirements/setup.txt | 4 -- requirements/test.txt | 10 ---- setup.cfg | 85 +++++++++++++++++++++++++++++++++ setup.py | 106 ----------------------------------------- 8 files changed, 91 insertions(+), 151 deletions(-) delete mode 100644 requirements/all.txt delete mode 100644 requirements/core.txt delete mode 100644 requirements/docs.txt delete mode 100644 requirements/setup.txt delete mode 100644 requirements/test.txt create mode 100644 setup.cfg diff --git a/MANIFEST.in b/MANIFEST.in index 99b801e827..8ad75e0554 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,16 +2,16 @@ 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/tests * +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/ci * # File required to build docs recursive-include docs Makefile *.js *.png *.py *.rst -prune docs/build +prune docs/src/_build # Files required to build std_names module include tools/generate_std_names.py @@ -19,3 +19,4 @@ include etc/cf-standard-name-table.xml global-exclude *.pyc global-exclude __pycache__ +global-exclude iris_image_test_output 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..d6c55b2051 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,85 @@ +[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.6 + 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 +install_requires = + cartopy>=0.18 + cf-units>=2 + cftime<1.3.0 + dask[array]>=2 + matplotlib + netcdf4 + numpy>=1.14 + scipy + scitools-pyke + xxhash +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 +packages = find: +package_dir = + =lib +python_requires = + >=3.6 +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 +dev = + 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", ) From 2a09ea0e162cca1e19d302a23d223024ee5336e5 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Wed, 2 Jun 2021 11:52:13 +0100 Subject: [PATCH 2/7] add keywords --- setup.cfg | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/setup.cfg b/setup.cfg index d6c55b2051..9b3b8da7b9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,6 +32,17 @@ install_requires = scipy scitools-pyke xxhash +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 From ad7b1046b35c4b7fc88e0988cbe3062324a685b8 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Wed, 2 Jun 2021 12:04:06 +0100 Subject: [PATCH 3/7] added a whatsnew entry --- docs/src/whatsnew/latest.rst | 2 ++ 1 file changed, 2 insertions(+) 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: From 46bc28c18ef7b376f663086bfc19560e77fad10d Mon Sep 17 00:00:00 2001 From: Bill Little Date: Wed, 2 Jun 2021 13:06:54 +0100 Subject: [PATCH 4/7] review actions --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 8ad75e0554..bd35934941 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,6 +12,8 @@ recursive-include requirements/ci * # File required to build docs recursive-include docs Makefile *.js *.png *.py *.rst 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 From 09efdfc491476e28e65293711b7d4059dae1c699 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Fri, 4 Jun 2021 08:29:44 +0100 Subject: [PATCH 5/7] review actions --- MANIFEST.in | 4 ++-- setup.cfg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index bd35934941..1902f6a74f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,12 +2,12 @@ include CHANGES COPYING COPYING.LESSER # Files from setup.py package_data that are not automatically added to source distributions -recursive-exclude lib/iris/tests * +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/*.krb -recursive-include requirements/ci * +recursive-include requirements * # File required to build docs recursive-include docs Makefile *.js *.png *.py *.rst diff --git a/setup.cfg b/setup.cfg index 9b3b8da7b9..6821293aa5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -86,7 +86,7 @@ test = pillow<7 pre-commit requests -dev = +all = mo_pack nc-time-axis pandas From a9c347b8de82d3a8a1863679356633d87ec69e30 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Fri, 4 Jun 2021 08:31:49 +0100 Subject: [PATCH 6/7] rebase with review actions --- setup.cfg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 6821293aa5..b0e1ab6403 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,7 +11,6 @@ classifiers = Operating System :: Unix Programming Language :: Python Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: Implementation :: CPython @@ -62,7 +61,7 @@ packages = find: package_dir = =lib python_requires = - >=3.6 + >=3.7 zip_safe = False [options.packages.find] From be5159b1ca6307d2448f197729671bb6697c3d2a Mon Sep 17 00:00:00 2001 From: Bill Little Date: Fri, 4 Jun 2021 11:01:13 +0100 Subject: [PATCH 7/7] review actions --- setup.cfg | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/setup.cfg b/setup.cfg index b0e1ab6403..b27e0c53d8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,17 +20,6 @@ classifiers = description = A powerful, format-agnostic, community-driven Python package for analysing and visualising Earth science data download_url = https://github.com/SciTools/iris -install_requires = - cartopy>=0.18 - cf-units>=2 - cftime<1.3.0 - dask[array]>=2 - matplotlib - netcdf4 - numpy>=1.14 - scipy - scitools-pyke - xxhash keywords = cf-metadata data-analysis @@ -57,6 +46,17 @@ 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