HEPData / hepdata_lib

Library for getting your data into HEPData
https://hepdata-lib.readthedocs.io
MIT License
15 stars 37 forks source link

build: Add requires-python metadata #222

Closed matthewfeickert closed 1 year ago

matthewfeickert commented 1 year ago

Add requires-python metadata through the addition of setuptools's python_requires in setup.py.

The lower bound versions are selected to support the versions of CPython currently supported: 2.7 and 3.6+. Currently these lower bound versions of CPython (2.7, 3.6) have all reached EOL:

$ python -m pip install --upgrade norwegianblue
$ eol python
┌───────┬────────────┬─────────┬────────────────┬────────────┐
│ cycle │  release   │  latest │ latest release │    eol     │
├───────┼────────────┼─────────┼────────────────┼────────────┤
│  3.11 │ 2022-10-24 │  3.11.2 │   2023-02-07   │ 2027-10-24 │
│  3.10 │ 2021-10-04 │ 3.10.10 │   2023-02-07   │ 2026-10-04 │
│  3.9  │ 2020-10-05 │  3.9.16 │   2022-12-06   │ 2025-10-05 │
│  3.8  │ 2019-10-14 │  3.8.16 │   2022-12-06   │ 2024-10-14 │
│  3.7  │ 2018-06-26 │  3.7.16 │   2022-12-06   │ 2023-06-27 │
│  3.6  │ 2016-12-22 │  3.6.15 │   2021-09-03   │ 2021-12-23 │
│  3.5  │ 2015-09-12 │  3.5.10 │   2020-09-05   │ 2020-09-13 │
│  3.4  │ 2014-03-15 │  3.4.10 │   2019-03-18   │ 2019-03-18 │
│  3.3  │ 2012-09-29 │  3.3.7  │   2017-09-19   │ 2017-09-29 │
│  2.7  │ 2010-07-03 │  2.7.18 │   2020-04-19   │ 2020-01-01 │
│  2.6  │ 2008-10-01 │  2.6.9  │   2013-10-29   │ 2013-10-29 │
└───────┴────────────┴─────────┴────────────────┴────────────┘

The addition of requires-python is to provide guards to keep older CPython versions from installing releases that could contain unrunnable code.

matthewfeickert commented 1 year ago

@clelange it would be good to have this go in before the release you mentioned here: https://github.com/HEPData/hepdata_lib/pull/220#pullrequestreview-1310761532

I'd suggest the following procedure:

  1. Merge this PR.
  2. Make and release patch release v0.11.1 (nothing has changed other than a dependency fix in PR #218 and the guard from this PR)
  3. Rebase, review, and eventually merge PR #221
  4. (Edit: Inserted on 2023-02-27): Rebase, review, and eventually merge PR #223
  5. Make and release minor release v0.12.0 as the supported versions of Python have changed.

What do you think?

codecov-commenter commented 1 year ago

Codecov Report

Merging #222 (53445de) into master (21349a6) will not change coverage. The diff coverage is n/a.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##           master     #222   +/-   ##
=======================================
  Coverage   88.01%   88.01%           
=======================================
  Files           4        4           
  Lines         968      968           
  Branches      202      202           
=======================================
  Hits          852      852           
  Misses         85       85           
  Partials       31       31           
Flag Coverage Δ
unittests-3.10 88.01% <ø> (ø)
unittests-3.6 87.66% <ø> (ø)
unittests-3.7 87.66% <ø> (ø)
unittests-3.8 87.80% <ø> (ø)
unittests-3.9 87.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

matthewfeickert commented 1 year ago

The motivation for this Issue comes too late, as the problems that I outlined with not setting a lower bound to avoid breaking old versions have actually already happened. PR #189 broke all Python 2 releases forever for hepdata_lib v0.10.0+ when it added

https://github.com/HEPData/hepdata_lib/blob/42238e14c8f005ed3f2aa2d8161e2516e09d58cf/requirements.txt#L5

as the last release of hepdata-validator to support Python 2 was hepdata-validator v0.2.3.

There is no way to unbreak these releases, but as there haven't been too many releases since v0.10.0

$ python -m pip index versions hepdata-lib
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
hepdata-lib (0.11.1)
Available versions: 0.11.1, 0.11.0, 0.10.1, 0.10.0, 0.9.0, 0.8.1, 0.8.0, 0.7.0, 0.6.0, 0.5.0, 0.4.1, 0.4.0, 0.3.2, 0.3.0, 0.2.8, 0.2.7, 0.2.6, 0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2.0, 0.1.1, 0.1

it would be feasible to finish following the outline of https://github.com/HEPData/hepdata_lib/pull/222#issuecomment-1441355145 and then to yank releases 0.10.0, 0.10.1, 0.11.0, and 0.11.1 from PyPI. This would still allow for these releases to be installed by exactly requesting them with == but it would then unbreak a Python 2.7 install like

$ docker run --rm -ti python:2.7 /bin/bash        
root@095b42ef95fd:/# virtualenv venv && . venv/bin/activate
(venv) root@095b42ef95fd:/# python -m pip --quiet install --upgrade pip setuptools wheel
(venv) root@095b42ef95fd:/# python -m pip install hepdata-lib
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting hepdata-lib
  Downloading hepdata_lib-0.11.1-py2.py3-none-any.whl (20 kB)
ERROR: Could not find a version that satisfies the requirement hepdata-validator>=0.3.2 (from hepdata-lib) (from versions: 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.1.10, 0.1.11, 0.1.12, 0.1.13, 0.1.14, 0.1.15, 0.1.16, 0.2.1, 0.2.2, 0.2.3)
ERROR: No matching distribution found for hepdata-validator>=0.3.2 (from hepdata-lib)
(venv) root@095b42ef95fd:/# 

as this would then be the equivalent of

(venv) root@095b42ef95fd:/# python -m pip install 'hepdata-lib<0.10.0'

which is a valid Python 2.7 install

(venv) root@095b42ef95fd:/# python -m pip show hepdata-lib
Name: hepdata-lib
Version: 0.9.0
Summary: Library for getting your data into HEPData
Home-page: https://github.com/HEPData/hepdata_lib
Author: Andreas Albert, Clemens Lange
Author-email: hepdata-lib@cern.ch
License: UNKNOWN
Location: /venv/lib/python2.7/site-packages
Requires: six, numpy, future, PyYAML
Required-by: 
(venv) root@095b42ef95fd:/#