From 836de527fd148c601a87c0e866b7639a9f9c3f03 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 7 Oct 2024 15:17:59 -0400 Subject: [PATCH] chore: modernize to hatchling backend Signed-off-by: Henry Schreiner --- MANIFEST.in | 4 --- pyproject.toml | 70 +++++++++++++++++++++++++++++++++++++++++---- setup.cfg | 45 ----------------------------- setup.py | 31 -------------------- src/mplhep/label.py | 2 +- 5 files changed, 66 insertions(+), 86 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 53efd2f8..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,4 +0,0 @@ -include src/mplhep/version.pyi -include src/mplhep/stylelib/*.mplstyle -recursive-include src/mplhep/fonts/ * -include LICENSE diff --git a/pyproject.toml b/pyproject.toml index 3e110979..8cf4d2da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,71 @@ [build-system] -# Minimum requirements for the build system (setup.py) to execute. -requires = ["setuptools>=64", "setuptools_scm>=8"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" +[project] +name = "mplhep" +dynamic = ["version"] +description = "Matplotlib styles for HEP" +readme = "README.md" +license = "MIT" +requires-python = ">=3.8" +authors = [ + { name = "andrzejnovak", email = "\"novak5andrzej@gmail.com\"" }, +] +classifiers = [ + "Framework :: Matplotlib", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering :: Physics", +] +dependencies = [ + "matplotlib>=3.4", + "mplhep-data", + "numpy>=1.16.0", + "packaging", + "uhi>=0.2.0", +] -[tool.setuptools_scm] -write_to = "src/mplhep/_version.py" +[project.optional-dependencies] +dev = [ + "black", + "bumpversion", + "flake8", + "jupyter", + "pre-commit", + "twine", +] +test = [ + "boost_histogram", + "hist", + "nteract-scrapbook~=0.3", + "papermill~=1.0", + "pytest-mock", + "pytest-mpl", + "pytest>=6.0", + "scikit-hep-testdata", + "scipy>=1.1.0", + "uproot", + "uproot4", +] +all = [ + "mplhep[dev,test]", +] + +[project.urls] +Homepage = "https://github.com/scikit-hep/mplhep" + + +[tool.hatch] +version.source = "vcs" +build.hooks.vcs.version-file = "src/mplhep/_version.py" [tool.nbqa.mutate] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 70cec8f9..00000000 --- a/setup.cfg +++ /dev/null @@ -1,45 +0,0 @@ -[metadata] -name = mplhep -description = Matplotlib styles for HEP -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/scikit-hep/mplhep -author = andrzejnovak -author_email = "novak5andrzej@gmail.com" -maintainer = Scikit-HEP -maintainer_email = scikit-hep-admins@googlegroups.com -license = MIT -license_files = LICENSE -classifiers = - Framework :: Matplotlib - Intended Audience :: Science/Research - License :: OSI Approved :: MIT License - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Topic :: Scientific/Engineering :: Physics - -[options] -packages = find: -install_requires = - matplotlib>=3.4 - mplhep-data - numpy>=1.16.0 - packaging - uhi>=0.2.0 -python_requires = >=3.8 -include_package_data = True -package_dir = - =src -zip_safe = False - -[options.packages.find] -where = src - -[flake8] -select = B,C,E,F,W,T4,B9 -extend-ignore = B950, W503, E501, E203, B905 diff --git a/setup.py b/setup.py deleted file mode 100644 index ec5bc6d7..00000000 --- a/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -from __future__ import annotations - -import setuptools_scm # noqa: F401 -from setuptools import setup - -extras_require = { - "test": [ - "scipy>=1.1.0", - "pytest>=6.0", - "pytest-mpl", - "pytest-mock", - "papermill~=1.0", - "nteract-scrapbook~=0.3", - "uproot", - "uproot4", - "boost_histogram", - "hist", - "scikit-hep-testdata", - ], - "dev": ["flake8", "jupyter", "bumpversion", "twine", "black", "pre-commit"], -} -extras_require["all"] = sorted(set(sum(extras_require.values(), []))) - - -setup( - extras_require=extras_require, -) - -# To push on pypi -# pipx run build -# pipx run twine upload dist/* diff --git a/src/mplhep/label.py b/src/mplhep/label.py index 31036173..a6206b83 100644 --- a/src/mplhep/label.py +++ b/src/mplhep/label.py @@ -139,7 +139,7 @@ def dist(tup): else: _exp_loc = 1 _formater = ax.get_yaxis().get_major_formatter() - if type(mpl.ticker.ScalarFormatter()) == type(_formater) and _exp_loc == 0: + if isinstance(_formatter, mpl.ticker.ScalarFormatter()) and _exp_loc == 0: _sci_box = pixel_to_axis( ax.get_yaxis().offsetText.get_window_extent(ax.figure.canvas.get_renderer()) )