diff --git a/setup.py b/setup.py index f6f07f85..0386ae8a 100644 --- a/setup.py +++ b/setup.py @@ -17,33 +17,40 @@ """ import os +import sys +import re from setuptools import setup -#function to find the version in gmv_cmd +# function to find the version in gmv_cmd def find_version(path): - with open(path, 'r') as f: + with open(path) as f: for line in f: - index = line.find('GMVAULT_VERSION = "') - if index > -1: - print(line[index+19:-2]) - res = line[index+19:-2] - return res.strip() + match = re.match(r'GMVAULT_VERSION\s=\s"(?P[\d.]+)"', line) + if match is not None: + version = match.groupdict().get('version') + return version raise Exception("Cannot find GMVAULT_VERSION in %s\n" % path) -path = os.path.join(os.path.dirname(__file__), './src/gmv/gmvault_utils.py') -print("PATH = %s\n" % path) +top_dir = os.path.dirname(os.path.realpath(__file__)) -version = find_version(os.path.join(os.path.dirname(__file__), - './src/gmv/gmvault_utils.py')) +utils_path = os.path.join(top_dir, 'src/gmv/gmvault_utils.py') +print("PATH = %s\n" % utils_path) -print("Gmvault version = %s\n" % version) -README = os.path.join(os.path.dirname(__file__), './README.md') -if os.path.exists(README): - with open(README, 'r') as f: - long_description = f.read() + 'nn' +try: + version = find_version(utils_path) +except Exception as e: + print(str(e)) + sys.exit(1) else: + print("Gmvault version = %s\n" % version) + +readme_path = os.path.join(top_dir, 'README.md') +try: + with open(readme_path) as f: + long_description = f.read() + '\n\n' +except IOError as e: long_description = 'Gmvault' setup(name='gmvault', @@ -51,21 +58,21 @@ def find_version(path): description=("Tool to backup and restore your Gmail emails at will. http://www.gmvault.org for more info"), long_description=long_description, classifiers=[ - "Programming Language :: Python", - "License :: OSI Approved :: GNU Affero General Public License v3", - "Topic :: Communications :: Email", - "Topic :: Communications :: Email :: Post-Office :: IMAP", - ], + "Programming Language :: Python", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Topic :: Communications :: Email", + "Topic :: Communications :: Email :: Post-Office :: IMAP", + ], keywords='gmail, email, backup, gmail backup, imap', author='Guillaume Aubert', author_email='guillaume.aubert@gmail.com', url='http://www.gmvault.org', license='AGPLv3', - packages=['gmv','gmv.conf', 'gmv.conf.utils'], + packages=['gmv', 'gmv.conf', 'gmv.conf.utils'], package_dir = {'gmv': './src/gmv'}, scripts=['./etc/scripts/gmvault'], package_data={'': ['release-note.txt']}, include_package_data=True, - #install_requires=['argparse', 'Logbook==0.4.1', 'IMAPClient==0.9.2','gdata==2.0.17'] + # install_requires=['argparse', 'Logbook==0.4.1', 'IMAPClient==0.9.2','gdata==2.0.17'] install_requires=['argparse', 'Logbook==0.10.1', 'IMAPClient==0.13', 'chardet==2.3.0'] )