From ac56396c755a0c3adafbe7f51e6adcb2a104a3af Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Tue, 20 Feb 2024 15:09:20 +0100 Subject: [PATCH 1/3] Move options from setup.cfg to pyproject.toml --- pyproject.toml | 125 +++++++++++++++++++++++++++++++++++++++++ setup.cfg | 147 ------------------------------------------------- 2 files changed, 125 insertions(+), 147 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index 0b5876204d2..6062eaf0939 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,128 @@ requires = ["setuptools>=64", "setuptools_scm[toml]>=8"] build-backend = "setuptools.build_meta" +[project] +name = "ctapipe" +description = "Event reconstruction framework for Imaging Atmospheric Cherenkov Telescopes developed for CTAO." +readme = "README.rst" +authors = [ + {name = "ctapipe developers"}, +] +maintainers = [ + {name = "Karl Kosack", email = "karl.kosack@cea.fr"}, + {name = "Maximilian Linhoff", email = "maximilian.linhoff@tu-dortmund.de"}, +] +license = {text = "BSD-3-Clause"} +classifiers = [ + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Scientific/Engineering :: Astronomy", + "Development Status :: 3 - Alpha", +] + +dynamic = ["version"] +requires-python = ">=3.9" + +dependencies = [ + "astropy >=5.3,<7.0.0a0", + "bokeh ~=2.0", + "docutils", + "eventio >=1.9.1, <2.0.0a0", + "iminuit >=2", + "importlib_metadata; python_version < '3.10'", + "joblib", + "matplotlib ~=3.0", + "numba >=0.56", + "numpy ~=1.16", + "psutil", + "pyyaml >=5.1", + "requests", + "scikit-learn <1.4", + "scipy ~=1.2", + "tables ~=3.4", + "tqdm >=4.32", + "traitlets ~=5.6", + "zstandard", +] + +[project.optional-dependencies] +tests = [ + "h5py", + "pandas", + "pytest >= 7.0", + "pytest-cov", + "pytest-xdist", + "pytest_astropy_header", + "tomli", +] + +docs = [ + "sphinx", + "pydata_sphinx_theme", + "sphinx_automodapi", + "nbsphinx", + "numpydoc", + "sphinx-design", + "sphinx-gallery", + "jupyter", + "notebook", + "graphviz", + "pandas", + "ipython", + "ffmpeg-python", + "pypandoc", +] + +dev = [ + "pre-commit", + "setuptools_scm[toml]", +] + +all = [ + # self-reference with all extras to simplify + "ctapipe[tests,docs,dev]", +] + +[project.scripts] +ctapipe-info = "ctapipe.tools.info:main" +ctapipe-dump-instrument = "ctapipe.tools.dump_instrument:main" +ctapipe-display-dl1 = "ctapipe.tools.display_dl1:main" +ctapipe-process = "ctapipe.tools.process:main" +ctapipe-merge = "ctapipe.tools.merge:main" +ctapipe-fileinfo = "ctapipe.tools.fileinfo:main" +ctapipe-quickstart = "ctapipe.tools.quickstart:main" +ctapipe-train-energy-regressor = "ctapipe.tools.train_energy_regressor:main" +ctapipe-train-particle-classifier = "ctapipe.tools.train_particle_classifier:main" +ctapipe-train-disp-reconstructor = "ctapipe.tools.train_disp_reconstructor:main" +ctapipe-apply-models = "ctapipe.tools.apply_models:main" + +[project.entry-points.ctapipe_io] +HDF5EventSource = "ctapipe.io.hdf5eventsource:HDF5EventSource" +SimTelEventSource = "ctapipe.io.simteleventsource:SimTelEventSource" + + +[project.entry-points.ctapipe_reco] +DispReconstructor = "ctapipe.reco.sklearn.DispReconstructor" +HillasIntersection = "ctapipe.reco.hillas_intersection.HillasIntersection" +HillasReconstructor = "ctapipe.reco.hillas_reconstructor.HillasReconstructor" +EnergyRegressor = "ctapipe.reco.sklearn.EnergyRegressor" +ParticleClassifier = "ctapipe.reco.sklearn.ParticleClassifier" + +[project.urls] +repository = "https://github.com/cta-observatory/ctapipe/" +documentation = "https://ctapipe.readthedocs.io/" + + +[tool.setuptools.packages.find] +where = ["src"] +exclude = ["ctapipe._dev_version"] + [tool.setuptools_scm] write_to = "src/ctapipe/_version.py" @@ -28,6 +150,7 @@ minversion = "7" testpaths = ["src"] log_cli_level = "INFO" xfail_strict = true +astropy_header = true # print summar of failed tests, force errors if settings are misspelled addopts = ["-ra", "--strict-config", "--strict-markers"] @@ -35,11 +158,13 @@ addopts = ["-ra", "--strict-config", "--strict-markers"] filterwarnings = [ "error::astropy.utils.exceptions.AstropyDeprecationWarning", "error::ctapipe.utils.deprecation.CTAPipeDeprecationWarning", + "ignore:`np.MachAr` is deprecated:DeprecationWarning", ] norecursedirs = [ ".git", "_build", "auto_examples", + "build", ] [tool.towncrier] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 952a64b0239..00000000000 --- a/setup.cfg +++ /dev/null @@ -1,147 +0,0 @@ -[metadata] -name = ctapipe -description = CTA Python pipeline experimental version -long_description = file: README.rst -long_description_content_type = text/x-rst -author = ctapipe developers -author_email = karl.kosack@cea.fr -license = BSD 3-Clause License -url = https://github.com/cta-observatory/ctapipe -classifiers = - Intended Audience :: Science/Research - License :: OSI Approved :: BSD License - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: Implementation :: CPython - Topic :: Scientific/Engineering :: Astronomy - Development Status :: 3 - Alpha - - -[options] -packages = find: -package_dir = - =src -python_requires = >=3.9 -zip_safe = False -install_requires= - astropy >=5.3,<7.0.0a0 - bokeh ~=2.0 - docutils - eventio >=1.9.1, <2.0.0a0 - iminuit >=2 - importlib_metadata ; python_version < "3.10" - joblib - matplotlib ~=3.0 - numba >=0.56 - numpy ~=1.16 - psutil - pyyaml >=5.1 - requests - scikit-learn <1.4 - scipy ~=1.2 - tables ~=3.4 - tqdm >=4.32 - traitlets ~=5.6 - zstandard - - -[options.extras_require] -tests = - pytest >= 7.0 - pytest-cov - pytest-xdist - pandas - tomli - pytest_astropy_header - h5py - - -docs = - sphinx - pydata_sphinx_theme - sphinx_automodapi - nbsphinx - numpydoc - sphinx-design - sphinx-gallery - jupyter - notebook - graphviz - pandas - ipython - ffmpeg-python - pypandoc - -dev = - setuptools_scm[toml] - -all = - %(tests)s - %(docs)s - %(dev)s - -[options.packages.find] -where = src -exclude = - ctapipe._dev_version - -[options.package_data] -* = resources/* - - -[options.entry_points] -console_scripts = - ctapipe-info = ctapipe.tools.info:main - ctapipe-dump-instrument=ctapipe.tools.dump_instrument:main - ctapipe-display-dl1 = ctapipe.tools.display_dl1:main - ctapipe-process = ctapipe.tools.process:main - ctapipe-merge = ctapipe.tools.merge:main - ctapipe-fileinfo = ctapipe.tools.fileinfo:main - ctapipe-quickstart = ctapipe.tools.quickstart:main - ctapipe-train-energy-regressor = ctapipe.tools.train_energy_regressor:main - ctapipe-train-particle-classifier = ctapipe.tools.train_particle_classifier:main - ctapipe-train-disp-reconstructor = ctapipe.tools.train_disp_reconstructor:main - ctapipe-apply-models = ctapipe.tools.apply_models:main - -ctapipe_io = - HDF5EventSource = ctapipe.io.hdf5eventsource:HDF5EventSource - SimTelEventSource = ctapipe.io.simteleventsource:SimTelEventSource - - -[build_sphinx] -source_dir = docs -build_dir = docs/_build -all_files = 1 - - -[tool:pytest] -minversion=3.0 -norecursedirs=build docs/_build -addopts = -v -astropy_header = true -filterwarnings = - ignore:`np.MachAr` is deprecated:DeprecationWarning - - -[flake8] -exclude= - build, - docs, - .eggs -max-line-length=90 -select = C,E,F,W,B,B950 -ignore = E501,W503,E203,W201,E712,E731 - -[pycodestyle] -count = False -ignore = E501,W503,E203,W201 -max-line-length = 90 -statistics = True - -[yapf] # a code reformatter -based_on_style: pep8 -dedent_closing_brackets: true -coalesce_brackets: true -join_multiple_lines: true From b4c09388f4919111fb5d34f79efcfe9baaa97efa Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Wed, 21 Feb 2024 15:29:34 +0100 Subject: [PATCH 2/3] Update docs/conf.py to read metadata from pyproject --- docs/conf.py | 22 ++++++++++++---------- pyproject.toml | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 877827bba24..c75f5ed1801 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,19 +25,21 @@ # -- General configuration ------------------------------------------------ import datetime import os +import sys +from pathlib import Path -# Get configuration information from setup.cfg -from configparser import ConfigParser +if sys.version_info < (3, 11): + import tomli as tomllib +else: + import tomllib # Sphinx gallery from sphinx_gallery.sorting import ExplicitOrder, FileNameSortKey import ctapipe -setup_cfg = ConfigParser() -setup_cfg.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")]) -setup_metadata = dict(setup_cfg.items("metadata")) -setup_options = dict(setup_cfg.items("options")) +pyproject_path = Path(__file__).parent.parent / "pyproject.toml" +pyproject = tomllib.loads(pyproject_path.read_text()) # Add any Sphinx extension module names here, as strings. They can be @@ -201,12 +203,12 @@ def setup(app): # General information about the project. -project = setup_metadata["name"] -author = setup_metadata["author"] +project = pyproject["project"]["name"] +author = pyproject["project"]["authors"][0]["name"] copyright = "{}. Last updated {}".format( - setup_metadata["author"], datetime.datetime.now().strftime("%d %b %Y %H:%M") + author, datetime.datetime.now().strftime("%d %b %Y %H:%M") ) -python_requires = setup_options["python_requires"] +python_requires = pyproject["project"]["requires-python"] # make some variables available to each page rst_epilog = f""" diff --git a/pyproject.toml b/pyproject.toml index 6062eaf0939..617535e0b5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,7 @@ docs = [ "ipython", "ffmpeg-python", "pypandoc", + "tomli; python_version < '3.11'", ] dev = [ From d98c57c894fd2204bd1ff792ed74c63f97f4021e Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Thu, 22 Feb 2024 15:44:19 +0100 Subject: [PATCH 3/3] Fix flake8 for docs/conf.yp --- docs/conf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index c75f5ed1801..7747dcd41f3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -108,8 +108,8 @@ def setup(app): # these nitpick_ignore = [ # needed for building the docs with python 3.11 locally. - # we use the lowest supported version on readthedocs, so that is what we use the intersphinx - # link above + # we use the lowest supported version on readthedocs, + # so that is what we use in the intersphinx link above ("py:class", "enum.StrEnum"), # these are coming from traitlets: ("py:class", "t.Union"), @@ -305,7 +305,7 @@ def setup(app): "name": "CTA Observatory", "url": "https://www.cta-observatory.org/", "type": "url", - "icon": "https://www.cta-observatory.org/wp-content/themes/ctao/favicon.ico", + "icon": "https://www.cta-observatory.org/wp-content/themes/ctao/favicon.ico", # noqa: E501 }, ], "announcement": """