Mercurial > wikked
comparison setup.py @ 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 | 9055434ebbd0 |
children | a78a4b20b720 |
comparison
equal
deleted
inserted
replaced
357:666a9d0981bb | 358:0698b546e278 |
---|---|
1 import os | 1 import os |
2 import os.path | 2 import os.path |
3 import time | |
4 import subprocess | |
5 from setuptools import setup, find_packages | 3 from setuptools import setup, find_packages |
6 | 4 |
7 | 5 |
8 def read(fname): | 6 def read(fname): |
9 with open(os.path.join(os.path.dirname(__file__), fname)) as fp: | 7 with open(os.path.join(os.path.dirname(__file__), fname)) as fp: |
10 return fp.read() | 8 return fp.read() |
11 | 9 |
12 | 10 |
13 def runcmd(cmd): | |
14 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, | |
15 stderr=subprocess.PIPE) | |
16 out, err = p.communicate() | |
17 return out, err | |
18 | |
19 | |
20 # Figure out the version. | |
21 # (this is loosely based on what Mercurial does) | |
22 version = None | |
23 try: | |
24 if os.path.isdir(os.path.join(os.path.dirname(__file__), '.hg')): | |
25 cmd = ['hg', 'log', '-r', '.', '--template', '{tags}\n'] | |
26 tags, err = runcmd(cmd) | |
27 versions = [t for t in tags.split() if t[0].isdigit()] | |
28 | |
29 cmd = ['hg', 'id', '-i'] | |
30 hgid, err = runcmd(cmd) | |
31 hgid = hgid.strip() | |
32 | |
33 if versions: | |
34 # Use tag found at the current revision. Add dirty flag if any. | |
35 version = versions[-1] | |
36 if hgid.endswith('+'): | |
37 version += '+' | |
38 else: | |
39 # Use latest tag. | |
40 cmd = ['hg', 'parents', '--template', '{latesttag}+{latesttagdistance}-'] | |
41 version, err = runcmd(cmd) | |
42 version += hgid | |
43 if version.endswith('+'): | |
44 version += time.strftime('%Y%m%d') | |
45 except OSError: | |
46 # Mercurial isn't installed, or not in the PATH. | |
47 version = None | |
48 | |
49 if version: | |
50 f = open("wikked/__version__.py", "w") | |
51 f.write('# this file is autogenerated by setup.py\n') | |
52 f.write('version = "%s"\n' % version) | |
53 f.close() | |
54 | |
55 | |
56 try: | |
57 from wikked import __version__ | |
58 version = __version__.version | |
59 except ImportError: | |
60 version = 'unknown' | |
61 | |
62 | |
63 setup( | 11 setup( |
64 name='Wikked', | 12 name='Wikked', |
65 version=version, | |
66 description=("A wiki engine entirely managed with text files " | 13 description=("A wiki engine entirely managed with text files " |
67 "stored in a revision control system."), | 14 "stored in a revision control system."), |
68 author='Ludovic Chabant', | 15 author='Ludovic Chabant', |
69 author_email='ludovic@chabant.com', | 16 author_email='ludovic@chabant.com', |
70 url="https://github.com/ludovicchabant/Wikked", | 17 url="https://github.com/ludovicchabant/Wikked", |
71 license="Apache 2.0", | 18 license="Apache 2.0", |
72 keywords="wiki mercurial hg git", | 19 keywords="wiki mercurial hg git", |
73 packages=find_packages(exclude=["tests"]), | 20 packages=find_packages(exclude=["tests"]), |
21 setup_requires=['setuptools_scm'], | |
22 use_scm_version={ | |
23 'write_to': 'wikked/__version__.py'}, | |
74 install_requires=[ | 24 install_requires=[ |
75 'Flask==0.10.1', | 25 'Flask==0.10.1', |
76 'Flask-Bcrypt==0.5.2', | 26 'Flask-Bcrypt==0.5.2', |
77 'Flask-Login==0.2.10', | 27 'Flask-Login==0.2.10', |
78 'Flask-Script==0.5.1', | 28 'Flask-Script==0.5.1', |
88 'repoze.lru==0.6', | 38 'repoze.lru==0.6', |
89 'python-hglib'], | 39 'python-hglib'], |
90 include_package_data=True, | 40 include_package_data=True, |
91 zip_safe=False, | 41 zip_safe=False, |
92 classifiers=[ | 42 classifiers=[ |
93 'Development Status :: 3 - Alpha', | 43 'Development Status :: 3 - Alpha', |
94 'License :: OSI Approved :: Apache Software License', | 44 'License :: OSI Approved :: Apache Software License', |
95 'Environment :: Console', | 45 'Environment :: Console', |
96 'Operating System :: MacOS :: MacOS X', | 46 'Operating System :: MacOS :: MacOS X', |
97 'Operating System :: Unix', | 47 'Operating System :: Unix', |
98 'Operating System :: POSIX', | 48 'Operating System :: POSIX', |
99 'Operating System :: Microsoft :: Windows', | 49 'Operating System :: Microsoft :: Windows', |
100 'Programming Language :: Python', | 50 'Programming Language :: Python'], |
101 ], | |
102 entry_points={ | 51 entry_points={ |
103 'console_scripts': [ | 52 'console_scripts': [ |
104 'wk = wikked.witch:real_main' | 53 'wk = wikked.witch:real_main'] |
105 ] | 54 }, |
106 }, | |
107 ) | 55 ) |
108 | 56 |