diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..b715b127 --- /dev/null +++ b/.flake8 @@ -0,0 +1,13 @@ +[flake8] +max-complexity = 18 +max-line-length = 88 +exclude = docs/conf.py +count = True +statistics = True +import-order-style = google +application-import-names = cabinetry, utils +# ignore whitespace before ':' +extend-ignore = E203 +# ignore print statements in example +per-file-ignores = + example.py: T diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 0ee3af78..4ab664e9 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -24,16 +24,12 @@ jobs: with: python-version: '3.x' - - name: Install python-build, check-manifest, and twine + - name: Install python-build and twine run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install build check-manifest twine + python -m pip install build twine python -m pip list - - name: Check MANIFEST - run: | - check-manifest --verbose - - name: Build a wheel and a sdist run: | python -m build --outdir dist/ . diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index dcd2caff..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,13 +0,0 @@ -prune ** -graft src -graft tests -graft utils - -include setup.py -include setup.cfg -include LICENSE -include README.md -include pyproject.toml -include MANIFEST.in - -global-exclude __pycache__ *.py[cod] *.png *.root diff --git a/pyproject.toml b/pyproject.toml index c1f2fc10..d4d22bb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,115 @@ [build-system] -requires = ["setuptools>=42"] -build-backend = "setuptools.build_meta" +requires = [ + "hatchling>=1.13.0", +] +build-backend = "hatchling.build" + +[project] +name = "cabinetry" +version = "0.6.0" +description = "design and steer profile likelihood fits" +readme = "README.md" +license = { text = "BSD-3-Clause" } # SPDX short identifier +requires-python = ">=3.8" +authors = [ + { name = "Alexander Held", email = "alexander.held@cern.ch" }, +] +maintainers = [ {name = "The Scikit-HEP admins", email = "scikit-hep-admins@googlegroups.com"} ] +keywords = [ + "fitting", + "physics", + "profile likelihood", +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD 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", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Physics", +] +dependencies = [ + "pyhf[minuit]~=0.7.0", # model.config.suggested_fixed / .par_names API changes, set_poi(None) + "boost_histogram>=1.0.0", # subclassing with family, 1.02 for stdev scaling fix (currently not needed) + "hist>=2.5.0", # hist.intervals.poisson_interval + "tabulate>=0.8.1", # multiline text + "matplotlib>=3.5.0", # layout kwarg for subplots + # below are direct dependencies of cabinetry, which are also included via pyhf[iminuit] + "numpy", + "pyyaml", + "iminuit", + "jsonschema", + "click", + "scipy", + "packaging", # for version parsing +] + +[project.scripts] +cabinetry = "cabinetry.cli:cabinetry" + +[project.urls] +Documentation = "https://cabinetry.readthedocs.io/" +Homepage = "https://github.com/scikit-hep/cabinetry" +"Issue Tracker" = "https://github.com/scikit-hep/cabinetry/issues" +"Releases" = "https://github.com/scikit-hep/cabinetry/releases" +"Source Code" = "https://github.com/scikit-hep/cabinetry" + +[project.optional-dependencies] +contrib = ["uproot>=4.1.5"] # file writing bug-fixes +pyhf_backends = ["pyhf[backends]"] + +# Developer extras +test = [ + "cabinetry[contrib]", + "pytest", + "pytest-cov>=2.6.1", # no_cover support + "pydocstyle", + "check-manifest", + "flake8", + "flake8-bugbear", + "flake8-import-order", + "flake8-print", + "mypy", + "types-tabulate", + "types-PyYAML", + "typeguard>=4.0.0", # cabinetry#391 + "black", +] +docs = [ + "sphinx!=5.2.0.post0", # broken due to version parsing in RTD theme + "sphinx-click", + "sphinx-copybutton", + "sphinx-jsonschema", + "sphinx-rtd-theme>=1.2", # Sphinx 7 compatibility +] +develop = [ + "cabinetry[test,docs]", + "pre-commit", + "twine", +] +complete = [ + "cabinetry[develop]", + "cabinetry[pyhf_backends]", +] + +[tool.hatch.build.targets.sdist] +# hatchling always includes: +# pyproject.toml, .gitignore, any README, any LICENSE, AUTHORS +only-include = [ + "/src", + "/tests", + "/utils", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/cabinetry"] [tool.black] target-version = ['py38'] @@ -13,6 +122,19 @@ exclude = ''' )/ ''' +[tool.pytest.ini_options] +# running typeguard can result in lower coverage https://github.com/agronholm/typeguard/issues/356 +addopts = "--cov=cabinetry --cov-report html --cov-report term-missing --cov-branch -rsx --typeguard-packages=cabinetry" + +[tool.pytype] +inputs = "src/cabinetry" + +[tool.pydocstyle] +# configuration duplicated in pre-commit config +match = "(?!setup|example).*\\.py" +match_dir = "^(?!(tests|utils|docs)).*" +convention = "google" + [tool.mypy] files = "src/cabinetry" pretty = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 6abee1ab..00000000 --- a/setup.cfg +++ /dev/null @@ -1,78 +0,0 @@ -[metadata] -name = cabinetry -version = 0.6.0 -author = Alexander Held -description = design and steer profile likelihood fits -long_description = file: README.md -long_description_content_type = text/markdown -license = BSD 3-Clause -license_files = LICENSE -url = https://github.com/scikit-hep/cabinetry -classifiers = - Development Status :: 3 - Alpha - 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 - License :: OSI Approved :: BSD License - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Physics - -[options] -packages = find: -package_dir = =src -python_requires = >=3.8 -install_requires = - pyhf[minuit]~=0.7.0 # model.config.suggested_fixed / .par_names API changes, set_poi(None) - boost_histogram>=1.0.0 # subclassing with family, 1.02 for stdev scaling fix (currently not needed) - hist>=2.5.0 # hist.intervals.poisson_interval - tabulate>=0.8.1 # multiline text - matplotlib>=3.5.0 # layout kwarg for subplots - # below are direct dependencies of cabinetry, which are also included via pyhf[iminuit] - numpy - pyyaml - iminuit - jsonschema - click - scipy - packaging # for version parsing - -[options.packages.find] -where = src - -[options.package_data] -cabinetry = - py.typed - schemas/config.json - -[options.entry_points] -console_scripts = - cabinetry = cabinetry.cli:cabinetry - -[tool:pytest] -# running typeguard can result in lower coverage https://github.com/agronholm/typeguard/issues/356 -addopts = --cov=cabinetry --cov-report html --cov-report term-missing --cov-branch -rsx --typeguard-packages=cabinetry - -[flake8] -max-complexity = 18 -max-line-length = 88 -exclude = docs/conf.py -count = True -statistics = True -import-order-style = google -application-import-names = cabinetry, utils -# ignore whitespace before ':' -extend-ignore = E203 -# ignore print statements in example -per-file-ignores = - example.py: T - -[pytype] -inputs = src/cabinetry - -[pydocstyle] -# configuration duplicated in pre-commit config -match = (?!setup|example).*\.py -match_dir = ^(?!(tests|utils|docs)).* -convention = google diff --git a/setup.py b/setup.py deleted file mode 100644 index 8f2af5d9..00000000 --- a/setup.py +++ /dev/null @@ -1,40 +0,0 @@ -from setuptools import setup - -extras_require = {"contrib": ["uproot>=4.1.5"]} # file writing bug-fixes -extras_require["test"] = sorted( - set( - extras_require["contrib"] - + [ - "pytest", - "pytest-cov>=2.6.1", # no_cover support - "pydocstyle", - "check-manifest", - "flake8", - "flake8-bugbear", - "flake8-import-order", - "flake8-print", - "mypy", - "types-tabulate", - "types-PyYAML", - "typeguard>=4.0.0", # cabinetry#391 - "black", - ] - ) -) -extras_require["pyhf_backends"] = ["pyhf[backends]"] -extras_require["docs"] = sorted( - { - "sphinx!=5.2.0.post0", # broken due to version parsing in RTD theme - "sphinx-click", - "sphinx-copybutton", - "sphinx-jsonschema", - "sphinx-rtd-theme>=1.2", # Sphinx 7 compatibility - } -) - -extras_require["develop"] = sorted( - set(extras_require["test"] + extras_require["docs"] + ["pre-commit", "twine"]) -) -extras_require["complete"] = sorted(set(sum(extras_require.values(), []))) - -setup(extras_require=extras_require)