Mercurial > wikked
changeset 358:0698b546e278
Simplify `setup.py` by using `setuptools_scm`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 20 Sep 2015 19:11:28 -0700 |
parents | 666a9d0981bb |
children | 90926c17779c |
files | setup.py |
diffstat | 1 files changed, 14 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py Sun Sep 20 14:40:08 2015 -0700 +++ b/setup.py Sun Sep 20 19:11:28 2015 -0700 @@ -1,7 +1,5 @@ import os import os.path -import time -import subprocess from setuptools import setup, find_packages @@ -10,67 +8,19 @@ return fp.read() -def runcmd(cmd): - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = p.communicate() - return out, err - - -# Figure out the version. -# (this is loosely based on what Mercurial does) -version = None -try: - if os.path.isdir(os.path.join(os.path.dirname(__file__), '.hg')): - cmd = ['hg', 'log', '-r', '.', '--template', '{tags}\n'] - tags, err = runcmd(cmd) - versions = [t for t in tags.split() if t[0].isdigit()] - - cmd = ['hg', 'id', '-i'] - hgid, err = runcmd(cmd) - hgid = hgid.strip() - - if versions: - # Use tag found at the current revision. Add dirty flag if any. - version = versions[-1] - if hgid.endswith('+'): - version += '+' - else: - # Use latest tag. - cmd = ['hg', 'parents', '--template', '{latesttag}+{latesttagdistance}-'] - version, err = runcmd(cmd) - version += hgid - if version.endswith('+'): - version += time.strftime('%Y%m%d') -except OSError: - # Mercurial isn't installed, or not in the PATH. - version = None - -if version: - f = open("wikked/__version__.py", "w") - f.write('# this file is autogenerated by setup.py\n') - f.write('version = "%s"\n' % version) - f.close() - - -try: - from wikked import __version__ - version = __version__.version -except ImportError: - version = 'unknown' - - setup( name='Wikked', - version=version, description=("A wiki engine entirely managed with text files " - "stored in a revision control system."), + "stored in a revision control system."), author='Ludovic Chabant', author_email='ludovic@chabant.com', url="https://github.com/ludovicchabant/Wikked", license="Apache 2.0", keywords="wiki mercurial hg git", packages=find_packages(exclude=["tests"]), + setup_requires=['setuptools_scm'], + use_scm_version={ + 'write_to': 'wikked/__version__.py'}, install_requires=[ 'Flask==0.10.1', 'Flask-Bcrypt==0.5.2', @@ -90,19 +40,17 @@ include_package_data=True, zip_safe=False, classifiers=[ - 'Development Status :: 3 - Alpha', - 'License :: OSI Approved :: Apache Software License', - 'Environment :: Console', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Unix', - 'Operating System :: POSIX', - 'Operating System :: Microsoft :: Windows', - 'Programming Language :: Python', - ], + 'Development Status :: 3 - Alpha', + 'License :: OSI Approved :: Apache Software License', + 'Environment :: Console', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Unix', + 'Operating System :: POSIX', + 'Operating System :: Microsoft :: Windows', + 'Programming Language :: Python'], entry_points={ 'console_scripts': [ - 'wk = wikked.witch:real_main' - ] - }, + 'wk = wikked.witch:real_main'] + }, )