Skip to content

Commit

Permalink
ci(backport): Use uv for all pip installs (#2494)
Browse files Browse the repository at this point in the history
* Backport:
   - PR #2444
   - PR #2475
  • Loading branch information
matthewfeickert authored May 30, 2024
1 parent 290a23c commit 902ffce
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 64 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.7' && 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.7' || 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
Expand Down
77 changes: 44 additions & 33 deletions .github/workflows/dependencies-head.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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:

Expand All @@ -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:

Expand All @@ -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:

Expand All @@ -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
Expand All @@ -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
7 changes: 4 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/')"
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
17 changes: 8 additions & 9 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ 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:
configuration: docs/conf.py

# 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

0 comments on commit 902ffce

Please sign in to comment.