forked from artynusov/MacTimeLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
63 lines (44 loc) · 1.44 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
import os
import sys
import subprocess
from setuptools import setup
from plistlib import Plist
def git(*args):
result = None
try:
result = subprocess.check_output(args).strip()
except Exception, e:
print >> sys.stderr, ('Unable to run git: {0}'.format(e))
return result
def generate_plist(plist_file):
"""Read plist from file and set CFBundleVersion to HEAD commit hash"""
version = git('git', 'describe', '--abbrev=0', '--tags')
commit_hash = git('git', 'rev-parse', '--short', 'HEAD')
if version is None or commit_hash is None:
sys.exit(-1)
plist = Plist.fromFile(plist_file)
plist.update(dict(
CFBundleShortVersionString=version,
CFBundleVersion=commit_hash,
))
return plist
APP = ['main.py']
DATA_FILES = (['data/English.lproj', 'data/Credits.html', 'data/MacTimeLog Help'])
OPTIONS = {'argv_emulation': True, 'iconfile': 'data/iconset.icns',
'plist': generate_plist('Info.plist'),
'packages': ['objc', 'durus'],
'excludes': ['local_settings']}
if __name__ == '__main__':
setup(
app=APP,
data_files=[] if os.environ.get("SCONS") else DATA_FILES,
install_requires=['durus==3.9', 'pyobjc-framework-Cocoa', 'py2app'],
options={'py2app': OPTIONS},
name='MacTimeLog',
author='Artem Yunusov'
)