Draft: feat: use github metadata if no pypi release found
5 unresolved threads
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
Activity
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') What will happen in the cases where the vx.y.z is not used? eg: https://github.com/python-poetry/poetry-core/tags
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(' ', ' ') 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) 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): 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) added 8 commits
-
75c5a8f5...75da5b83 - 7 commits from branch
python-team/tools:master
- 6ced5bfa - feat: use github metadata if no pypi release found
-
75c5a8f5...75da5b83 - 7 commits from branch
added 11 commits
-
6ced5bfa...066ac0c1 - 10 commits from branch
python-team/tools:master
- 3b110450 - feat: use github metadata if no pypi release found
-
6ced5bfa...066ac0c1 - 10 commits from branch
Agathe, could you address inline comments from Sandro and Emmanuel?
Edited by Piotr Ożarowski
Please register or sign in to reply