diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c7c5a2b2e..26fff0b55 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,14 +7,12 @@ on: paths: - "docs/**" - "madminer/**" - - "setup.py" pull_request: branches: - main paths: - "docs/**" - "madminer/**" - - "setup.py" workflow_dispatch: concurrency: @@ -29,6 +27,8 @@ jobs: steps: - name: "Set up GitHub Actions" uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: "Set up Python" uses: actions/setup-python@v5 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2981dc7c7..167f8b589 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,6 +21,8 @@ jobs: steps: - name: "Set up GitHub Actions" uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: "Set up Python" uses: actions/setup-python@v5 with: diff --git a/.gitignore b/.gitignore index aa73bf13e..2a6173189 100644 --- a/.gitignore +++ b/.gitignore @@ -144,3 +144,6 @@ patches/ black.sh run_sphinx.sh publish.sh + +# version information +*_version.py diff --git a/Makefile b/Makefile index e2c6754b6..2bb5876e5 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,7 @@ -PKG_VERSION = $(shell cat VERSION) DOCS_FOLDER = "docs" SOURCE_FOLDER = "madminer" TESTS_FOLDER = "tests" - .PHONY: build build: @echo "Building package" @@ -26,7 +24,8 @@ docs: .PHONY: tag tag: @echo "Tagging current commit" - @git tag --annotate "v$(PKG_VERSION)" --message "Tag v$(PKG_VERSION)" + @git tag --annotate "v$(shell python -c 'from importlib.metadata import version; print(version("madminer"))')" \ + --message "Tag v$(shell python -c 'from importlib.metadata import version; print(version("madminer"))')" @git push --follow-tags diff --git a/VERSION b/VERSION deleted file mode 100644 index 85b7c695b..000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.9.6 diff --git a/docs/conf.py b/docs/conf.py index 7600b0260..233ca62d8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,19 +16,21 @@ # sys.path.insert(0, os.path.abspath('.')) from pathlib import Path +import importlib.metadata # -- Project information ----------------------------------------------------- -project_folder = Path(__file__).parent.parent -version_file = project_folder.joinpath("VERSION") - project = 'MadMiner' authors = 'Johann Brehmer, Felix Kling, Irina Espejo, Sinclert Perez, Kyle Cranmer' -version = open(version_file).read().strip() copyright = '{} 2018-2020'.format(authors) -# The full version, including alpha/beta/rc tags -release = version +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# The full version, including alpha/beta/rc tags. +release = importlib.metadata.version("madminer") +# for example take major/minor/patch +version = ".".join(release.split(".")[:3]) # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index c30595caf..cb060aa0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,21 +1,118 @@ -# Black formatting options +[build-system] +requires = [ + "hatchling>=1.13.0", + "hatch-vcs>=0.3.0", +] +build-backend = "hatchling.build" + +[project] +name = "madminer" +dynamic = ["version"] +description = "Mining gold from MadGraph to improve limit setting in particle physics" +readme = "README.md" +license = { text = "MIT" } # SPDX short identifier +requires-python = ">=3.8" +authors = [ + { name = "Johann Brehmer", email = "johann.brehmer@nyu.edu" }, + { name = "Felix Kling" }, + { name = "Irina Espejo" }, + { name = "Sinclert Perez" }, + { name = "Kyle Cranmer", email = "kyle.cranmer@wisc.edu" }, +] +maintainers = [ {name = "Matthew Feickert", email = "matthew.feickert@cern.ch"} ] +keywords = [ + "physics", + "simulation based inference", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "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 = [ + "h5py", + "matplotlib>=2.0.0", + "particle>=0.16.0", + "scipy>=1.0.0", + "sympy>=0.7.4", + "torch>=1.0.0", + "uproot>=4.0.0", + "vector>=0.8.4", + "numpy", # compatible versions controlled through scipy +] + +[project.urls] +Documentation = "https://madminer.readthedocs.io/" +Homepage = "https://github.com/madminer-tool/madminer" +"Issue Tracker" = "https://github.com/madminer-tool/madminer/issues" +"Releases" = "https://github.com/madminer-tool/madminer/releases" +"Source Code" = "https://github.com/madminer-tool/madminer" + +[project.optional-dependencies] +examples = [ + "bqplot", + "pandas", +] + +# Developer extras +lint = [ + "black[jupyter]", + "isort", +] +test = [ + "pytest>=6.0", +] +docs = [ + "myst-parser", + "numpydoc", + "sphinx>=7.0.0", + "sphinx-rtd-theme>=1.3.0", +] + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.version.raw-options] +local_scheme = "no-local-version" + +[tool.hatch.build.hooks.vcs] +version-file = "madminer/_version.py" + +[tool.hatch.build.targets.sdist] +# hatchling always includes: +# pyproject.toml, .gitignore, any README, any LICENSE, AUTHORS +only-include = [ + "/madminer", + "/CITATION.cff" +] + +[tool.hatch.build.targets.wheel] +packages = ["madminer"] + [tool.black] line-length = 120 target-version = ['py38', 'py39', 'py310'] -include = '(\.py$|\.ipynb$)' +include = '(\.pyi?$|\.ipynb$)' exclude = ''' ( \.eggs | \.git - | \.hg | \.mypy_cache | \.tox + | \.nox | \.venv - | _build - | buck-out | build | dist - | mg_processes ) ''' @@ -24,3 +121,16 @@ force_single_line = true ignore_whitespace = true only_sections = true profile = "black" + +[tool.coverage.run] +source = ["madminer"] +branch = true +omit = ["*/madminer/typing.py"] + +[tool.coverage.report] +precision = 1 +sort = "cover" +show_missing = true +exclude_also = [ + "if TYPE_CHECKING:" +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0c596ffb2..000000000 --- a/setup.cfg +++ /dev/null @@ -1,56 +0,0 @@ -[metadata] -name = madminer -version = file: VERSION -url = https://github.com/madminer-tool/madminer -description = Mining gold from MadGraph to improve limit setting in particle physics. -long_description = file: README.md -long_description_content_type = text/markdown -author = Johann Brehmer, Felix Kling, Irina Espejo, Sinclert Perez, Kyle Cranmer -author_email = johann.brehmer@nyu.edu -license = MIT -project_urls = - Documentation = https://madminer.readthedocs.io/en/latest/ - Source Code = https://github.com/madminer-tool/madminer - Issue Tracker = https://github.com/madminer-tool/madminer/issues -classifiers = - License :: OSI Approved :: MIT License - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Physics - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - -[options] -packages = find: -python_requires = >=3.8 -install_requires = - h5py - matplotlib>=2.0.0 - numpy>=1.20.0 - particle>=0.16.0 - scipy>=1.0.0 - torch>=1.0.0 - uproot>=4.0.0 - vector>=0.8.4 - sympy>=0.7.4 - -[options.packages.find] -exclude = - tests - -[options.extras_require] -docs = - myst-parser - numpydoc - sphinx>=1.4 - sphinx_rtd_theme -lint = - black[jupyter]==23.1.0 - isort==5.11.3 -test = - pytest -examples = - bqplot - pandas