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

Get URL from PURL #86

Open
TG1999 opened this issue Apr 27, 2022 · 2 comments
Open

Get URL from PURL #86

TG1999 opened this issue Apr 27, 2022 · 2 comments

Comments

@TG1999
Copy link
Collaborator

TG1999 commented Apr 27, 2022

From gitter chat https://gitter.im/package-url/Lobby

@tclasen :

Anyone know why the python package isn't letting me get a url from a purl?
@app.command()
def get(purl: str):
    parsed = PackageURL.from_string(purl)
    typer.echo(f"Grabbing {parsed}")
    typer.echo("A", purl2url.get_url(purl))
    typer.echo("B", purl2url.get_url(parsed.to_string()))
    typer.echo("C", purl2url.get_url(str(parsed)))
    typer.echo("D", purl2url.get_url(parsed.to_string()))
For this I've tried the two following PURLs:

pkg:maven/org.apache.commons/[email protected]
pkg:pypi/[email protected]
And for both of them I successfully parse and can print the purl, but the A, B, C, D echos after that are all empty (but don't crash).

@pombredanne :

@tclasen because it has not been implemented yet : https://github.com/package-url/packageurl-python/blob/main/src/packageurl/contrib/purl2url.py :)
It should be reasonably straightforward using tidbits of code from https://github.com/nexB/fetchcode/blob/master/src/fetchcode/package.py and the expansive set in https://github.com/nexB/scancode-toolkit/tree/develop/src/packagedcode
@TG1999
Copy link
Collaborator Author

TG1999 commented Apr 27, 2022

@tclasen one work around for now could be to use fetchcode for this, since many package types are not supported in purl2url

>>> from fetchcode.package import *
>>> pkgs = list(info("pkg:npm/[email protected]"))
>>> package = pkgs[0]
>>> package.bug_tracking_url
>>> package.homepage_url
>>> package.download_url

You can additionally get more information from a package like this

@tdruez
Copy link
Collaborator

tdruez commented Dec 8, 2023

one work around for now could be to use fetchcode for this

fetchcode does not support the provided example pkg:maven/org.apache.commons/[email protected]

>>> from fetchcode.package import *
>>> info("pkg:maven/org.apache.commons/[email protected]")

And for pkg:pypi/[email protected], the bug_tracking_url and homepage_url are not consistent with the purl2url.get_repo_url


>>> from fetchcode.package import *
>>> pkgs = list(info("pkg:pypi/[email protected]"))
>>> package = pkgs[0]
>>> package.bug_tracking_url
'https://code.djangoproject.com/'
>>> package.homepage_url
'https://www.djangoproject.com/'
>>> package.download_url
>>>

Let's see if we could improve support in purl2url for the following:

>>> from packageurl.contrib import purl2url

>>> purl2url.get_repo_url("pkg:maven/org.apache.commons/[email protected]")
None

>>> purl2url.get_download_url("pkg:maven/org.apache.commons/[email protected]")
None

>>> purl2url.get_repo_url("pkg:pypi/[email protected]")
'https://pypi.org/project/django/1.11.1/'

>>> purl2url.get_download_url("pkg:pypi/[email protected]")
None

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

No branches or pull requests

2 participants