peterridolfi / Pyhf-to-Combine-converter

Tool to convert models from pyhf to CMS Combine and vise versa
MIT License
7 stars 1 forks source link

Project metadata not getting picked up fully and install lacking file #6

Closed matthewfeickert closed 2 years ago

matthewfeickert commented 2 years ago

In release v0.0.2 some of the project metadata

https://github.com/peterridolfi/Pyhf-to-Combine-converter/blob/2d154ad73ab460b8a6b7512f1cc8df5fb102ff0a/pyproject.toml#L11-L30

https://github.com/peterridolfi/Pyhf-to-Combine-converter/blob/2d154ad73ab460b8a6b7512f1cc8df5fb102ff0a/pyproject.toml#L34-L36

isn't getting picked up properly during hatchling's build.

Example: Homepage is empty

$ docker run --rm -ti python:3.10 /bin/bash
root@f8b394a8b771:/# python -m venv venv && . venv/bin/activate
(venv) root@f8b394a8b771:/# python -m pip --quiet install --upgrade pip wheel
(venv) root@f8b394a8b771:/# git clone --quiet https://github.com/peterridolfi/Pyhf-to-Combine-converter.git
(venv) root@f8b394a8b771:/# cd Pyhf-to-Combine-converter
(venv) root@f8b394a8b771:/Pyhf-to-Combine-converter# git reset --hard 2d154ad73ab460b8a6b7512f1cc8df5fb102ff0a
HEAD is now at 2d154ad added src/ to package build
(venv) root@f8b394a8b771:/Pyhf-to-Combine-converter# python -m pip --quiet install build
(venv) root@f8b394a8b771:/Pyhf-to-Combine-converter# python -m build .
* Creating venv isolated environment...
* Installing packages in isolated environment... (hatch-vcs, hatchling)
* Getting dependencies for sdist...
* Building sdist...
* Building wheel from sdist
* Creating venv isolated environment...
* Installing packages in isolated environment... (hatch-vcs, hatchling)
* Getting dependencies for wheel...
* Building wheel...
Successfully built pyhf_combine_converter-0.0.2.tar.gz and pyhf_combine_converter-0.0.2-py3-none-any.whl
(venv) root@f8b394a8b771:/Pyhf-to-Combine-converter# python -m pip install ./dist/pyhf_combine_converter-0.0.2-py3-none-any.whl
(venv) root@f8b394a8b771:/Pyhf-to-Combine-converter# python -m pip show pyhf_combine_converter
Name: pyhf_combine_converter
Version: 0.0.2
Summary: A package to translate between pyhf and Combine models
Home-page: 
Author: 
Author-email: Peter Ridolfi <petey.ridolfi7@gmail.com>
License: MIT License

        Copyright (c) 2022 Peter Bruce Ridolfi

        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:

        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.

        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Location: /venv/lib/python3.10/site-packages
Requires: hist, pyhf, uproot
Required-by: 
(venv) root@f8b394a8b771:/Pyhf-to-Combine-converter# python -m pip show pyhf  # For comparison
Name: pyhf
Version: 0.6.3
Summary: pure-Python HistFactory implementation with tensors and autodiff
Home-page: 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
Location: /venv/lib/python3.10/site-packages
Requires: click, jsonpatch, jsonschema, pyyaml, scipy, tqdm
Required-by: pyhf_combine_converter

More importantly, the install of the wheel isn't actually installing any files

(venv) root@f8b394a8b771:/Pyhf-to-Combine-converter# find /venv/lib/python3.10/site-packages/ -type d -iname "pyhf_combine_converter*"  # no pyhf_combine_converter directory
/venv/lib/python3.10/site-packages/pyhf_combine_converter-0.0.2.dist-info
(venv) root@f8b394a8b771:/Pyhf-to-Combine-converter# find /venv/lib/python3.10/site-packages/ -type d -iname "pyhf*"  # for comparison
/venv/lib/python3.10/site-packages/pyhf-0.6.3.dist-info
/venv/lib/python3.10/site-packages/pyhf
/venv/lib/python3.10/site-packages/pyhf_combine_converter-0.0.2.dist-info
matthewfeickert commented 2 years ago

I'm going to tag @henryiii and @agoose77 as they both have more experience with hatchling then @alexander-held or I do.

(Henry, Angus, not sure if there is a way to avoid the annoying print of the entire LICENSE either — that would be terrible for something like pyhf that uses Apache 2.0).

kratsg commented 2 years ago

You probably need to file an issue with the hatch developers as I see similar problems in mapyde and that uses the scikit-hep cookiecutter repository

$ python -m pip show mapyde
Name: mapyde
Version: 0.2.3
Summary: Generation, simulation, analysis, and statistical inference in one go.
Home-page: 
Author: 
Author-email: Giordon Stark <kratsg@gmail.com>
License: 
Location: /Users/kratsg/mario-mapyde/venv/lib/python3.9/site-packages
Requires: in-place, jinja2, toml, typer
Required-by: 

where our pyproject.toml follows the guidelines for sure in the hatch metadata documentation.

I think the home-page is project.url for pyproject.toml, as the other project URLs are typically picked up by pypi (https://pypi.org/project/mapyde/).

henryiii commented 2 years ago

Homepage is supposed to be empty, it's been deprecated as "redundant and confusing" as part of PEP 621. Same thing with Author if Author-email is filled.

As to why there are no files, there is no package in this repo. If you look inside src, you'll see there are just some random files, including __init__.py. This would be terrible, as it would install to site-packages/__init__.py (and only one package could do that before you'd have conflicts). But hatchling will refuse to pick it up. You need to make a package out of it:

mkdir src/pyhf_to_combine_converter
mv src/* src/pyhf_to_combine_converter/.
matthewfeickert commented 2 years ago

Homepage is supposed to be empty, it's been deprecated as "redundant and confusing" as part of PEP 621. Same thing with Author if Author-email is filled.

Ah interesting. Good to know for the future.

As to why there are no files, there is no package in this repo. If you look inside src, you'll see there are just some random files, including __init__.py. This would be terrible, as it would install to site-packages/__init__.py (and only one package could do that before you'd have conflicts). But hatchling will refuse to pick it up. You need to make a package out of it:

mkdir src/pyhf_to_combine_converter
mv src/* src/pyhf_to_combine_converter/.

Whoops yeah that would indeed do it. I should have checked that things were packaged before filing this. @peterridolfi, @henryiii's suggestions will definitely work, so please update the directory layout for this (though as this is under version control use git mv).

As you were following the https://packaging.python.org/en/latest/tutorials/packaging-projects/ that Henry and I have both made contributions to if you let us know later on what parts were unclear I can see if there might be some slight revisions to the text that may warrant a PR to https://github.com/pypa/packaging.python.org