Skip to content

Commit

Permalink
build: Use hatchling as build backend (#475)
Browse files Browse the repository at this point in the history
* Migrate to using hatchling as the build backend.
   - Include all build metadata in pyproject.toml.
   - Remove setup.py, setup.cfg, and MANIFEST.in.
   - Remove package_data as not needed.
* Add .flake8 as flake8 won't support pyproject.toml.
* ci: Remove MANIFEST check from CI
* Remove check-manifest install in CI workflow.
  • Loading branch information
matthewfeickert authored Nov 7, 2024
1 parent 8f78894 commit 5f96224
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 139 deletions.
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/ .
Expand Down
13 changes: 0 additions & 13 deletions MANIFEST.in

This file was deleted.

126 changes: 124 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
]
maintainers = [ {name = "The Scikit-HEP admins", email = "[email protected]"} ]
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']
Expand All @@ -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
Expand Down
78 changes: 0 additions & 78 deletions setup.cfg

This file was deleted.

40 changes: 0 additions & 40 deletions setup.py

This file was deleted.

0 comments on commit 5f96224

Please sign in to comment.