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 --no-header <blank requirements.in> neither creates nor overwrites requirements.txt #900

Closed
AndydeCleyre opened this issue Sep 18, 2019 · 3 comments · Fixed by #909
Labels
bug Something is not working PR wanted Feature is discussed or bug is confirmed, PR needed

Comments

@AndydeCleyre
Copy link
Contributor

If requirements.in is empty, running pip-compile will create or clobber requirements.txt, thereby removing all requirements, but if --no-header is passed to pip-compile, requirements.txt will not be affected in any way, no matter its state.

Environment Versions

  1. Linux
  2. Python version: 3.7.4
  3. pip version: 19.2.3
  4. pip-tools version: 4.1.0

Steps to replicate

touch requirements.in
pip-compile --no-header
# no txt file created (unexpected)
pip-compile
# txt file created (as expected)
echo plumbum > requirements.in
pip-compile
echo > requirements.in
pip-compile --no-header
cat requirements.txt

full, unexpected:

#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile
#
plumbum==1.6.7
@atugushev atugushev added the bug Something is not working label Sep 19, 2019
@atugushev
Copy link
Member

Hello @AndydeCleyre,

Thanks for the report! That's a good catch!

@atugushev atugushev added the PR wanted Feature is discussed or bug is confirmed, PR needed label Sep 19, 2019
@AndydeCleyre
Copy link
Contributor Author

I'll submit a pull request for this today. Would it be preferable for the writer line iterator to simply always yield a final extra newline, or to actually keep track of whether or not it has yielded any real lines along the way, and only add the newline in that case?

@atugushev

@atugushev
Copy link
Member

atugushev commented Sep 25, 2019

@AndydeCleyre

I'd prefer this suggestion:

keep track of whether or not it has yielded any real lines along the way, and only add the newline in that case?

AndydeCleyre added a commit to AndydeCleyre/pip-tools that referenced this issue Oct 1, 2019
…d --no-header is supplied (Fixes jazzband#900)

Add !is_empty (yielded) tracking to the writer's _iter_lines method, and yield a blank line (empty string) if (and only if) otherwise nothing at all would be yielded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working PR wanted Feature is discussed or bug is confirmed, PR needed
Projects
None yet
2 participants