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

Promote pinning sub-dependencies in constraints.txt #7807

Closed
wants to merge 3 commits into from

Conversation

m-aciek
Copy link

@m-aciek m-aciek commented Mar 1, 2020

Promote separating top- and sub-dependencies over generating requirements from pip freeze

Using pip freeze to generate requirements may be harmful as one may have other packages installed before.
Separating pinned versions of top-level dependencies from sub-dependencies should help in maintaining and keeping control over dependencies.

Promote separating top- and sub-dependencies over generating requirements from pip freeze

Using pip freeze to generate requirements may be harmful as one may have other packages installed before.
Separating pinned versions of top-level dependencies from sub-dependencies should help in maintaining and keeping control over dependencies.
@pradyunsg pradyunsg added the type: docs Documentation related label Mar 2, 2020
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @m-aciek! I'm on board for this change.

Let's wait for a bit, to see if other folks have any thoughts or concerns. :)

@uranusjr
Copy link
Member

uranusjr commented Mar 2, 2020

I am not against the change, but also not sure what exactly the benefits are. It would probably be a good idea to add some discussion on exactly what this would help with what situations. Probably not directly with the freeze instructions (that would confuse newcomers), but a new section further down the page discussing the differences between constraint and requirement files, with a reference pointing to it added to the freeze section.

@pfmoore
Copy link
Member

pfmoore commented Mar 2, 2020

+1 on what @uranusjr said. I don't really have a clear understanding of what a constraint file is in general (specifically, how it differs from a requirements file) so I think before we promote constraint files as standard workflow, we should improve the docs on constraint files in general, to avoid confusing users.

@chrahunt
Copy link
Member

chrahunt commented Mar 2, 2020

I don't like that this puts the burden on users to distinguish between top-level dependencies and sub-dependencies.

This will probably be something that we have to resolve as part of the resolver work, so I would suggest waiting until then to see if a more reasonable workflow can be built on top of the machinery used for that.

@pfmoore
Copy link
Member

pfmoore commented Mar 2, 2020

That's a very good point. I'm not sure the new resolver will make much difference here, though - it sounds much more likely that the discussions around a standard lockfile format are going to be the key to a good user experience here.

I'm still +1 on documenting the difference in purpose between constraint and requirement files better, regardless. And I'm +0 on subsequently adding something like this change to document what works now, if you want to spend the effort manually making the distinction between direct requirements and dependencies.

@chrahunt
Copy link
Member

chrahunt commented Mar 2, 2020

If we have anything like a "prune" capability, it will require tracking installed top-level dependencies in an environment. That would make the task of outputting something like a Pipfile or requirements + constraints actually possible.

@chrahunt
Copy link
Member

chrahunt commented Mar 4, 2020

Hi @m-aciek. As mentioned above, as it is currently documented this isn't likely to delight users, who will have to make up for pip not being able to differentiate between the top-level and sub-dependencies. Let's follow #7811 and #6925, as they will provide some basic machinery that we can build on top of to provide a better user workflow.

Any issues with closing this, in favor of following those issues and seeing where we are afterwards?

@m-aciek
Copy link
Author

m-aciek commented Mar 4, 2020

Thank you all for your comments. My original message was missing some motivation background, which I'll express now below. And I will close the PR for now.

Critique of generating requirements.txt from pip freeze

My main concern expressed in this documentation change was to not promote putting pip freeze as requirements, because

  • this way one is losing information about distinction between top- and sub-dependencies,
  • one can include in a requirements.txt package he didn’t intend to, e.g. having polluted environment with some other packages.

In bigger projects with multiple top-dependencies, generating requirements.txt this way may produce set which is very hard to maintain (project I worked on in the past at work experienced this, and for me working with it's requirements.txt was a pain).

I would suggest in documentation creating such file by hand, with help of sections Version and Depends of pip show [package].

Using constraints

Constraints may be better than requirements in case of upgrading some dependencies. Let assume django will drop sqlparse as dependency. If someone will miss that fact while upgrading pinned version of django in requirements.txt, constraints for sqlparse will not install that unnecessary package.

But I would say constraints are an extra to the main concern.

Let me close this pull request and open another one, with a bit less “aggresive” documentation change.

@m-aciek
Copy link
Author

m-aciek commented Mar 4, 2020

For the record, I've opened #7820 with a second take on this part of documentation.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Apr 4, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: docs Documentation related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants