Skip to content

Commit

Permalink
Update setup.py to add git commit count to product_version.
Browse files Browse the repository at this point in the history
  • Loading branch information
awltux committed Feb 1, 2023
1 parent 36bb7d3 commit 9c8b213
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gnucash_uk_vat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from . device import get_device

# BEWARE: This version number is injected by setup.py
product_version = "1.5.2"
product_version = "1.5.140"

# Configuration object, loads configuration from a JSON file, and then
# supports path navigate with config.get("part1.part2.part3")
Expand Down
17 changes: 16 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import setuptools
import re
import git

PRODUCT_BASE_VERSION = "1.5"

with open("README.md", "r") as fh:
long_description = fh.read()

productVersion = "1.5.2"
uncommitted = True
try:
# Use git commit count as a build number in product-version
git_repo = git.Repo(search_parent_directories=True)
uncommitted = git_repo.is_dirty()
git_commits = list(git_repo.iter_commits('HEAD'))
git_count = len(git_commits)
except Exception as git_exception:
git_count = 9999
raise Exception("[ERROR] Couldn't calculate the GIT commit count! Is this a git checkout?")

productVersion = "%s.%s" % (PRODUCT_BASE_VERSION, git_count)
configFilename = "gnucash_uk_vat/config.py"

# Inject the product_version into configFilename
Expand Down Expand Up @@ -42,6 +56,7 @@
'piecash',
'netifaces',
'tabulate',
'GitPython',
],
scripts=[
"scripts/gnucash-uk-vat",
Expand Down
2 changes: 0 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
if [[ $(sfc 2>&1 | tr -d '\0') =~ SCANNOW ]]; then
if [[ -f $(dirname $(which python))/scripts/gnucash-uk-vat ]]; then
echo "Update gnucash-uk-vat"
# The '--force-reinstall' was a bit savage
# python -m pip install --upgrade --force-reinstall . 2>&1 | tee setup.log
python -m pip install --upgrade . 2>&1 | tee setup.log
else
echo "Install gnucash-uk-vat"
Expand Down

0 comments on commit 9c8b213

Please sign in to comment.