From 4a7191f6dc7e792c7d87b0ded7ac677229d6b55b Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Mon, 13 Jun 2022 19:59:52 +0100 Subject: [PATCH 1/4] WIP: initial commit --- MANIFEST.in | 12 -- pyproject.toml | 313 ++++++++++++++++++++++++++++++++++++++++++------- setup.cfg | 60 ---------- setup.py | 87 -------------- 4 files changed, 272 insertions(+), 200 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 18353aadb6..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,12 +0,0 @@ -prune ** -graft src - -include setup.py -include setup.cfg -include LICENSE -include README.rst -include pyproject.toml -include MANIFEST.in -include AUTHORS - -global-exclude __pycache__ *.py[cod] diff --git a/pyproject.toml b/pyproject.toml index bec9480541..6c87c8ad3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,41 +1,270 @@ [build-system] -# Minimum requirements for the build system to execute. -requires = ["setuptools>=42.0.0", "setuptools_scm[toml]>=3.4"] -build-backend = "setuptools.build_meta" +requires = [ + "hatchling>=1.3.1", + "hatch-vcs", +] +build-backend = "hatchling.build" + +[project] +name = "pyhf" +description = "pure-Python HistFactory implementation with tensors and autodiff" +readme = "README.rst" +license = { file = "LICENSE" } +requires-python = ">=3.7" +keywords = [ + "fitting", + "jax", + "numpy", + "physics", + "pytorch", + "scipy", + "tensorflow", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: 3.10", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Physics", +] +dependencies = [ + "click>=7.0", # for console scripts + "importlib_resources>=1.3.0; python_version < \"3.9\"", # for resources in schema + "jsonpatch>=1.15", + "jsonschema>=3.0.0", # for utils + "pyyaml>=5.1", # for parsing CLI equal-delimited options + "scipy>=1.1.0", # requires numpy, which is required by pyhf and tensorflow + "tqdm>=4.56.0" # for readxml +] +dynamic = [ + "version", +] +authors = [ + { name = "Lukas Heinrich", email = "lukas.heinrich@cern.ch" }, + { name = "Matthew Feickert", email = "matthew.feickert@cern.ch"}, + { name = "Giordon Stark", email = "gstark@cern.ch" } +] + +[project.optional-dependencies] +backends = [ + "iminuit>=2.4.0", + "jax>=0.2.10", + "jaxlib>=0.1.60,!=0.1.68", + "tensorflow-probability>=0.11.0", + "tensorflow>=2.6.5", + "torch>=1.10.0", +] +complete = [ + "black>=22.1.0", + "check-manifest", + "click_completion", + "codemetapy>=0.3.4", + "flake8", + "graphviz", + "iminuit>=2.4.0", + "ipython", + "ipywidgets", + "jax>=0.2.10", + "jaxlib>=0.1.60,!=0.1.68", + "jupyter", + "matplotlib", + "nbdime", + "nbsphinx!=0.8.8", + "papermill~=2.3.4", + "pre-commit", + "pydocstyle", + "pytest-benchmark[histogram]", + "pytest-console-scripts", + "pytest-cov>=2.5.1", + "pytest-mock", + "pytest-mpl", + "pytest>=6.0", + "requests", + "requests-mock>=1.9.0", + "scikit-hep-testdata>=0.4.11", + "scrapbook~=0.5.0", + "sphinx-click", + "sphinx-copybutton>=0.3.2", + "sphinx-issues", + "sphinx-togglebutton>=0.3.0", + "sphinx>=4.0.0", + "sphinx_rtd_theme", + "sphinxcontrib-bibtex~=2.1", + "tbump>=6.7.0", + "tensorflow-probability>=0.11.0", + "tensorflow>=2.6.5", + "torch>=1.10.0", + "twine", + "uproot>=4.1.1", +] +contrib = [ + "matplotlib", + "requests", +] +develop = [ + "black>=22.1.0", + "check-manifest", + "click_completion", + "codemetapy>=0.3.4", + "flake8", + "graphviz", + "iminuit>=2.4.0", + "ipython", + "ipywidgets", + "jax>=0.2.10", + "jaxlib>=0.1.60,!=0.1.68", + "jupyter", + "matplotlib", + "nbdime", + "nbsphinx!=0.8.8", + "papermill~=2.3.4", + "pre-commit", + "pydocstyle", + "pytest-benchmark[histogram]", + "pytest-console-scripts", + "pytest-cov>=2.5.1", + "pytest-mock", + "pytest-mpl", + "pytest>=6.0", + "requests", + "requests-mock>=1.9.0", + "scikit-hep-testdata>=0.4.11", + "scrapbook~=0.5.0", + "sphinx-click", + "sphinx-copybutton>=0.3.2", + "sphinx-issues", + "sphinx-togglebutton>=0.3.0", + "sphinx>=4.0.0", + "sphinx_rtd_theme", + "sphinxcontrib-bibtex~=2.1", + "tbump>=6.7.0", + "tensorflow-probability>=0.11.0", + "tensorflow>=2.6.5", + "torch>=1.10.0", + "twine", + "uproot>=4.1.1", +] +docs = [ + "ipywidgets", + "matplotlib", + "nbsphinx!=0.8.8", + "requests", + "sphinx-click", + "sphinx-copybutton>=0.3.2", + "sphinx-issues", + "sphinx-togglebutton>=0.3.0", + "sphinx>=4.0.0", + "sphinx_rtd_theme", + "sphinxcontrib-bibtex~=2.1", + "uproot>=4.1.1", +] +jax = [ + "jax>=0.2.10", + "jaxlib>=0.1.60,!=0.1.68", +] +lint = [ + "black>=22.1.0", + "flake8", +] +minuit = [ + "iminuit>=2.4.0", +] +shellcomplete = [ + "click_completion", +] +tensorflow = [ + "tensorflow-probability>=0.11.0", + "tensorflow>=2.6.5", +] +test = [ + "click_completion", + "graphviz", + "iminuit>=2.4.0", + "jax>=0.2.10", + "jaxlib>=0.1.60,!=0.1.68", + "jupyter", + "matplotlib", + "papermill~=2.3.4", + "pydocstyle", + "pytest-benchmark[histogram]", + "pytest-console-scripts", + "pytest-cov>=2.5.1", + "pytest-mock", + "pytest-mpl", + "pytest>=6.0", + "requests", + "requests-mock>=1.9.0", + "scikit-hep-testdata>=0.4.11", + "scrapbook~=0.5.0", + "tensorflow-probability>=0.11.0", + "tensorflow>=2.6.5", + "torch>=1.10.0", + "uproot>=4.1.1", +] +torch = [ + "torch>=1.10.0", +] +xmlio = [ + "uproot>=4.1.1", +] + +[project.scripts] +pyhf = "pyhf.cli:cli" + +[project.urls] +"Documentation" = "https://pyhf.readthedocs.io/" +"Homepage" = "https://github.com/scikit-hep/pyhf" +"Issue Tracker" = "https://github.com/scikit-hep/pyhf/issues" +"Release Notes" = "https://pyhf.readthedocs.io/en/stable/release-notes.html" +"Source Code" = "https://github.com/scikit-hep/pyhf" + +# Give Hatch the ability to determine the project version +[tool.hatch.version] +source = "vcs" + +# Generate _version.py at build time +[tool.hatch.build.hooks.vcs] +version-file = "src/pyhf/_version.py" + +[tool.hatch.build] +sources = [ + "src", +] -[tool.setuptools_scm] -write_to = "src/pyhf/_version.py" -local_scheme = "no-local-version" [tool.black] line-length = 88 -target-version = ['py37', 'py38'] +target-version = [ + "py37", + "py38", +] skip-string-normalization = true -include = '\.pyi?$' -exclude = ''' -/( - \.git - | .eggs - | build -)/ -''' +include = "\\.pyi?$" +exclude = "/(\n \\.git\n | .eggs\n | build\n)/\n" [tool.check-manifest] ignore = [ - 'docs*', - 'validation*', - 'examples*', - 'tests*', - 'docker*', - 'binder*', - '.*', - 'pyproject.toml', - 'pytest.ini', - 'codecov.yml', - 'codemeta.json', - 'CODE_OF_CONDUCT.md', - 'CONTRIBUTING.md', - 'AUTHORS', + "docs*", + "validation*", + "examples*", + "tests*", + "docker*", + "binder*", + ".*", + "pyproject.toml", + "pytest.ini", + "codecov.yml", + "codemeta.json", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "AUTHORS", ] [tool.pytest.ini_options] @@ -78,21 +307,23 @@ markers = [ ] filterwarnings = [ "error", - 'ignore:the imp module is deprecated:DeprecationWarning', # tensorflow - 'ignore:distutils Version classes are deprecated:DeprecationWarning', # tensorflow-probability - 'ignore:the `interpolation=` argument to percentile was renamed to `method=`, which has additional options:DeprecationWarning', # Issue #1772 - "ignore:The interpolation= argument to 'quantile' is deprecated. Use 'method=' instead:DeprecationWarning", # Issue #1772 - 'ignore: Exception ignored in:pytest.PytestUnraisableExceptionWarning', #FIXME: Exception ignored in: <_io.FileIO [closed]> - 'ignore:invalid value encountered in (true_)?divide:RuntimeWarning', #FIXME - 'ignore:invalid value encountered in add:RuntimeWarning', #FIXME - "ignore:In future, it will be an error for 'np.bool_' scalars to be interpreted as an index:DeprecationWarning", #FIXME: tests/test_tensor.py::test_pdf_eval[pytorch] - 'ignore:Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with:UserWarning', #FIXME: tests/test_optim.py::test_minimize[no_grad-scipy-pytorch-no_stitch] - 'ignore:divide by zero encountered in (true_)?divide:RuntimeWarning', #FIXME: pytest tests/test_tensor.py::test_pdf_calculations[numpy] - 'ignore:[A-Z]+ is deprecated and will be removed in Pillow 10:DeprecationWarning', # keras + "ignore:the imp module is deprecated:DeprecationWarning", + "ignore:distutils Version classes are deprecated:DeprecationWarning", + "ignore:the `interpolation=` argument to percentile was renamed to `method=`, which has additional options:DeprecationWarning", + "ignore:The interpolation= argument to 'quantile' is deprecated. Use 'method=' instead:DeprecationWarning", + "ignore: Exception ignored in:pytest.PytestUnraisableExceptionWarning", + "ignore:invalid value encountered in (true_)?divide:RuntimeWarning", + "ignore:invalid value encountered in add:RuntimeWarning", + "ignore:In future, it will be an error for 'np.bool_' scalars to be interpreted as an index:DeprecationWarning", + "ignore:Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with:UserWarning", + "ignore:divide by zero encountered in (true_)?divide:RuntimeWarning", + "ignore:[A-Z]+ is deprecated and will be removed in Pillow 10:DeprecationWarning", ] [tool.nbqa.mutate] pyupgrade = 1 [tool.nbqa.addopts] -pyupgrade = ["--py37-plus"] +pyupgrade = [ + "--py37-plus", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index dbe241c62f..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,60 +0,0 @@ -[metadata] -name = pyhf -description = pure-Python HistFactory implementation with tensors and autodiff -long_description = file: README.rst -long_description_content_type = text/x-rst -url = https://github.com/scikit-hep/pyhf -author = Lukas Heinrich, Matthew Feickert, Giordon Stark -author_email = lukas.heinrich@cern.ch, matthew.feickert@cern.ch, gstark@cern.ch -license = Apache -license_files = LICENSE -keywords = physics fitting numpy scipy tensorflow pytorch jax -project_urls = - Documentation = https://pyhf.readthedocs.io/ - Source Code = https://github.com/scikit-hep/pyhf - Issue Tracker = https://github.com/scikit-hep/pyhf/issues - Release Notes = https://pyhf.readthedocs.io/en/stable/release-notes.html -classifiers = - Development Status :: 4 - Beta - License :: OSI Approved :: Apache Software License - Intended Audience :: Science/Research - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Physics - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: Implementation :: CPython - -[options] -packages = find_namespace: -package_dir = - = src -include_package_data = True -python_requires = >=3.7 -install_requires = - scipy>=1.1.0 # requires numpy, which is required by pyhf and tensorflow - click>=7.0 # for console scripts - tqdm>=4.56.0 # for readxml - jsonschema>=3.0.0 # for utils - jsonpatch>=1.15 - pyyaml>=5.1 # for parsing CLI equal-delimited options - importlib_resources>=1.3.0; python_version < "3.9" # for resources in schema - -[options.packages.find] -where = src - -[options.entry_points] -console_scripts = - pyhf = pyhf.cli:cli - -[flake8] -# E203: whitespace before ':' -# E402: module level import not at top of file -# E501: line too long -extend-ignore = E203, E402, E501 -max-line-length = 88 -count = True -statistics = True diff --git a/setup.py b/setup.py deleted file mode 100644 index f989157df6..0000000000 --- a/setup.py +++ /dev/null @@ -1,87 +0,0 @@ -from setuptools import setup - -extras_require = { - 'shellcomplete': ['click_completion'], - 'tensorflow': [ - 'tensorflow>=2.6.5', # c.f. PR #1874 - 'tensorflow-probability>=0.11.0', # c.f. PR #1657 - ], - 'torch': ['torch>=1.10.0'], # c.f. PR #1657 - 'jax': ['jax>=0.2.10', 'jaxlib>=0.1.60,!=0.1.68'], # c.f. Issue 1501 - 'xmlio': ['uproot>=4.1.1'], # c.f. PR #1567 - 'minuit': ['iminuit>=2.4.0'], # c.f. PR #1306 -} -extras_require['backends'] = sorted( - set( - extras_require['tensorflow'] - + extras_require['torch'] - + extras_require['jax'] - + extras_require['minuit'] - ) -) -extras_require['contrib'] = sorted({'matplotlib', 'requests'}) -extras_require['lint'] = sorted({'flake8', 'black>=22.1.0'}) - -extras_require['test'] = sorted( - set( - extras_require['backends'] - + extras_require['xmlio'] - + extras_require['contrib'] - + extras_require['shellcomplete'] - + [ - 'scikit-hep-testdata>=0.4.11', - 'pytest>=6.0', - 'pytest-cov>=2.5.1', - 'pytest-mock', - 'requests-mock>=1.9.0', - 'pytest-benchmark[histogram]', - 'pytest-console-scripts', - 'pytest-mpl', - 'pydocstyle', - 'papermill~=2.3.4', - 'scrapbook~=0.5.0', - 'jupyter', - 'graphviz', - ] - ) -) -extras_require['docs'] = sorted( - set( - extras_require['xmlio'] - + extras_require['contrib'] - + [ - 'sphinx>=4.0.0', - 'sphinxcontrib-bibtex~=2.1', - 'sphinx-click', - 'sphinx_rtd_theme', - 'nbsphinx!=0.8.8', # c.f. https://github.com/spatialaudio/nbsphinx/issues/620 - 'ipywidgets', - 'sphinx-issues', - 'sphinx-copybutton>=0.3.2', - 'sphinx-togglebutton>=0.3.0', - ] - ) -) -extras_require['develop'] = sorted( - set( - extras_require['docs'] - + extras_require['lint'] - + extras_require['test'] - + [ - 'nbdime', - 'tbump>=6.7.0', - 'ipython', - 'pre-commit', - 'check-manifest', - 'codemetapy>=0.3.4', - 'twine', - ] - ) -) -extras_require['complete'] = sorted(set(sum(extras_require.values(), []))) - - -setup( - extras_require=extras_require, - use_scm_version=lambda: {'local_scheme': lambda version: ''}, -) From 22c455febf85db644e5899b0a4479661263545b3 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Mon, 13 Jun 2022 20:50:17 +0100 Subject: [PATCH 2/4] Fix: use packages --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6c87c8ad3e..ed342f93ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -234,8 +234,8 @@ source = "vcs" version-file = "src/pyhf/_version.py" [tool.hatch.build] -sources = [ - "src", +packages = [ + "src/pyhf" ] From d4d8a26556b03d9c1424266b31456d5950bb0cba Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Mon, 13 Jun 2022 20:51:42 +0100 Subject: [PATCH 3/4] Chore: remove check-manifest (no longer needed) --- .github/workflows/publish-package.yml | 8 ++------ pyproject.toml | 19 ------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index b50a02cf61..c3336013a2 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -35,16 +35,12 @@ jobs: with: python-version: '3.10' - - 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 - - name: Build a wheel and a sdist run: | python -m build --outdir dist/ . diff --git a/pyproject.toml b/pyproject.toml index ed342f93ec..0107262f5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,6 @@ backends = [ ] complete = [ "black>=22.1.0", - "check-manifest", "click_completion", "codemetapy>=0.3.4", "flake8", @@ -110,7 +109,6 @@ contrib = [ ] develop = [ "black>=22.1.0", - "check-manifest", "click_completion", "codemetapy>=0.3.4", "flake8", @@ -249,23 +247,6 @@ skip-string-normalization = true include = "\\.pyi?$" exclude = "/(\n \\.git\n | .eggs\n | build\n)/\n" -[tool.check-manifest] -ignore = [ - "docs*", - "validation*", - "examples*", - "tests*", - "docker*", - "binder*", - ".*", - "pyproject.toml", - "pytest.ini", - "codecov.yml", - "codemeta.json", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.md", - "AUTHORS", -] [tool.pytest.ini_options] minversion = "6.0" From 5d463b676e92568957203b2239626290e78a2f72 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 19:54:40 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0107262f5b..f2210ce728 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ dynamic = [ ] authors = [ { name = "Lukas Heinrich", email = "lukas.heinrich@cern.ch" }, - { name = "Matthew Feickert", email = "matthew.feickert@cern.ch"}, + { name = "Matthew Feickert", email = "matthew.feickert@cern.ch"}, { name = "Giordon Stark", email = "gstark@cern.ch" } ]