Skip to content

Commit

Permalink
ci: Use uv for all pip installs (#2444)
Browse files Browse the repository at this point in the history
* Use 'uv pip' for all calls to 'pip install' and 'pip uninstall' in
  CI workflows.
   - c.f. https://github.com/astral-sh/uv/
   - Still use pip for Python 3.8 until astral-sh/uv#2062
     is resolved.
* Apply subtle changes to install commands in .github/workflows/dependencies-head.yml.
   - 'uv pip install --upgrade' will try to upgrade all dependencies of the target
     package as well, which for the dependencies-head workflow isn't the goal. So
     remove the '--upgrade' from calls that also install from the
     scientific-python-nightly-wheels package index when testing only particular packages.
   - 'up pip' and 'pip' have different behavior with regards to --extra-index-url, as
     'uv pip' gives --extra-index-url priority over --index-url, where 'pip' does
     not give priority to either. Use this with 'uv pip' to give priority to the
     scientific-python-nightly-wheels package index.
* Add uv to the 'develop' extras.
  • Loading branch information
matthewfeickert authored Apr 30, 2024
1 parent 682ce76 commit 08755e4
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 49 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,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
5 changes: 3 additions & 2 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade '.[all,test]'
python -m pip install uv
uv pip install --system --upgrade pip setuptools wheel
uv pip install --system --upgrade '.[all,test]'
- name: List installed Python packages
run: python -m pip list
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
if: matrix.python-version != '3.8'
run: |
python -m pip install uv
uv pip install --system --upgrade pip setuptools wheel
uv pip install --system --upgrade ".[all,test]"
# c.f. https://github.com/astral-sh/uv/issues/2062
- name: Install dependencies (Python 3.8)
if: matrix.python-version == '3.8'
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade ".[all,test]"
Expand Down
64 changes: 35 additions & 29 deletions .github/workflows/dependencies-head.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip --no-cache-dir --quiet install --upgrade --pre ".[all,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
Expand All @@ -57,14 +58,14 @@ 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 ".[all,test]"
python -m pip uninstall --yes scipy
python -m pip install --upgrade --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/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
Expand All @@ -87,11 +88,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 ".[all,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: |
Expand All @@ -113,10 +115,11 @@ 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 ".[all,test]"
python -m pip uninstall --yes uproot
python -m pip install --upgrade git+https://github.com/scikit-hep/uproot5.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: |
Expand All @@ -140,16 +143,18 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip --no-cache-dir --quiet install --upgrade ".[all,test]"
python -m pip uninstall --yes matplotlib
# Need to use --extra-index-url as dependencies aren't on scientific-python-nightly-wheels 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 \
--index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \
--extra-index-url https://pypi.org/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 @@ -175,10 +180,11 @@ 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 ".[all,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: |
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,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
5 changes: 3 additions & 2 deletions .github/workflows/lower-bound-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ".[all,test]"
python -m pip install uv
uv pip install --system --upgrade pip setuptools wheel
uv pip --no-cache install --system --constraint tests/constraints.txt ".[all,test]"
- name: List installed Python packages
run: python -m pip list
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install uv
uv pip install --system --upgrade pip setuptools wheel
# FIXME: c.f. https://github.com/scikit-hep/pyhf/issues/2104
python -m pip install --upgrade ".[all,test]" 'jupyter-client<8.0.0'
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 @@ -43,19 +43,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 @@ -36,9 +36,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
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 @@ -48,6 +49,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.3.0"
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)
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sphinx:
# If using Sphinx, optionally build your docs in additional formats such as PDF and ePub
formats: all

# python -m pip install .[docs]
# python -m pip install '.[docs]'
python:
install:
- method: pip
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ develop = [
"pre-commit",
"nox",
"codemetapy>=2.3.0",
"uv>=0.1.39"
]

[tool.hatch.version]
Expand Down

0 comments on commit 08755e4

Please sign in to comment.