-
Notifications
You must be signed in to change notification settings - Fork 205
Update Pypi.dependencies after update to package manager api #3040
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
Changes from all commits
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 |
---|---|---|
|
@@ -11,6 +11,8 @@ class Pypi < Base | |
ENTIRE_PACKAGE_CAN_BE_DEPRECATED = true | ||
SUPPORTS_SINGLE_VERSION_UPDATE = true | ||
PYPI_PRERELEASE = /(a|b|rc|dev)[0-9]+$/.freeze | ||
# Adapted from https://peps.python.org/pep-0508/#names | ||
PEP_508_NAME_REGEX = /^([A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9])/i | ||
|
||
def self.package_link(db_project, version = nil) | ||
# NB PEP 503: "All URLs which respond with an HTML5 page MUST end with a / and the repository SHOULD redirect the URLs without a / to add a / to the end." | ||
|
@@ -123,17 +125,25 @@ def self.known_versions(name) | |
&.index_by { |v| v[:number] } || {} | ||
end | ||
|
||
def self.dependencies(name, version, _mapped_project) | ||
# Simply parses out the name of a PEP 508 Dependency specification: https://peps.python.org/pep-0508/ | ||
# Leaves the rest as-is with any leading semicolons or spaces stripped | ||
def self.parse_pep_508_dep_spec(dep) | ||
name, requirement = dep.split(PEP_508_NAME_REGEX, 2).last(2).map(&:strip) | ||
requirement = requirement.sub(/^[\s;]*/, "") | ||
return name, requirement | ||
end | ||
|
||
def self.dependencies(name, version, _mapped_project = nil) | ||
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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. Just the test. |
||
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 | ||
dep_name, requirements = parse_pep_508_dep_spec(dep) | ||
{ | ||
project_name: name, | ||
requirements: version.nil? || version == ";" ? "*" : version.gsub(/\(|\)/, ""), | ||
project_name: dep_name, | ||
requirements: requirements.blank? ? "*" : requirements, | ||
kind: "runtime", | ||
optional: false, | ||
platform: self.name.demodulize, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.