Skip to content

Index priority without index groups #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

atalman
Copy link

@atalman atalman commented Mar 20, 2025

Working with @msarahan on Index Priority. pypa#13210

Hack way of prioritizing indexes

Test 1:
pip install torch --index-groups https://download.pytorch.org/whl/test/cpu,https://download.pytorch.org/whl/nightly/cpu --force-reinstall --dry-run

Output:

 pip install torch --index-groups https://download.pytorch.org/whl/test/cpu,https://download.pytorch.org/whl/nightly/cpu --force-reinstall --dry-run
https://download.pytorch.org/whl/test/cpu,https://download.pytorch.org/whl/nightly/cpu
Looking in indexes: https://download.pytorch.org/whl/test/cpu, https://download.pytorch.org/whl/nightly/cpu
Collecting torch
  Using cached https://download.pytorch.org/whl/test/cpu/torch-2.7.0%2Bcpu-cp311-cp311-manylinux_2_28_x86_64.whl.metadata (27 kB)
Collecting filelock (from torch)
  Using cached https://download.pytorch.org/whl/test/filelock-3.13.1-py3-none-any.whl (11 kB)
Collecting typing-extensions>=4.10.0 (from torch)
  Using cached https://download.pytorch.org/whl/test/typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Collecting sympy>=1.13.3 (from torch)
  Using cached https://download.pytorch.org/whl/test/sympy-1.13.3-py3-none-any.whl.metadata (12 kB)
Collecting networkx (from torch)
  Using cached https://download.pytorch.org/whl/test/networkx-3.3-py3-none-any.whl (1.7 MB)
Collecting jinja2 (from torch)
  Using cached https://download.pytorch.org/whl/test/Jinja2-3.1.4-py3-none-any.whl (133 kB)
Collecting fsspec (from torch)
  Using cached https://download.pytorch.org/whl/test/fsspec-2024.6.1-py3-none-any.whl (177 kB)
Collecting mpmath<1.4,>=1.1.0 (from sympy>=1.13.3->torch)
  Using cached https://download.pytorch.org/whl/test/mpmath-1.3.0-py3-none-any.whl (536 kB)
Collecting MarkupSafe>=2.0 (from jinja2->torch)
  Using cached https://download.pytorch.org/whl/test/MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28 kB)
Using cached https://download.pytorch.org/whl/test/cpu/torch-2.7.0%2Bcpu-cp311-cp311-manylinux_2_28_x86_64.whl (176.0 MB)
Using cached https://download.pytorch.org/whl/test/sympy-1.13.3-py3-none-any.whl (6.2 MB)
Would install Jinja2-3.1.4 MarkupSafe-2.1.5 filelock-3.13.1 fsspec-2024.6.1 mpmath-1.3.0 networkx-3.3 sympy-1.13.3 torch-2.7.0+cpu typing_extensions-4.12.2

Test 2:
pip install torch --index-groups https://download.pytorch.org/whl/nightly/cpu,https://download.pytorch.org/whl/test/cpu --force-reinstall --dry-run

Output:

pip install torch --index-groups https://download.pytorch.org/whl/nightly/cpu,https://download.pytorch.org/whl/test/cpu --force-reinstall --dry-run
https://download.pytorch.org/whl/nightly/cpu,https://download.pytorch.org/whl/test/cpu
Looking in indexes: https://download.pytorch.org/whl/nightly/cpu, https://download.pytorch.org/whl/test/cpu
Collecting torch
  Using cached https://download.pytorch.org/whl/nightly/cpu/torch-2.8.0.dev20250320%2Bcpu-cp311-cp311-manylinux_2_28_x86_64.whl.metadata (27 kB)
Collecting filelock (from torch)
  Using cached https://download.pytorch.org/whl/nightly/filelock-3.16.1-py3-none-any.whl (16 kB)
Collecting typing-extensions>=4.10.0 (from torch)
  Using cached https://download.pytorch.org/whl/nightly/typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Collecting sympy>=1.13.3 (from torch)
  Using cached https://download.pytorch.org/whl/nightly/sympy-1.13.3-py3-none-any.whl (6.2 MB)
Collecting networkx (from torch)
  Using cached https://download.pytorch.org/whl/nightly/networkx-3.4.2-py3-none-any.whl (1.7 MB)
Collecting jinja2 (from torch)
  Using cached https://download.pytorch.org/whl/nightly/jinja2-3.1.4-py3-none-any.whl (133 kB)
Collecting fsspec (from torch)
  Using cached https://download.pytorch.org/whl/nightly/fsspec-2024.10.0-py3-none-any.whl (179 kB)
Collecting mpmath<1.4,>=1.1.0 (from sympy>=1.13.3->torch)
  Using cached https://download.pytorch.org/whl/nightly/mpmath-1.3.0-py3-none-any.whl (536 kB)
Collecting MarkupSafe>=2.0 (from jinja2->torch)
  Using cached https://download.pytorch.org/whl/nightly/MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28 kB)
Using cached https://download.pytorch.org/whl/nightly/cpu/torch-2.8.0.dev20250320%2Bcpu-cp311-cp311-manylinux_2_28_x86_64.whl (177.6 MB)
Would install Jinja2-3.1.4 MarkupSafe-2.1.5 filelock-3.16.1 fsspec-2024.10.0 mpmath-1.3.0 networkx-3.4.2 sympy-1.13.3 torch-2.8.0.dev20250320+cpu typing_extensions-4.12.2

@atalman atalman marked this pull request as draft March 20, 2025 18:09
best_candidate = self.sort_best_candidate(applicable_candidates)
# Apply priority filtering to the list of candidates
found_candidate = False
if(self._index_priority and self._index_urls is not None):
Copy link

@msarahan msarahan Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good example of the opt-in index priority described by PEP 766 as it stands today. I think this is ultimately not a good approach, because it forces a behavior change away from Pip. I think that is going to be disruptive enough that it will be very hard to get into Pip. The behavior you have here should be similar to uv's default behavior.

@msarahan msarahan changed the base branch from index-groups to main March 20, 2025 20:40
@msarahan msarahan changed the title Draft index_priority Index priority without index groups Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants