From e5625bd7cfc207f30e013a51fd8104362f3f4e91 Mon Sep 17 00:00:00 2001 From: Christophe Siraut Date: Fri, 20 Jul 2018 10:45:16 +0200 Subject: [PATCH] eobuilderize setup.py --- debian/changelog | 2 +- setup.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index e08e8f9..eb28437 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -certbot-haproxy (0.1.1-1) unstable; urgency=low +certbot-haproxy (0.1.2-1) unstable; urgency=low * source package automatically created by stdeb 0.8.5 diff --git a/setup.py b/setup.py index 350df5e..5285ea3 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,48 @@ +import os +import subprocess import sys - from setuptools import setup from setuptools import find_packages +from distutils.command.sdist import sdist own_version = '0.1.2' certbot_version = '0.8.1' +class eo_sdist(sdist): + def run(self): + if os.path.exists('VERSION'): + os.remove('VERSION') + version = get_version() + version_file = open('VERSION', 'w') + version_file.write(version) + version_file.close() + sdist.run(self) + if os.path.exists('VERSION'): + os.remove('VERSION') + +def get_version(): + if os.path.exists('VERSION'): + version_file = open('VERSION', 'r') + version = version_file.read() + version_file.close() + return version + if os.path.exists('.git'): + p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE) + result = p.communicate()[0] + if p.returncode == 0: + version = result.split()[0][1:] + version = version.replace('-', '.') + return version + return '0' + +def data_tree(destdir, sourcedir): + extensions = ['.css', '.png', '.jpeg', '.jpg', '.gif', '.xml', '.html', '.js'] + r = [] + for root, dirs, files in os.walk(sourcedir): + l = [os.path.join(root, x) for x in files if os.path.splitext(x)[1] in extensions] + r.append((root.replace(sourcedir, destdir, 1), l)) + return r + # Please update tox.ini when modifying dependency version requirements install_requires = [ 'acme>={0}'.format(certbot_version), @@ -43,7 +80,7 @@ haproxy_installer = 'certbot_haproxy.installer:HAProxyInstaller' setup( name='certbot-haproxy', - version=own_version, + version=get_version(), description="HAProxy plugin for Certbot", long_description=long_description, url='https://code.greenhost.net/open/certbot-haproxy', @@ -70,6 +107,7 @@ setup( packages=find_packages(), include_package_data=True, + data_files=data_tree('share/certbot-haproxy/docs/', 'docs/'), install_requires=install_requires, extras_require={ 'docs': docs_extras, @@ -81,4 +119,7 @@ setup( ], }, # test_suite='certbot_haproxy', + cmdclass={ + 'sdist': eo_sdist, + } )