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

Python: Dependencies are looked up from incorrect urls #241

Open
jenshnielsen opened this issue Aug 30, 2022 · 3 comments
Open

Python: Dependencies are looked up from incorrect urls #241

jenshnielsen opened this issue Aug 30, 2022 · 3 comments
Assignees
Labels
detector:pip The pip detector status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality

Comments

@jenshnielsen
Copy link

When running component-detection on one of my projects I am seeing output like the following.

[INFO] Getting Python data from https://pypi.org/pypi/pywinpty>=1.1.0/json
[WARN] Received 404 Not Found from https://pypi.org/pypi/pywinpty>=1.1.0/json
[WARN] Dependency Package pywinpty>=1.1.0 not found in Pypi. Skipping package

It seems like component-detection is in some situations passing an incorrect url which contains the version specifier and obviously does not resolve. This seems to happen for transitive dependencies that are constrained to a specific version by some other direct or transitive dependency.

@JamieMagee JamieMagee added status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality detector:pip The pip detector labels Aug 30, 2022
@melotic
Copy link
Member

melotic commented Mar 10, 2023

This is handled by this regex:

// Extracts abcd from a string like abcd==1.*,!=1.3
private static readonly Regex PipNameExtractionRegex = new Regex(
@"^.+?((?=<)|(?=>)|(?=>=)|(?=<=)|(?===)|(?=!=)|(?=~=)|(?====))",
RegexOptions.Compiled);

Testing this regex on pywinpty>=1.1.0 works, but requirements with optional dependencies like PyJWT[crypto]<3,>=1.0.0 will match as PyJWT[crypto] which is incorrect. We probably need to add

|(?=\[)

to this regex and create a separate issue that tracks us not fetching the transitive dependencies of the optional depenedency.

@melotic
Copy link
Member

melotic commented Mar 10, 2023

Additionally, there are some Require-Dists in this format:

Requires-Dist: numpy<1.27.0,>=1.19.5

that do not match this Regex:

// Extracts name and version from a Requires-Dist string that is found in a metadata file
public static readonly Regex RequiresDistRegex = new Regex(
@"Requires-Dist:\s*(?:(.*?)\s*\((.*?)\)|([^\s;]*))",
RegexOptions.Compiled);

@cobya
Copy link
Contributor

cobya commented May 23, 2024

This is also likely a combination of custom packaging index feeds - #1129 should have support for this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
detector:pip The pip detector status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality
Projects
Development

No branches or pull requests

4 participants