-
Notifications
You must be signed in to change notification settings - Fork 206
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
Update Pypi.dependencies after update to package manager api #3040
Changes from 1 commit
aa2091b
15ac575
ef5746a
afb5349
4f46915
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,14 +123,14 @@ def self.known_versions(name) | |
&.index_by { |v| v[:number] } || {} | ||
end | ||
|
||
def self.dependencies(name, version, _mapped_project) | ||
def self.dependencies(name, version, _mapped_project = nil) | ||
api_response = get("https://pypi.org/pypi/#{name}/#{version}/json") | ||
deps = api_response.dig("info", "requires_dist") | ||
source_info = api_response.dig("releases", version) | ||
source_info = api_response.fetch("urls", []) | ||
Rails.logger.warn("Pypi sdist (no deps): #{name}") unless source_info.any? { |rel| rel["packagetype"] == "bdist_wheel" } | ||
|
||
deps.map do |dep| | ||
name, version = dep.split | ||
name, version = dep.split(/ /, 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the reason for this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TLDR: before we were saying definitively that a package had a certain number of dependencies, even if some of those dependencies only came with variants of the package. Now we include the information specifying which ones are only included with a variant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allegedly (according to this StackOverflow post), these dependencies are in the PEP 508 format. I can't find an official PyPI source stating this though. Looking at the tests in the grammar section, there are a couple of instances of valid PEP 508 dependencies where the part after a space would not specify a version, e.g.
That's not the point of this change, but it's possible that the current (and this) implementation would create bad data There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That being said we should probably file something else to address it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oof... According to this, we should be able to use this regex to parse the name: Edit: Please make sure I'm understanding that right. I think when they say "names" they're talking about package names... I'm not 100% sure though. |
||
{ | ||
project_name: name, | ||
requirements: version.nil? || version == ";" ? "*" : version.gsub(/\(|\)/, ""), | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need this change. Is something calling this method without passing in the third argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the test.