Skip to content

Commit

Permalink
Tweak the package release and version scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
OKaluza committed Dec 7, 2017
1 parent 56c53b6 commit 11c689a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
22 changes: 21 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,35 @@
from multiprocessing import cpu_count
from ctypes.util import find_library

#Current version
version = "1.2.14"

"""
To release a new verison:
1) Edit the version number above
2) Tag the release with git
>>> python setup.py tag
3) Publish the release to PyPi
>>> python setup.py publish
"""

#Run with "tag" arg to create a release tag
if sys.argv[-1] == 'tag':
os.system("git tag -a %s -m 'version %s'" % (version, version))
os.system("git push --tags")
sys.exit()

#Run with "publish" arg to upload the release
if sys.argv[-1] == 'publish':
os.system("python setup.py sdist upload")
sys.exit()

#Class to do the custom library build with make
class LVBuild(build):
def run(self):
# Run original build code
Expand Down Expand Up @@ -69,7 +89,7 @@ def run(self):
author = "Owen Kaluza",
author_email = "owen.kaluza@monash.edu",
url = "https://github.com/OKaluza/LavaVu",
version = "1.2.13",
version = version,
license = "LGPL-3",
description = "Python interface to LavaVu OpenGL 3D scientific visualisation utilities",
long_description = 'See https://github.com/OKaluza/LavaVu/wiki for more info',
Expand Down
27 changes: 16 additions & 11 deletions version.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@
import os

version = os.popen("git describe --tags --always").read()
version = version.rstrip('\r\n')
#Strip trailing newline and 'v' prefix
version = version.rstrip('\r\n')[1:]
#Replace first - with .
version = version.replace('-', '.', 1)

f = open('src/version.cpp', 'a+')
content = f.read()
if __name__ == "__main__":
# Only update version.cpp when not called via 'import'
f = open('src/version.cpp', 'a+')
content = f.read()

if not version in content:
f.close()
f = open('src/version.cpp', 'w')
print "Writing new version"
f.write('#include "version.h"\nconst std::string version = "%s";\n' % version)
else:
print "Version matches: " + version
if not version in content:
f.close()
f = open('src/version.cpp', 'w')
print "Writing new version: " + version
f.write('#include "version.h"\nconst std::string version = "%s";\n' % version)
else:
print "Version matches: " + version

f.close()
f.close()

0 comments on commit 11c689a

Please sign in to comment.