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

Add "provides" package metadata. #194

Merged
merged 9 commits into from
Apr 29, 2016
Merged

Add "provides" package metadata. #194

merged 9 commits into from
Apr 29, 2016

Conversation

johntyree
Copy link
Contributor

This adds PackageMetadata.provides and the associated code around that. It works by dumping all of the providers of a given name into pool's the internal name_to_packages list. The rest of the behavior falls out from that.

If package A provides package B, then either A or B can be used to satisfy dependencies (or cause conflicts with) B. This does imply that package A replaces package B or that package B is somehow obsolete or that package A should be preferred. With the current implementation, if two packages provide the same thing then you'll get whichever has a higher version number, but this is unspecified. If you care about priority, you'll need to use some of the other metadata features (not yet implemented).

See #177

self._packages_by_name_[package.name].append(package)
for constraints in package.provides:
req = Requirement.from_constraints(constraints)
assert not req.has_any_version_constraint
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain this assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I forgot to write about it. Really we need to move the entire package metadata spec into the docs here.

The long and short of it is that right now we don't have a good way to handle provides with version numbers. We might someday, but there aren't any good use-cases that I know of. This assertion is there to make sure package metadata authors haven't done that. It should probably be ValueError or InvalidConstraint or something instead. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

This does sound like an InvalidConstraint. If this exception trickles up to users, we would want to make sure that the message was clear, too

@noraderam
Copy link
Contributor

Just a few questions

@noraderam noraderam assigned johntyree and unassigned noraderam Apr 28, 2016
@johntyree johntyree assigned noraderam and unassigned johntyree Apr 28, 2016
"install_requires (zope *, numpy ^= 1.8.0, requests >= 0.2)",
"conflicts (requests ^= 0.2.5, requests > 0.4, bokeh_git)",
"conflicts (requests ^= 0.2.5, requests > 0.4, bokeh)",
"provides (webplot ^= 0.1, bokeh)",
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this different from "provides with version numbers"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only testing our ability to parse, which separates the clauses and builds constraint tuples, but doesn't validate. In general we don't validate things up front due to the overhead of parsing version objects and the sheer number of packages. Also, we will not be parsing pretty strings during a normal work flow. IThe program which is using simplesat as a library will construct package metadata directly (which is why we guard against it below this level).

@noraderam noraderam assigned johntyree and unassigned noraderam Apr 28, 2016
Raise InvalidCosntraint instead of AssertionError
@johntyree johntyree assigned noraderam and unassigned johntyree Apr 29, 2016
@johntyree
Copy link
Contributor Author

@noraderam 📬

@noraderam
Copy link
Contributor

LGTM

@johntyree johntyree merged commit 9a00002 into master Apr 29, 2016
@johntyree johntyree deleted the enh/provides-metadata branch April 29, 2016 21:31
@cournape cournape modified the milestone: 0.3 May 3, 2016
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 this pull request may close these issues.

3 participants