Skip to content

requirements.update doesn't work on windows when requirements.in in a subpackage #1431

Closed
@carpenterjc

Description

@carpenterjc

Affected Rule

The issue is caused by the rule: compile_pip_requirements

Is this a regression?

Yes this regressed between: 0.18.0...0.19.0

Description

If you have a rule in a sub package (so it contains a directory separator) then on windows you will get an issue where it cannot find file path for requirements.txt.

Note: the slashes are the wrong direction for windows.

🔬 Minimal Reproduction

In 0.25.0 branch of rules_python


cd .\examples\pip_parse\
REM This works
bazel run requirements.update

mkdir bad
copy .\BUILD.bazel bad
copy .\requirements.in bad
copy .\requirements_lock.txt bad

REM This fails with Error: Could not open file 'bad/requirements_lock.txt': No such file or directory
bazel run //bad:requirements.update

🔥 Exception or Error



INFO: Running command line: bazel-bin/tools/thirdparty/requirements.update.exe tools/thirdparty/requirements.in tools/thirdparty/requirements.txt None None None //tools/thirdparty:requirements.update --allow-unsafe --no-reuse-hashes
Updating tools/thirdparty/requirements.txt
Traceback (most recent call last):
  File "C:\Users\JAMESC~1\AppData\Local\Temp\Bazel.runfiles_gwh6jf4s\runfiles\rules_python\python\pip_install\tools\dependency_resolver\dependency_resolver.py", line 139, in 
    if not os.path.samefile(requirements_txt, requirements_txt_tree):
  File "C:\Users\JAMESC~1\AppData\Local\Temp\Bazel.runfiles_gwh6jf4s\runfiles\python3_10_x86_64-pc-windows-msvc\lib\genericpath.py", line 100, in samefile
    s1 = os.stat(f1)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'tools/thirdparty/requirements.txt'

🌍 Your Environment

Operating System:

  
windows 
  

Output of bazel version:

  
Build label: 6.2.0
Build target: bazel-out/x64_windows-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue May 9 18:34:17 2023 (1683657257)
Build timestamp: 1683657257
Build timestamp as int: 1683657257
  

Rules_python version:

  
0.25.0
  

Anything else relevant?
Same code works fine on macos and WSL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions