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

Update Pypi.dependencies after update to package manager api #3040

Merged
merged 5 commits into from
Jan 25, 2023

Conversation

papiro
Copy link
Contributor

@papiro papiro commented Jan 24, 2023

This is fixing Pypi dependencies after this update: pypi/warehouse#11775 which broke the existing implementation.

@@ -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)
Copy link
Contributor

@mikeyoung85 mikeyoung85 Jan 24, 2023

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just the test.

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the reason for this change?

Copy link
Contributor Author

@papiro papiro Jan 24, 2023

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

@tiegz tiegz Jan 24, 2023

Choose a reason for hiding this comment

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

I wonder if it's better to split on the semi-colon? Feeling slightly nervous about splitting on a whitespace (unless pypi is really strict about whitespaces in ranges) nevermind, I misread the tests at first!

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

name[quux, strange];python_version<'2.7' and platform_version=='2'
=> ["name[quux,", "strange];python_version<'2.7'"and platform_version=='2'"]

That's not the point of this change, but it's possible that the current (and this) implementation would create bad data

Copy link
Contributor

Choose a reason for hiding this comment

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

That being said we should probably file something else to address it

Copy link
Contributor Author

@papiro papiro Jan 24, 2023

Choose a reason for hiding this comment

The 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: ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9]). I suppose the rest of it we could provide in requirements?

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.

Copy link
Contributor

@mpace965 mpace965 left a comment

Choose a reason for hiding this comment

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

Not sure if the paren stripping was important, but otherwise LGTM

@papiro
Copy link
Contributor Author

papiro commented Jan 25, 2023

Not sure if the paren stripping was important, but otherwise LGTM

I noticed it would mess with dependency specifications like this: "os_name=='a' and (os_name=='b' or os_name=='c')". I looked through the git history to see why we added that and there wasn't a specific reason. I think it was just cosmetic because most dep spec requirements are simple and are yet surrounded by the parens.

@papiro papiro merged commit e2c925f into main Jan 25, 2023
@papiro papiro deleted the pp/sc-29698/dependencies-not-showing-up-in-release-api branch January 25, 2023 22:21
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.

4 participants