From 664d34727eea46666b16cef2af318e7fa6076b41 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Thu, 30 May 2024 00:06:24 -0500 Subject: [PATCH] ci(backport): Use uv for all pip installs * Backport: - PR https://github.com/scikit-hep/pyhf/pull/ 2444 - PR https://github.com/scikit-hep/pyhf/pull/ 2475 --- .github/workflows/bump-version.yml | 5 +- .github/workflows/ci.yml | 16 ++-- .github/workflows/dependencies-head.yml | 77 +++++++++++-------- .github/workflows/docs.yml | 7 +- .../workflows/lower-bound-requirements.yml | 5 +- .github/workflows/notebooks.yml | 6 +- .github/workflows/publish-package.yml | 9 ++- .github/workflows/release_tests.yml | 9 ++- .readthedocs.yaml | 17 ++-- 9 files changed, 85 insertions(+), 66 deletions(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 4849406e64..3a5b1f0142 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -198,8 +198,9 @@ jobs: - name: Install Python dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install tbump + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip install --system tbump python -m pip list - name: Setup Git user to push new tag diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1e016e307..011e1fb1bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,17 +43,19 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install dependencies (Python 3.7) - if: matrix.python-version == '3.7' + - name: Install dependencies + if: matrix.python-version != '3.8' run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install --find-links https://storage.googleapis.com/jax-releases/jax_releases.html --upgrade .[test] + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip install --system --upgrade ".[all,test]" - - name: Install dependencies - if: matrix.python-version != '3.7' + # c.f. https://github.com/astral-sh/uv/issues/2062 + - name: Install dependencies (Python 3.7, 3.8) + if: matrix.python-version <= '3.8' run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade .[test] + python -m pip install --find-links https://storage.googleapis.com/jax-releases/jax_releases.html --upgrade ".[all,test]" - name: List installed Python packages run: python -m pip list diff --git a/.github/workflows/dependencies-head.yml b/.github/workflows/dependencies-head.yml index d6f7a43421..849cf6fea4 100644 --- a/.github/workflows/dependencies-head.yml +++ b/.github/workflows/dependencies-head.yml @@ -29,13 +29,18 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip --no-cache-dir --quiet install --upgrade --pre .[test] + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip --no-cache --quiet install --system --upgrade --pre ".[all,test]" python -m pip list + - name: List release candidates, alpha, and beta releases + run: | + python -m pip list | egrep '[0-9](rc|[ab])[0-9]' + - name: Test with pytest run: | - pytest --ignore tests/benchmarks/ --ignore tests/contrib --ignore tests/test_notebooks.py + pytest --ignore tests/contrib --ignore tests/benchmarks --ignore tests/test_notebooks.py scipy: @@ -53,19 +58,19 @@ jobs: with: python-version: ${{ matrix.python-version }} - # Use nightly SciPy wheels from Anaconda's PyPI - # c.f. https://twitter.com/ralfgommers/status/1419917265781334025 - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip --no-cache-dir --quiet install --upgrade .[test] - python -m pip uninstall --yes scipy - python -m pip install --upgrade --index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip --no-cache --quiet install --system --upgrade ".[all,test]" + uv pip uninstall --system scipy + # uv wants to upgrade dependencies (numpy) to a dev release too, so don't --upgrade + uv pip install --system --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple scipy python -m pip list - name: Test with pytest run: | - pytest --ignore tests/benchmarks/ --ignore tests/contrib --ignore tests/test_notebooks.py + pytest --ignore tests/contrib --ignore tests/benchmarks --ignore tests/test_notebooks.py iminuit: @@ -83,15 +88,16 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip --no-cache-dir --quiet install --upgrade .[test] - python -m pip uninstall --yes iminuit - python -m pip install --upgrade cython - python -m pip install --upgrade git+https://github.com/scikit-hep/iminuit.git + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip --no-cache --quiet install --system --upgrade ".[all,test]" + uv pip uninstall --system iminuit + uv pip install --system --upgrade cython + uv pip install --system --upgrade git+https://github.com/scikit-hep/iminuit.git python -m pip list - name: Test with pytest run: | - pytest --ignore tests/benchmarks/ --ignore tests/contrib --ignore tests/test_notebooks.py + pytest --ignore tests/contrib --ignore tests/benchmarks --ignore tests/test_notebooks.py uproot5: @@ -109,14 +115,15 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip --no-cache-dir --quiet install --upgrade .[test] - python -m pip uninstall --yes uproot - python -m pip install --upgrade git+https://github.com/scikit-hep/uproot4.git + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip --no-cache --quiet install --system --upgrade ".[all,test]" + uv pip uninstall --system uproot + uv pip install --system --upgrade git+https://github.com/scikit-hep/uproot5.git python -m pip list - name: Test with pytest run: | - pytest --ignore tests/benchmarks/ --ignore tests/contrib --ignore tests/test_notebooks.py + pytest --ignore tests/contrib --ignore tests/benchmarks --ignore tests/test_notebooks.py matplotlib: @@ -136,15 +143,18 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip --no-cache-dir --quiet install --upgrade .[test] - python -m pip uninstall --yes matplotlib - # Need to use --extra-index-url as dependencies aren't on scipy-wheels-nightly package index. + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip --no-cache --quiet install --system --upgrade ".[all,test]" + uv pip uninstall --system matplotlib + # Need to use --extra-index-url as all dependencies aren't on scientific-python-nightly-wheels package index. # Need to use --pre as dev releases will need priority over stable releases. - python -m pip install \ - --upgrade \ + # Note that uv and pip differ on --extra-index-url priority + # c.f. https://github.com/scientific-python/upload-nightly-action/issues/76 + uv pip install --system \ --pre \ - --extra-index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple \ + --index-url https://pypi.org/simple/ \ + --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \ matplotlib - name: List installed Python packages @@ -170,11 +180,12 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip --no-cache-dir --quiet install --upgrade .[test] - python -m pip uninstall --yes pytest - python -m pip install --upgrade git+https://github.com/pytest-dev/pytest.git + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip --no-cache --quiet install --system --upgrade ".[all,test]" + uv pip uninstall --system pytest + uv pip install --system --upgrade git+https://github.com/pytest-dev/pytest.git python -m pip list - name: Test with pytest run: | - pytest --ignore tests/benchmarks/ --ignore tests/contrib --ignore tests/test_notebooks.py + pytest --ignore tests/contrib --ignore tests/benchmarks --ignore tests/test_notebooks.py diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 70c841ef21..365aeff43b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -31,9 +31,10 @@ jobs: - name: Install Python dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip --quiet install --upgrade .[docs,test] - python -m pip install yq + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip --quiet install --system --upgrade ".[docs,test]" + uv pip install --system yq python -m pip list - name: Install apt-get dependencies diff --git a/.github/workflows/lower-bound-requirements.yml b/.github/workflows/lower-bound-requirements.yml index 4b170d67ac..366a6b0cb2 100644 --- a/.github/workflows/lower-bound-requirements.yml +++ b/.github/workflows/lower-bound-requirements.yml @@ -26,8 +26,9 @@ jobs: - name: Install dependencies and force lowest bound run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip --no-cache-dir install --constraint tests/constraints.txt .[test] + python -m pip install uv + uv pip install --system --upgrade pip 'setuptools<70.0.0' wheel + uv pip --no-cache install --system --constraint tests/constraints.txt ".[all,test]" - name: List installed Python packages run: python -m pip list diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index ca9a5eb609..29d6df0605 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -28,8 +28,10 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade .[test] + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + # FIXME: c.f. https://github.com/scikit-hep/pyhf/issues/2104 + uv pip install --system --upgrade ".[all,test]" 'jupyter-client<8.0.0' - name: List installed Python packages run: python -m pip list diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index a70a9e1478..6d96038c68 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -41,19 +41,20 @@ jobs: - name: Install python-build and twine run: | - python -m pip install --upgrade pip - python -m pip install build twine + python -m pip install uv + uv pip install --system --upgrade pip + uv pip install --system build twine python -m pip list - name: Build a sdist and wheel if: github.event_name != 'schedule' run: | - python -m build . + python -m build --installer uv . - name: Build a sdist and wheel and check for warnings if: github.event_name == 'schedule' run: | - PYTHONWARNINGS=error,default::DeprecationWarning python -m build . + PYTHONWARNINGS=error,default::DeprecationWarning python -m build --installer uv . - name: Verify untagged commits have dev versions if: "!startsWith(github.ref, 'refs/tags/')" diff --git a/.github/workflows/release_tests.yml b/.github/workflows/release_tests.yml index 146fb4cd4d..f5c1904260 100644 --- a/.github/workflows/release_tests.yml +++ b/.github/workflows/release_tests.yml @@ -37,9 +37,10 @@ jobs: - name: Install from PyPI run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install --pre pyhf[backends,xmlio] - python -m pip install pytest pytest-cov + python -m pip install uv + uv pip install --system --upgrade pip setuptools wheel + uv pip install --system --pre 'pyhf[backends,xmlio]' + uv pip install --system pytest python -m pip list - name: Canary test public API @@ -49,6 +50,6 @@ jobs: # FIXME: c.f. https://github.com/proycon/codemetapy/issues/24 - name: Verify requirements in codemeta.json run: | - python -m pip install jq "codemetapy>=2.4.1" + uv pip install --system jq "codemetapy>=2.3.0" codemetapy --inputtype python --no-extras pyhf > codemeta_generated.json diff <(jq -S .softwareRequirements codemeta.json) <(jq -S .softwareRequirements codemeta_generated.json) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index bdab4e8207..5bd7c51f22 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,10 +9,17 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3.12" apt_packages: - curl - jq + jobs: + post_create_environment: + - pip install uv + post_install: + # VIRTUAL_ENV needs to be set manually for now. + # See https://github.com/readthedocs/readthedocs.org/pull/11152/ + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install '.[docs]' # Build documentation in the docs/ directory with Sphinx sphinx: @@ -20,11 +27,3 @@ sphinx: # If using Sphinx, optionally build your docs in additional formats such as PDF and ePub formats: all - -# python -m pip install .[docs] -python: - install: - - method: pip - path: . - extra_requirements: - - docs