Skip to content

Conversation

@aignas
Copy link
Collaborator

@aignas aignas commented Nov 24, 2025

Before this PR the user would have to specify download = True in order to not
fallback to pip, which is admittedly an odd interface design. With this PR we
correctly do not add a pip fallback if there is no sdist to be used. With
this in place we are better placed to enable the experimental_index_url by
default. What is more we can more reliably detect when we should use a special
repository rule to prepare for building from sdist.

Summary:

  • Add a test that shows the problem and then adjust the torch experimental URL
    test.
  • Cleanup unused marker stubs in the tests.
  • Fix the code to better handle the case when there is no sdist.

Work towards #260
Work towards #2410

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aignas, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the dependency resolution logic by preventing the system from attempting a pip fallback when no source distribution (sdist) is available for a package. This change addresses an unintuitive interface design where users previously had to explicitly set download = True to avoid fallbacks. By making the fallback decision more robust and automatic, the PR paves the way for enabling experimental_index_url by default and enhances the reliability of detecting when to use special repository rules for sdist builds.

Highlights

  • Improved Pip Fallback Logic: The system now intelligently avoids adding a pip fallback mechanism when a source distribution (sdist) is not available, preventing confusing errors and improving bazel query reliability.
  • Enhanced _add_dists Function: The _add_dists function has been updated to return a new can_fallback boolean flag, which explicitly indicates whether a pip fallback is a viable option based on the presence of an sdist or filename detection.
  • Test Suite Refinements: New test cases have been introduced to validate the improved fallback behavior, particularly for scenarios where no sdist is present. Additionally, unused marker stubs and download_only parameters were cleaned up from existing tests.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@aignas aignas changed the title fix(pip-cross): do not add a pip-fallback when there is no sdist fix(pip): do not add a pip-fallback when there is no sdist Nov 24, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the pip fallback logic to correctly avoid falling back when no source distribution (sdist) is available. This is a good improvement as it removes the need for the download = True workaround and makes the behavior more intuitive.

The changes in python/private/pypi/parse_requirements.bzl are clean, introducing a can_fallback flag from _add_dists to control the fallback behavior. The logic sdist != None correctly determines if a fallback is possible.

The test updates in tests/pypi/hub_builder/hub_builder_tests.bzl are comprehensive. They correctly test the new behavior by adding cases with wheels but no sdists, and by removing the download_only = True workaround. The cleanup of unused marker stubs is also a welcome improvement.

I have a couple of suggestions for minor improvements: one for code simplification in parse_requirements.bzl and another to correct a test assertion in hub_builder_tests.bzl.

"direct_sdist_without_sha",
"direct_without_sha",
"git_dep",
"pip_fallback",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The package plat_pkg should probably not be in the exposed_packages list. A package is considered 'exposed' only if it is available for all target platforms. In this test, plat_pkg provides a wheel only for linux_x86_64 and has no sdist, so it's not available for other platforms like osx_aarch64 or windows_aarch64. Therefore, it should not be exposed and should be removed from this list.

@rickeylev rickeylev added this pull request to the merge queue Nov 24, 2025
Merged via the queue into bazel-contrib:main with commit 45821b8 Nov 25, 2025
4 checks passed
@aignas aignas deleted the exp.aignas.if-no-sdist-no-fallback branch November 25, 2025 00:36
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