Skip to content
Snippets Groups Projects

Draft: feat: use github metadata if no pypi release found

Open Agathe Porte requested to merge gagath/pypi2deb:feat-use-github-metadata into master
5 unresolved threads

The current implementation always uses PyPI to find out metadata for the package, even if a Github link has been provided. This is problematic for packages that only have their source available on Github, but without any release available on PyPI.

The code was refactored to put some functions in common, and a new function has been added to extract metadata from the Github repository if no PyPI release is found, as a fallback.

Edited by Agathe Porte

Merge request reports

Members who can merge are allowed to add commits.
Approval is optional
Merge blocked: 2 checks failed
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
32 from pypi2deb.tools import clean_summary
33
32 34 log = logging.getLogger('pypi2deb')
33 35
34 36
37 def github_latest_tag_name(repo):
38 try:
39 return repo.get_latest_release().tag_name
40 except UnknownObjectException:
41 # Some projects do not use Github Releases, check the latest tag instead
42 return repo.get_tags()[0].name
43
44
45 def github_version(tag_name):
46 # TODO: are there other special cases? vx.y.z tag gets rewritten as x.y.z
47 return tag_name.lstrip('v')
  • 94
    95 g = Github()
    96 repo = g.get_repo(url.replace('https://github.com/', ''))
    97
    98 tag_name = github_latest_tag_name(repo)
    99
    100 result = {
    101 'name': repo.name,
    102 'version': github_version(tag_name),
    103 'description': repo.description,
    104 'license_name': repo.get_license().license,
    105 'author': '{} <{}>'.format(repo.owner.name, repo.owner.email),
    106 'homepage': repo.homepage,
    107 }
    108
    109 summary = repo.description.replace(' ', ' ')
  • Sandro Tosi
    Sandro Tosi @morph started a thread on the diff
  • 42 57 if not name:
    43 58 name = repo.name
    44 59
    45 try:
    46 tag_name = repo.get_latest_release().tag_name
    47 except UnknownObjectException:
    48 # Some projects do not use Github Releases, check the latest tag instead
    49 tag_name = repo.get_tags()[0].name
    50
    51 60 if not version:
    52 # TODO: are there other special cases? vx.y.z tag gets rewritten as x.y.z
    53 version = tag_name.lstrip('v')
    61 tag_name = github_latest_tag_name(repo)
    62 version = github_version(tag_name)
    63 else:
    64 tag_name = "v{}".format(version)
  • Sandro Tosi
    Sandro Tosi @morph started a thread on the diff
  • 30 30 from github.GithubException import UnknownObjectException
    31 31
    32 from pypi2deb.tools import clean_summary
    33
    32 34 log = logging.getLogger('pypi2deb')
    33 35
    34 36
    37 def github_latest_tag_name(repo):
    38 try:
    39 return repo.get_latest_release().tag_name
    40 except UnknownObjectException:
    41 # Some projects do not use Github Releases, check the latest tag instead
    42 return repo.get_tags()[0].name
    43
    44
    45 def github_version(tag_name):
  • Sandro Tosi
    Sandro Tosi @morph started a thread on the diff
  • 42 57 if not name:
    43 58 name = repo.name
    44 59
    45 try:
    46 tag_name = repo.get_latest_release().tag_name
    47 except UnknownObjectException:
    48 # Some projects do not use Github Releases, check the latest tag instead
    49 tag_name = repo.get_tags()[0].name
    50
    51 60 if not version:
    52 # TODO: are there other special cases? vx.y.z tag gets rewritten as x.y.z
    53 version = tag_name.lstrip('v')
    61 tag_name = github_latest_tag_name(repo)
    62 version = github_version(tag_name)
    63 else:
    64 tag_name = "v{}".format(version)
    • i think this requires more thought, because not all projects on github use vx.y.z. so maybe we need to have a function to retrive all the tags/releases, compare them with the version specified and match it with the correct tag name

    • Please register or sign in to reply
  • Agathe Porte added 8 commits

    added 8 commits

    Compare with previous version

  • Agathe Porte marked this merge request as draft

    marked this merge request as draft

  • Agathe Porte added 11 commits

    added 11 commits

    Compare with previous version

  • Agathe, could you address inline comments from Sandro and Emmanuel?

    Edited by Piotr Ożarowski
  • Please register or sign in to reply
    Loading