Skip to content

Commit

Permalink
Fix the version issue
Browse files Browse the repository at this point in the history
Use dynamic version in setup.py, replace _getversion.py with "setup.py
version"
  • Loading branch information
OKaluza committed Jun 27, 2024
1 parent f09af94 commit c192731
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ vpath %.cc src
#When releasing, just build with the clean version from setup.py
ifneq ($(LV_RELEASE), 1)
#Otherwise update version using git tag
TMP := $(shell $(PYTHON) _getversion.py)
TMP := $(shell $(PYTHON) setup.py version)
endif

SRC := $(wildcard src/*.cpp) $(wildcard src/Main/*Viewer.cpp) $(wildcard src/jpeg/*.cpp)
Expand Down
22 changes: 0 additions & 22 deletions _getversion.py

This file was deleted.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[project]
name = "lavavu"
version = "1.8.62"
authors = [
{name = "Owen Kaluza", email = "[email protected]"},
]
Expand Down Expand Up @@ -34,7 +33,7 @@ classifiers = [
'Framework :: IPython'
]
requires-python = ">=3.5"
dynamic = ["dependencies"]
dynamic = ["version", "dependencies"]
#dynamic = ["version", "description", "dependencies"]

[project.urls]
Expand All @@ -57,6 +56,7 @@ exclude = ["html*", "shaders*"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
version = {attr = "setup.version"}

[tool.setuptools.package-data]
lavavu = ['font.bin', 'dict.json', 'shaders/*', 'html/*', '*.dll']
Expand Down
26 changes: 23 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def write_version():
webbrowser.open("docs/index.html")
sys.exit()
#Run with "tag" arg to create a release tag
if sys.argv[-1] == 'release':
elif sys.argv[-1] == 'release':
#Commit and push docs
wd = os.getcwd()
os.chdir("docs")
Expand All @@ -113,13 +113,13 @@ def write_version():
sys.exit()

#Run with "publish" arg to upload the release
if sys.argv[-1] == 'publish':
elif sys.argv[-1] == 'publish':
os.system("python setup.py sdist")
os.system("twine upload dist/lavavu-%s.tar.gz" % version)
sys.exit()

# Just output the wheel name for current arch + environment
if sys.argv[-1] == 'wheelname':
elif sys.argv[-1] == 'wheelname':
# https://stackoverflow.com/a/60644659/866759
from setuptools.dist import Distribution
lavavu = Extension('lavavu', [])
Expand All @@ -132,6 +132,26 @@ def write_version():
print(wheel_name)
sys.exit()

elif sys.argv[-1] == 'version':
#Replaces _getversion.py,
#Get current git tag version
git_version = os.popen("git describe --tags --always 2> /dev/null").read()
if len(git_version) == 0:
#Just report the current release version
#Still need to write if file doesn't exist
if os.path.exists('src/version.cpp'):
print(version)
exit()
else:
#Strip trailing newline
version = version.rstrip('\r\n')
#Replace first - with .
version = version.replace('-', '.', 1)

#Update version.cpp
write_version()
exit()

#Get extra lib and include dirs
inc_dirs = []
lib_dirs = []
Expand Down

0 comments on commit c192731

Please sign in to comment.