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
Add new --with-blanklines option to pip freeze command #12485
base: main
Are you sure you want to change the base?
Conversation
Thanks for submitting this. I'm personally -1 to add a new option just for this. If this is deemed important, it could be enabled by default. I'm not a user of that particular pip freeze feature myself, though, and I'm not sure if introducing this would be considered a backward incompatible change. |
Thanks for the answer. I agree that adding a new flag maybe is unnecessary. There are two aspects why I decided to make this flag optional:
But if you think this should work by default, then I can work in that direction. |
Can you elaborate item 2? |
About the second item. For example we have two requirements.txt - The # databases
alembic==1.13.1
SQLAlchemy==2.0.25
psycopg2==2.9.9
# network
aiohttp==3.9.1
# parsing
bs4==0.0.1 And # databases
alembic==1.13.1
asyncpg==0.29.0
SQLAlchemy==2.0.25
psycopg2==2.9.9
# network
requests==2.31.0
# parsing
Scrapy==2.11.0 If we pass it to pip freeze command without new flag ( # databases
alembic==1.13.1
SQLAlchemy==2.0.25
psycopg2==2.9.9
# network
aiohttp==3.9.1
# parsing
bs4==0.0.1
asyncpg==0.29.0
requests==2.31.0
Scrapy==2.11.0
## The following requirements were added by pip freeze:
...other packages... And with new # databases
alembic==1.13.1
SQLAlchemy==2.0.25
psycopg2==2.9.9
# network
aiohttp==3.9.1
# parsing
bs4==0.0.1
asyncpg==0.29.0
requests==2.31.0
Scrapy==2.11.0
## The following requirements were added by pip freeze:
...other packages... Preserved blanklines in this case make the output look strange (for me). |
So, what do you think about it? Should I work in that way or move to make this logic work by default? |
So, @sbidoul what do you think about this? |
I'm not sure. This, as an option, sounds very "ad-hoc". I'd prefer a solution that works well out of the box. BTW, about your example 2, the blank line is not stranger than having On the other hand, changing the output by default might be considered a breaking change. It might be interesting to hear from other users of the |
I agree with @sbidoul - I don't use the I would be interested in seeing the motivation for the original addition of this option. The ability to use a single The whole thing seems to be largely unintended behaviour. My preference would be:
In practice, though, I don't think (3) is worth the effort, as we clearly have people using the feature. But I don't think we should encourage this usage, or spend maintainer time on it. Again, though, I'll note that I have no use for the |
This pull request (PR) introduces a new option to the pip freeze command. New
--with-blanklines
option allows you to preserve blank lines in final output when using the--requirement
option, which can be convenient and useful in certain scenarios.For example, when updating dependencies, it will be based on
requirements.txt
:The
requirements.txt
format will be preserved without violations, including the retention of empty lines in output.Instead of default behavior: