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

Use setuptools_scm to map PyPI package version to branch #212

Open
pinkwah opened this issue Jul 8, 2021 · 1 comment
Open

Use setuptools_scm to map PyPI package version to branch #212

pinkwah opened this issue Jul 8, 2021 · 1 comment

Comments

@pinkwah
Copy link
Collaborator

pinkwah commented Jul 8, 2021

We can use setuptools_scm.version.Version to convert GitHub branch and tags to PyPI-compatible strings, and use this as a lookup table for komodo packages that use * as version.

mapping = {}
for bt in branch_and_tags:
    try:
        version = setuptools_scm.version.Version(bt)
        mapping[str(version)] = bt
    except:  # Could not parse version string, ignore
        pass

print("Your branch is:", mapping["1.2.3b4"])  # => 1.2.3-beta.4

Github has APIs for getting branches and tags:

@markusdregi
Copy link
Contributor

markusdregi commented Jul 8, 2021

Snippet for getting releases from GitHub using pygithub.

>>> import github
>>> g = github.Github() # <- Use token or you will quickly use too many requests...
>>> repo = g.get_repo("equinor/ert")                  
>>> releases = repo.get_releases()
>>> [r.tag_name for r in releases]
['2.25.0-rc1', '2.25.0-rc0', ..., '2017.07']

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