In windows, requirements file parser collapses absolute reference to requirements file
See original GitHub issueDescription
In Windows, running pip install -r
against the following requirements file containing an absolute reference to other requirements files fails.
# In power-shell
$ echo pandas > requirements.txt
$ echo "-r $(pwd)\requirements.txt" > other-requirements.txt
$ pip install -r "$(pwd)\other-requirements.txt"
Could not open requirements file: [Errno 2] No such file or directory: 'D:\\absolute\\path\\to\\absolutepathtorequirements.txt'
Expected behavior
pip install
should succeed
pip version
21.1.3
Python version
3.7.9
OS
Windows
How to Reproduce
echo pandas > requirements.txt
echo "-r $(pwd)\requirements.txt" > other_requirements.txt
cat requirements.txt
cat other_requirements.txt
pip install -r "$(pwd)\other_equirements.txt"
See this github actions log: https://github.com/harupy/windows-playground/pull/1/checks?check_run_id=2979532159
Output
pandas
-r D:\a\windows-playground\windows-playground\requirements.txt
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'D:\\a\\windows-playground\\windows-playground\\awindows-playgroundwindows-playgroundrequirements.txt'
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Proper way to parse requirements file after pip upgrade to pip ...
First, I believe parsing requirements.txt from within setup.py is not a good idea. It should be the other way around, install_requires in ...
Read more >madpah/requirements-parser: A Pip requirements file ... - GitHub
This is a small Python module for parsing Pip requirement files. The goal is to parse everything in the Pip requirement file format...
Read more >Changelog - pip documentation v22.3.1
This fixes bugs where the file:// URL cannot be correctly used as requirement, constraint, or index URLs on Windows. (#10115).
Read more >pathlib — Object-oriented filesystem paths — Python 3.11.1 ...
Represent the path as a file URI. ValueError is raised if the path isn't absolute. >>> >>> ...
Read more >UG162: Simplicity Commander Reference Guide - Silicon Labs
6.7.7 Creating a Signed GBL File Using a Hardware Security Module . ... To execute Simplicity Commander commands, start a Windows command ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it’s more because of we need quotes (to handle special names, spaces, etc.), and once quoting is a thing you need a way to escape quotes, and everything cascades from there. The root of the issue is requirements.txt handles options by writing them like command line options, and cross-shell command line parsing is literally impossible. So there is a design decision to make, either we restrict the allowed quoting/escaping syntax, restrict what characters can appear in a path, or do platform-dependant parsing. All of them have significant setbacks.
As I said, I don’t like this solution because it makes Windows paths second-class. Why do we even need backslash-escaping in a requirements file?
Declaring forward slashes as the only supported option is easy and convenient, and may well be sufficient in practice, but that doesn’t mean it’s correct…