Skip to content
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

Included requirements files should be relative to parent, not cwd #1416

Closed
hauntsaninja opened this issue Feb 16, 2024 · 7 comments · Fixed by #1421
Closed

Included requirements files should be relative to parent, not cwd #1416

hauntsaninja opened this issue Feb 16, 2024 · 7 comments · Fixed by #1421

Comments

@hauntsaninja
Copy link
Contributor

. λ rm -rf tmp
. λ mkdir tmp
. λ cd tmp
./tmp λ printf 'mypy' > a.in                     
./tmp λ printf '-r a.in\nruff' > b.in
./tmp λ cd ..
. λ pip-compile --no-header --no-annotate tmp/b.in
WARNING: --strip-extras is becoming the default in version 8.0.0. To silence this warning, either use --strip-extras to opt into the new default or use --no-strip-extras to retain the existing behavior.
mypy==1.8.0
mypy-extensions==1.0.0
ruff==0.2.1
typing-extensions==4.9.0
. λ uv pip compile --no-header --no-annotate tmp/b.in
error: Error parsing included file in `tmp/b.in` at position 0
  Caused by: failed to open file `./a.in`
  Caused by: No such file or directory (os error 2)
@charliermarsh
Copy link
Member

I believe this is the same as #1367.

@charliermarsh
Copy link
Member

Gonna look at it now.

@hauntsaninja
Copy link
Contributor Author

Thanks! I'll close this as a duplicate

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2024
@charliermarsh
Copy link
Member

Do you know if pip has the same treatment for local packages, or is this just for requirements / constraints files?

@charliermarsh
Copy link
Member

Ahh, I see, it's just files (not directories): pypa/pip#8765

@hauntsaninja
Copy link
Contributor Author

hauntsaninja commented Feb 16, 2024

Looks like pip is inconsistent, in that in the following case it is relative to cwd:

λ ls tmp
a.in                         pypyp-1.1.0-py3-none-any.whl
λ cat tmp/a.in
pypyp-1.1.0-py3-none-any.whl
λ pip install -r tmp/a.in
WARNING: Requirement 'pypyp-1.1.0-py3-none-any.whl' looks like a filename, but the file does not exist
Processing ./pypyp-1.1.0-py3-none-any.whl (from -r tmp/a.in (line 1))
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: './pypyp-1.1.0-py3-none-any.whl'
λ cd tmp
./tmp master λ pip install -r a.in    
Processing ./pypyp-1.1.0-py3-none-any.whl (from -r a.in (line 1))
pypyp is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.

I don't care about^ case at all

@charliermarsh
Copy link
Member

Okay yeah, makes sense.

charliermarsh added a commit that referenced this issue Feb 16, 2024
## Summary

In a `requirements.txt` file, it turns out that the `-c` and `-r`
entries should be interpreted as relative to the file in which they're
declared, while the `-e` entries should be interpreted as relative to
the current working directory, no matter where they're defined.

Previously, we always used the current working directory; now, we use
the declaring file's directory for `-c` and `-r`.

Closes #1367.

Closes #1416.
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 a pull request may close this issue.

2 participants