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

kivy + buildozer one place app name and version conventions #1482

Closed
cederom opened this issue Aug 1, 2022 · 1 comment
Closed

kivy + buildozer one place app name and version conventions #1482

cederom opened this issue Aug 1, 2022 · 1 comment

Comments

@cederom
Copy link
Contributor

cederom commented Aug 1, 2022

Versions

  • Python: 3.9.13
  • OS: macOS 12.5 / FreeBSD 13-STABLE
  • Buildozer: 1.4.0 / master

Description

Hello world of Kivy :-)

What would be the most elegant way to store application version information assuming the application will be exported with Buildozer to Android and iOS?

I would like to keep application name and version in one place so it is then available to both Buildozer specification (to generate mobile application release) and application code (to display name and version for the user).

I know that buildozer.spec requires the application name and version variables.

Should I set my application name and version in Buildozer specification then import them into my application code?

Should I create global variables in my main.py with application name and version them import them somehow into Buildozer specification?

Should I create separate file then import it somehow to both buildozer and application code?

Is there any prefered way or this needs to be yet created?

Any hints welcome :-)

@cederom
Copy link
Contributor Author

cederom commented Aug 3, 2022

Allright, I have discovered that Buildozer has two ways of versioning that can be used in buildozer.spec. Pare code is here:

def get_version(self):

You can either use version = 0.1 directly or search for __version__ = '0.1' variable value defined in a file specified by version.filename.

# version = 0.1
# EITHER ABOVE OR BELOW
version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py

Long story short put __version__ = '0.1' in the main.py and it will be obtained by buildozer.spec when you select second method :-)

You can also use git module to append branch and commit hex to the version string that will be safe to read by default buildozer regex and will help in release identification when developing with git.

__version__ = '0.1.0'

# IF A GIT REPO APPEND BRANCH AND COMMIT TO VERSION STRING
try:
    from git import Repo
    repo = Repo(search_parent_directories=True)
    __version__ = __version__ + '-' + repo.active_branch.name
    __version__ = __version__ + '-' + repo.active_branch.commit.hexsha[:7]
    del Repo
except:
    pass

@cederom cederom closed this as completed Aug 3, 2022
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

1 participant