1
0
mirror of https://github.com/moepman/acertmgr.git synced 2024-12-27 10:41:51 +01:00

setup: rework version determination for release bundles and update values

This commit is contained in:
Kishi85 2019-03-22 11:46:01 +01:00
parent 2ed50e032d
commit 53f61f19d1
3 changed files with 30 additions and 13 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
*.pyc *.pyc
__pycache__ __pycache__
*dist/ *dist/
*build/
*egg-info/ *egg-info/
*.tar.gz *.tar.gz

View File

@ -1,3 +1,4 @@
import io
import os import os
import subprocess import subprocess
@ -8,34 +9,45 @@ from setuptools import setup, find_packages
# Used for the long_description. It's nice, because now 1) we have a top level # Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw # README file and 2) it's easier to type in the README file than to put a raw
# string in below ... # string in below ...
def read(fname): def read(filename):
return open(os.path.join(os.path.dirname(__file__), fname)).read() with io.open(os.path.join(os.path.dirname(__file__), filename)) as f:
return f.read()
# Utility function to determine version using git in a PEP-440 compatible way # Utility function to determine version using git in a PEP-440 compatible way, fallback to version.txt for releases
def get_git_version(): def determine_version():
dir_path = os.path.dirname(os.path.realpath(__file__))
ver_file = os.path.join(dir_path, "version.txt")
version = "0.0.0"
if os.path.exists(ver_file):
version = read(ver_file)
# If this is a release file and no git is found, use version.txt
if not os.path.isdir(os.path.join(dir_path, ".git")):
return version
# Derive version from git
try: try:
output = subprocess.check_output(['git', 'describe', '--tags', '--dirty']).decode('utf-8').strip().split('-') output = subprocess.check_output(['git', 'describe', '--tags', '--dirty'], cwd=dir_path)\
.decode('utf-8').strip().split('-')
if len(output) == 1: if len(output) == 1:
version = output[0] return output[0]
elif len(output) == 2: elif len(output) == 2:
version = "{}.dev0".format(output[0]) return "{}.dev0".format(output[0])
else: else:
release = 'dev' if len(output) == 4 and output[3] == 'dirty' else '' release = 'dev' if len(output) == 4 and output[3] == 'dirty' else ''
version = "{}.{}{}+{}".format(output[0], release, output[1], output[2]) return "{}.{}{}+{}".format(output[0], release, output[1], output[2])
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
try: try:
commit = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip() commit = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
status = subprocess.check_output(['git', 'status', '-s']).decode('utf-8').strip() status = subprocess.check_output(['git', 'status', '-s']).decode('utf-8').strip()
version = "0.0.0.dev0+{}".format(commit) if len(status) > 0 else "0.0.0+{}".format(commit) return "{}.dev0+{}".format(version, commit) if len(status) > 0 else "{}+{}".format(version, commit)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
version = "0.0.0" # finding the git version has utterly failed, use version.txt
return version return version
setup( setup(
name="acertmgr", name="acertmgr",
version=get_git_version(), version=determine_version(),
author="Markus Hauschild", author="Markus Hauschild",
author_email="moepman@binary-kitchen.de", author_email="moepman@binary-kitchen.de",
description="An automated certificate manager using ACME/letsencrypt", description="An automated certificate manager using ACME/letsencrypt",
@ -46,7 +58,10 @@ setup(
long_description=read('README.md'), long_description=read('README.md'),
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
classifiers=[ classifiers=[
"Development Status :: 3 - Alpha", "Development Status :: 4 - Beta",
"Programming Language :: Python",
"Environment :: Console",
"Topic :: Security :: Cryptography",
"License :: OSI Approved :: ISC License", "License :: OSI Approved :: ISC License",
], ],
install_requires=[ install_requires=[

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.9.1