Comparing 1.8.4...1.8.5 · bazel-contrib/rules_python

Commits on Feb 23, 2026

  1. fix(runfiles): assume main repository on Windows (#3578)

    With any Python version on Windows, `RUNFILES_*` environment variables
    still point to an intermediate stage path instead of the module path,
    causing `CurrentRepository()` to raise a `ValueError` since
    `rules_python` v1.8.0:
    ```
    ValueError: C:\Users\bot\AppData\Local\Temp\Bazel.runfiles_gh34ij5_\runfiles\+_repo_rules+cpython\my_script.py does not lie under the runfiles root C:/cache/ab1cdef2/execroot/_main/bazel-out/x64_windows-fastbuild/bin/external/+_repo_rules+cpython/install.exe.runfiles
    ```
    
    This was not the case with `rules_python` v1.7.0. The issue stems from
    behavior.
    
    Since #3086 came up with a corresponding workaround in
    `//tests/runtime_env_toolchain:toolchain_runs_test`, the proposed fix
    simply consists in moving it to `CurrentRepository()`, thus adding
    another case to the workaround introduced by #1634 for Python < 3.11. It
    therefore leads to assuming the main module path on Windows as well.
    
    Removing the workaround from `CurrentRepository()` would make the test
    fail as follows:
    ```
    ==================== Test output for //tests/runtime_env_toolchain:toolchain_runs_test:
    E
    ======================================================================
    ERROR: test_ran (__main__.RunTest.test_ran)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
    [...]
    ValueError: C:\Users\user\AppData\Local\Temp\Bazel.runfiles_1f08smy6\runfiles\_main\tests\runtime_env_toolchain\toolchain_runs_test.py does not lie under the runfiles root c:\users\user\_bazel_user\cxxeswjo\execroot\_main\bazel-out\x64_windows-fastbuild-st-c530e4918e48\bin\tests\runtime_env_toolchain\toolchain_runs_test.exe.runfiles
    ```
    
    Fixes #3579.
    
    (cherry picked from commit f78add7)

    authored and rickeylev committed

    Feb 23, 2026
    Configuration menu

    Browse the repository at this point in the history

  2. fix(pip): preserve PEP 508 URL-based requirements when extract_url_sr…

    …cs=False (#3582)
    
    pip_parse (via pip_repository) passes extract_url_srcs=False to
    parse_requirements. The _package_srcs() function silently dropped PEP
    508 URL-based requirements (pkg @ https://...) in this mode because
    _add_dists() returns can_fallback=False for URL requirements, causing
    them to fall through to the `continue` statement.
    
    Fix the elif condition to also accept the case where extract_url_srcs is
    False but a valid URL dist exists, falling back to pip to handle the URL
    requirement directly.
    
    Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
    (cherry picked from commit 9dcbabb)

    2 people authored and rickeylev committed

    Feb 23, 2026
    Configuration menu

    Browse the repository at this point in the history

  3. fix(pypi): normalize extras in requirement strings per PEP 685 (#3588)

    ## Summary
    
    Extras parsed from requirement strings (e.g., from `requirements.txt`)
    were not being normalized, causing mismatches when evaluating PEP 508
    marker expressions. For example, `sqlalchemy[postgresql-psycopg2binary]`
    would fail to resolve `psycopg2-binary` as a transitive dependency
    because the wheel METADATA marker expression `extra ==
    "postgresql_psycopg2binary"` uses the underscore-normalized form (per
    PEP 685), while the extras set retained the original hyphenated form
    from the requirement string.
    
    ## Before
    
    ```
    # requirements.txt
    sqlalchemy[postgresql-psycopg2binary]==2.0.36
    
    # Parsed extras: ["postgresql-psycopg2binary"]
    # Marker evaluation: "postgresql-psycopg2binary" != "postgresql_psycopg2binary" -> MISS
    # Result: psycopg2-binary NOT included as a dependency
    ```
    
    ## After
    
    ```
    # requirements.txt
    sqlalchemy[postgresql-psycopg2binary]==2.0.36
    
    # Parsed extras: ["postgresql_psycopg2binary"]  (normalized)
    # Marker evaluation: "postgresql_psycopg2binary" == "postgresql_psycopg2binary" -> MATCH
    # Result: psycopg2-binary correctly included as a dependency
    ```
    
    ## Changes
    
    - **`python/private/pypi/pep508_requirement.bzl`**: Apply
    `normalize_name()` to each extra during requirement parsing, consistent
    with how the package name is already normalized.
    - **`tests/pypi/pep508/requirement_tests.bzl`**: Updated existing test
    expectation for case normalization and added test case for hyphenated
    extras
    (`sqlalchemy[asyncio,postgresql-psycopg2binary,postgresql-asyncpg]`).
    - **`tests/pypi/pep508/deps_tests.bzl`**: Added
    `test_extras_with_hyphens_are_normalized` integration test confirming
    that dependencies gated behind hyphenated extras are correctly resolved.
    - **`CHANGELOG.md`**: Added entry under Unreleased > Fixed.
    
    Fixes #3587
    
    ---------
    
    Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>
    (cherry picked from commit 9fe42b1)

    2 people authored and rickeylev committed

    Feb 23, 2026
    Configuration menu

    Browse the repository at this point in the history