scikit-hep / hist

Histogramming for analysis powered by boost-histogram
https://hist.readthedocs.io
BSD 3-Clause "New" or "Revised" License
123 stars 23 forks source link

[BUG] defaulting to use of release candidate numpy on Python 3.12 #570

Closed matthewfeickert closed 1 month ago

matthewfeickert commented 1 month ago

Describe the bug

This might not really be a "bug", but it is different from the expected user experience.

hist v2.7.2 has different NumPy requirements between Python 3.12 and older Pythons

https://github.com/scikit-hep/hist/blob/8ab95946809e8195fcbecc7cc398738af1d2267d/pyproject.toml#L41-L42

For Python 3.12, the numpy>=1.26.0b1 means that using pip's default upgrade strategy, this will also pick up release candidates, which might not be desirable (c.f. https://github.com/scikit-hep/cabinetry/pull/477)

$ docker run --rm -ti python:3.12 /bin/bash
root@b825552eb42f:/# python -m venv venv && . venv/bin/activate
(venv) root@b825552eb42f:/# python -m pip --quiet install --upgrade pip wheel
(venv) root@b825552eb42f:/# python -m pip install 'numpy>=1.26.0b1'
Collecting numpy>=1.26.0b1
  Downloading numpy-2.0.0rc2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.9/60.9 kB 1.0 MB/s eta 0:00:00
Downloading numpy-2.0.0rc2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.0/19.0 MB 51.5 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-2.0.0rc2
(venv) root@b825552eb42f:/#

This was fixed in https://github.com/scikit-hep/hist/pull/543 with the move to

https://github.com/scikit-hep/hist/blob/9c3a275ff3f614d5ea201149b7851905a4c2e8b4/pyproject.toml#L41

but there hasn't been a release since then. A new release would resolve this issue, without users needing to explicitly guard against release candidates.

Steps to reproduce

$ docker run --rm -ti python:3.12 /bin/bash
root@ae8245ca153b:/# python -m venv venv && . venv/bin/activate
(venv) root@ae8245ca153b:/# python -m pip --quiet install --upgrade pip wheel
(venv) root@ae8245ca153b:/# python -m pip install --upgrade hist
Collecting hist
  Downloading hist-2.7.2-py3-none-any.whl.metadata (17 kB)
Collecting boost-histogram<1.5,>=1.3.1 (from hist)
  Downloading boost_histogram-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (25 kB)
Collecting histoprint>=2.2.0 (from hist)
  Downloading histoprint-2.4.0-py3-none-any.whl.metadata (17 kB)
Collecting numpy>=1.26.0b1 (from hist)
  Downloading numpy-2.0.0rc2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.9/60.9 kB 1.3 MB/s eta 0:00:00
Collecting click>=7.0.0 (from histoprint>=2.2.0->hist)
  Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting uhi>=0.2.1 (from histoprint>=2.2.0->hist)
  Downloading uhi-0.4.0-py3-none-any.whl.metadata (7.2 kB)
Downloading hist-2.7.2-py3-none-any.whl (40 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.4/40.4 kB 5.1 MB/s eta 0:00:00
Downloading boost_histogram-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 13.4 MB/s eta 0:00:00
Downloading histoprint-2.4.0-py3-none-any.whl (16 kB)
Downloading numpy-2.0.0rc2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.0/19.0 MB 49.7 MB/s eta 0:00:00
Downloading click-8.1.7-py3-none-any.whl (97 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 25.3 MB/s eta 0:00:00
Downloading uhi-0.4.0-py3-none-any.whl (11 kB)
Installing collected packages: numpy, click, uhi, boost-histogram, histoprint, hist
Successfully installed boost-histogram-1.4.1 click-8.1.7 hist-2.7.2 histoprint-2.4.0 numpy-2.0.0rc2 uhi-0.4.0
(venv) root@ae8245ca153b:/# python -m pip list | grep numpy
numpy           2.0.0rc2
(venv) root@ae8245ca153b:/# deactivate && rm -rf venv && python -m venv venv && . venv/bin/activate
(venv) root@ae8245ca153b:/# python -m pip install --upgrade --no-cache-dir 'hist@git+https://github.com/scikit-hep/hist.git'
Collecting hist@ git+https://github.com/scikit-hep/hist.git
  Cloning https://github.com/scikit-hep/hist.git to /tmp/pip-install-0yiw9keq/hist_0512fe2498364f79ba39b33babffa6e9
  Running command git clone --filter=blob:none --quiet https://github.com/scikit-hep/hist.git /tmp/pip-install-0yiw9keq/hist_0512fe2498364f79ba39b33babffa6e9
  Resolved https://github.com/scikit-hep/hist.git to commit 9c3a275ff3f614d5ea201149b7851905a4c2e8b4
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting boost-histogram<1.5,>=1.3.1 (from hist@ git+https://github.com/scikit-hep/hist.git)
  Downloading boost_histogram-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (25 kB)
Collecting histoprint>=2.2.0 (from hist@ git+https://github.com/scikit-hep/hist.git)
  Downloading histoprint-2.4.0-py3-none-any.whl.metadata (17 kB)
Collecting numpy>=1.14.5 (from hist@ git+https://github.com/scikit-hep/hist.git)
  Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.0/61.0 kB 2.2 MB/s eta 0:00:00
Collecting click>=7.0.0 (from histoprint>=2.2.0->hist@ git+https://github.com/scikit-hep/hist.git)
  Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting uhi>=0.2.1 (from histoprint>=2.2.0->hist@ git+https://github.com/scikit-hep/hist.git)
  Downloading uhi-0.4.0-py3-none-any.whl.metadata (7.2 kB)
Downloading boost_histogram-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 16.3 MB/s eta 0:00:00
Downloading histoprint-2.4.0-py3-none-any.whl (16 kB)
Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.0/18.0 MB 58.7 MB/s eta 0:00:00
Downloading click-8.1.7-py3-none-any.whl (97 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 98.4 MB/s eta 0:00:00
Downloading uhi-0.4.0-py3-none-any.whl (11 kB)
Building wheels for collected packages: hist
  Building wheel for hist (pyproject.toml) ... done
  Created wheel for hist: filename=hist-2.7.3.dev18+g9c3a275-py3-none-any.whl size=40760 sha256=e58b8f99dda4ebd75d7c4e07a278976f8e22f30504587739a0703de75b13b86c
  Stored in directory: /tmp/pip-ephem-wheel-cache-8uy3fw2_/wheels/0f/56/88/8a37ccc417d17d4bf263d4615cb853b05ceaf6c0aefc1b9b90
Successfully built hist
Installing collected packages: numpy, click, uhi, boost-histogram, histoprint, hist
Successfully installed boost-histogram-1.4.1 click-8.1.7 hist-2.7.3.dev18+g9c3a275 histoprint-2.4.0 numpy-1.26.4 uhi-0.4.0
(venv) root@ae8245ca153b:/# python -m pip list | grep numpy
numpy           1.26.4
henryiii commented 1 month ago

Ah, forgot that was in hist too, I fixed it in boost-histogram.

henryiii commented 1 month ago

Fixed in 2.7.3.