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

pip-compile should accept special files (pipes, fifo, pty, sockets, ...) as output files #2012

Open
manuco opened this issue Oct 31, 2023 · 7 comments
Labels
docs Documentation related enhancement Improvements to functionality logging Related to log or console output

Comments

@manuco
Copy link
Contributor

manuco commented Oct 31, 2023

When running pip-compile -o /dev/stdout, the command blocks indefinitely. It shouldn't and should write the requirement file in the given file, even if it's not a bare file.

Please note that pip-compile | <other program> doesn't work either (the other program doesn't receive anything).

Please also note that stderr is cluttered by some eventual warnings not parseable by pip and is so not usable as a viable content source.

Environment Versions

  1. Linux VirtualBox 5.4.0-165-generic # 182-Ubuntu SMP Mon Oct 2 19:43:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

  2. Python version: Python 3.8.10

  3. pip version: pip 23.3.1

  4. pip-tools version: pip-compile, version 7.3.0

Steps to replicate

  1. git clone <your favourite "using setup.py" project> && cd in
  2. pip-compile setup.py -o /dev/stdout
  3. nothing happens

Expected result

output on stdout (not stderr)
warnings (if any) on stderr

Actual result

<nothing and process blocked>

Steps to replicate (advanced)

TTY 1 :

  1. mkfifo /tmp/mylovelyfifo
  2. cat /tmp/mylovelyfifo

TTY 2 :

  1. git clone <your favourite "using setup.py" project> && cd in
  2. pip-compile setup.py -o /tmp/mylovelyfifo

Expected result

output on TTY 1
warnings (if any) on TTY 2

Actual result

<nothing and process blocked>

@manuco
Copy link
Contributor Author

manuco commented Nov 2, 2023

The main problem is that pip compile try to read the output file in order to find previous requirement and update it. pip compile should ensure that previous requirements is only read from a real file (with stat.S_ISREG(mode)), but should not trust that reading from this file won't block.

For example, setting /dev/stdout as an output file will make pip compile try to read this file. And it won't generate any error because /dev/stdout as a link to your terminal (/dev/pts/*n*) is also readable (since /dev/pts/*n* is also stdin and stderr). But it won't give any data until you type on your keyboard (which is not what's expected).

@manuco
Copy link
Contributor Author

manuco commented Nov 2, 2023

Also the documentation should emphasize that - is a legit output filename redirecting it to stdout.

@chrysle
Copy link
Contributor

chrysle commented Nov 8, 2023

Thanks for raising this issue, sounds like a reasonable request! I'll look into it.

@chrysle chrysle added docs Documentation related logging Related to log or console output enhancement Improvements to functionality labels Nov 8, 2023
@webknjaz
Copy link
Member

@manuco are you willing to contribute tests, at least?

@manuco
Copy link
Contributor Author

manuco commented Dec 19, 2023

@webknjaz I'll have a look at it if it can help. Since those tests will be integrations tests (with the IOs of the OS), will they fit in the current tests ?

@manuco
Copy link
Contributor Author

manuco commented Dec 29, 2023

@webknjaz Is this test ok for you ?

@webknjaz
Copy link
Member

Looks good, mostly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related enhancement Improvements to functionality logging Related to log or console output
Projects
None yet
Development

No branches or pull requests

3 participants