Skip to content

Commit 14127ae

Browse files
matthewfeickertagoose77ofek
authored
build: Switch to using Hatchling as build backend (#2095)
* Migrate build system to Hatchling and add Hatch configuration in pyproject.toml. - Use pip v21.2+'s ability to handle recursive dependencies to define nested extras. c.f. https://hynek.me/articles/python-recursive-optional-dependencies/ - Use hatch-vcs to dynamically determine the version information from Git. - Use 'only-include' option with `[tool.hatch.build.targets.sdist]` to avoid problem with hatchling discovering the symlink of src/pyhf/schemas under docs/ before src/ and skipping including it in the sdist. c.f. #791 and pypa/hatch#276 * Remove all setuptools related files: setup.py, setup.cfg, MANIFEST.in. * Add .flake8 config file as the config for flake8 had previously been in setup.cfg as flake8 doesn't support pyproject.toml. * Remove use of check-manifest from packaging GitHub Actions workflow. * Remove mention of setup.cfg from release checklist. * Add Scikit-HEP admins info to maintainers metadata. Co-authored-by: Angus Hollands <goosey15@gmail.com> Co-authored-by: Ofek Lev <oss@ofek.dev>
1 parent 3eef1ff commit 14127ae

File tree

7 files changed

+152
-189
lines changed

7 files changed

+152
-189
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
# E203: whitespace before ':'
3+
# E402: module level import not at top of file
4+
# E501: line too long
5+
extend-ignore = E203, E402, E501
6+
max-line-length = 88

.github/ISSUE_TEMPLATE/~release-checklist.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ about: Checklist for core developers to complete as part of making a release
3232
* [ ] Verify that a Binder has properly built for the new release.
3333
* [ ] Watch for a GitHub notification that there is an automatic PR to the [Conda-forge feedstock](https://github.com/conda-forge/pyhf-feedstock). This may take multiple hours to happen. If there are any changes needed to the Conda-forge release make them **from a personal account** and not from an organization account to have workflows properly trigger.
3434
- [ ] Check if any requirements need to be updated by commenting "@conda-grayskull show requirements" on the PR.
35-
- [ ] Verify the requirements in the [Conda-forge feedstock](https://github.com/conda-forge/pyhf-feedstock) recipe `meta.yaml` match those in `setup.cfg` and `pyproject.toml`.
35+
- [ ] Verify the requirements in the [Conda-forge feedstock](https://github.com/conda-forge/pyhf-feedstock) recipe `meta.yaml` match those in `pyproject.toml`.
3636

3737
## After Release
3838

.github/workflows/publish-package.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,12 @@ jobs:
3737
with:
3838
python-version: '3.10'
3939

40-
- name: Install python-build, check-manifest, and twine
40+
- name: Install python-build and twine
4141
run: |
42-
python -m pip install --upgrade pip setuptools wheel
43-
python -m pip install build check-manifest twine
42+
python -m pip install --upgrade pip
43+
python -m pip install build twine
4444
python -m pip list
4545
46-
- name: Check MANIFEST
47-
run: |
48-
check-manifest
49-
5046
- name: Build a wheel and a sdist
5147
run: |
5248
PYTHONWARNINGS=error,default::DeprecationWarning python -m build .

MANIFEST.in

Lines changed: 0 additions & 13 deletions
This file was deleted.

pyproject.toml

Lines changed: 142 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,149 @@
11
[build-system]
2-
# Minimum requirements for the build system to execute.
3-
requires = ["setuptools>=61.0.0", "setuptools_scm>=7.0.1"]
4-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling>=1.0.0", "hatch-vcs"]
3+
build-backend = "hatchling.build"
54

6-
[tool.setuptools_scm]
7-
write_to = "src/pyhf/_version.py"
5+
[project]
6+
name = "pyhf"
7+
dynamic = ["version"]
8+
description = "pure-Python HistFactory implementation with tensors and autodiff"
9+
readme = "README.rst"
10+
license = { text = "Apache-2.0" } # SPDX short identifier
11+
requires-python = ">=3.8"
12+
authors = [
13+
{ name = "Lukas Heinrich", email = "lukas.heinrich@cern.ch" },
14+
{ name = "Matthew Feickert", email = "matthew.feickert@cern.ch" },
15+
{ name = "Giordon Stark", email = "gstark@cern.ch" },
16+
]
17+
maintainers = [ {name = "The Scikit-HEP admins", email = "scikit-hep-admins@googlegroups.com"} ]
18+
keywords = [
19+
"fitting",
20+
"jax",
21+
"numpy",
22+
"physics",
23+
"pytorch",
24+
"scipy",
25+
"tensorflow",
26+
]
27+
classifiers = [
28+
"Development Status :: 4 - Beta",
29+
"Intended Audience :: Science/Research",
30+
"License :: OSI Approved :: Apache Software License",
31+
"Programming Language :: Python :: 3",
32+
"Programming Language :: Python :: 3 :: Only",
33+
"Programming Language :: Python :: 3.8",
34+
"Programming Language :: Python :: 3.9",
35+
"Programming Language :: Python :: 3.10",
36+
"Programming Language :: Python :: Implementation :: CPython",
37+
"Topic :: Scientific/Engineering",
38+
"Topic :: Scientific/Engineering :: Physics",
39+
]
40+
dependencies = [
41+
"click>=8.0.0", # for console scripts
42+
"importlib_resources>=1.4.0; python_version < '3.9'", # for resources in schema
43+
"jsonpatch>=1.15",
44+
"jsonschema>=4.15.0", # for utils
45+
"pyyaml>=5.1", # for parsing CLI equal-delimited options
46+
"scipy>=1.5.1", # requires numpy, which is required by pyhf and tensorflow
47+
"tqdm>=4.56.0", # for readxml
48+
"numpy", # compatible versions controlled through scipy
49+
]
50+
51+
[project.scripts]
52+
pyhf = "pyhf.cli:cli"
53+
54+
[project.urls]
55+
Documentation = "https://pyhf.readthedocs.io/"
56+
Homepage = "https://github.com/scikit-hep/pyhf"
57+
"Issue Tracker" = "https://github.com/scikit-hep/pyhf/issues"
58+
"Release Notes" = "https://pyhf.readthedocs.io/en/stable/release-notes.html"
59+
"Source Code" = "https://github.com/scikit-hep/pyhf"
60+
61+
[project.optional-dependencies]
62+
shellcomplete = ["click_completion"]
63+
tensorflow = [
64+
"tensorflow>=2.7.0", # c.f. PR #1962
65+
"tensorflow-probability>=0.11.0", # c.f. PR #1657
66+
]
67+
torch = ["torch>=1.10.0"] # c.f. PR #1657
68+
jax = [
69+
"jax>=0.4.1", # c.f. PR #2079
70+
"jaxlib>=0.4.1", # c.f. PR #2079
71+
]
72+
xmlio = ["uproot>=4.1.1"] # c.f. PR #1567
73+
minuit = ["iminuit>=2.7.0"] # c.f. PR #1895
74+
contrib = [
75+
"matplotlib>=3.0.0",
76+
"requests>=2.22.0",
77+
]
78+
backends = ["pyhf[tensorflow,torch,jax,minuit]"]
79+
all = ["pyhf[backends,xmlio,contrib,shellcomplete]"]
80+
81+
# Developer extras
82+
test = [
83+
"pyhf[all]",
84+
"scikit-hep-testdata>=0.4.11",
85+
"pytest>=6.0",
86+
"coverage[toml]>=6.0.0",
87+
"pytest-mock",
88+
"requests-mock>=1.9.0",
89+
"pytest-benchmark[histogram]",
90+
"pytest-console-scripts",
91+
"pytest-mpl",
92+
"pydocstyle",
93+
"papermill~=2.3.4",
94+
"scrapbook~=0.5.0",
95+
"jupyter",
96+
"graphviz",
97+
"pytest-socket>=0.2.0", # c.f. PR #1917
98+
]
99+
docs = [
100+
"pyhf[xmlio,contrib]",
101+
"sphinx>=5.1.1", # c.f. https://github.com/scikit-hep/pyhf/pull/1926
102+
"sphinxcontrib-bibtex~=2.1",
103+
"sphinx-click",
104+
"sphinx_rtd_theme",
105+
"nbsphinx!=0.8.8", # c.f. https://github.com/spatialaudio/nbsphinx/issues/620
106+
"ipywidgets",
107+
"sphinx-issues",
108+
"sphinx-copybutton>=0.3.2",
109+
"sphinx-togglebutton>=0.3.0",
110+
"ipython!=8.7.0", # c.f. https://github.com/scikit-hep/pyhf/pull/2068
111+
]
112+
develop = [
113+
"pyhf[test,docs]",
114+
"tbump>=6.7.0",
115+
"pre-commit",
116+
"nox",
117+
"codemetapy>=2.3.0",
118+
]
119+
120+
[tool.hatch.version]
121+
source = "vcs"
122+
123+
[tool.hatch.version.raw-options]
8124
local_scheme = "no-local-version"
9125

126+
[tool.hatch.build.hooks.vcs]
127+
version-file = "src/pyhf/_version.py"
128+
129+
[tool.hatch.build.targets.sdist]
130+
# only-include needed to properly include src/pyhf/schemas
131+
# c.f. https://github.com/pypa/hatch/pull/299
132+
only-include = [
133+
"/src",
134+
"/LICENSE",
135+
"/README.rst",
136+
"/pyproject.toml",
137+
"/AUTHORS",
138+
"/CITATION.cff"
139+
]
140+
exclude = [
141+
"/src/conftest.py"
142+
]
143+
144+
[tool.hatch.build.targets.wheel]
145+
packages = ["src/pyhf"]
146+
10147
[tool.black]
11148
line-length = 88
12149
target-version = ['py38', 'py39', 'py310']
@@ -21,24 +158,6 @@ exclude = '''
21158
)/
22159
'''
23160

24-
[tool.check-manifest]
25-
ignore = [
26-
'docs*',
27-
'validation*',
28-
'examples*',
29-
'tests*',
30-
'docker*',
31-
'binder*',
32-
'.*',
33-
'pyproject.toml',
34-
'pytest.ini',
35-
'codecov.yml',
36-
'codemeta.json',
37-
'CODE_OF_CONDUCT.md',
38-
'CONTRIBUTING.md',
39-
'AUTHORS',
40-
]
41-
42161
[tool.pytest.ini_options]
43162
minversion = "6.0"
44163
xfail_strict = true

setup.cfg

Lines changed: 0 additions & 58 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)