8 from distutils
.core
import setup
9 from distutils
.command
import build_scripts
10 build_scripts
.first_line_re
= re
.compile('^should not match$')
12 from cola
import version
13 from cola
import utils
14 from cola
import resources
18 # ensure readable files
19 old_mask
= os
.umask(0022)
20 git_version
= version
.git_version()
21 if sys
.argv
[1] in ('install', 'build'):
23 _check_python_version()
24 _check_git_version(git_version
)
26 _build_translations() # msgfmt: .po -> .qm
28 if os
.path
.exists('.git'):
29 version
.write_builtin_version()
30 _run_setup(git_version
)
32 if os
.path
.exists('.git'):
33 version
.delete_builtin_version()
34 # restore the old mask
37 def _setup_environment():
38 """Adds win32/ to our path for windows only"""
39 if sys
.platform
!= 'win32':
41 path
= os
.environ
['PATH']
42 win32
= os
.path
.join(os
.path
.dirname(__file__
), 'win32')
43 os
.environ
['PATH'] = win32
+ os
.pathsep
+ path
45 def _run_setup(git_version
):
46 """Runs distutils.setup()"""
48 scripts
= ['bin/git-cola']
50 # git-difftool first moved out of git.git's contrib area in git 1.6.3
51 if (os
.environ
.get('INSTALL_GIT_DIFFTOOL', '') or
52 not version
.check('difftool-builtin', git_version
)):
53 scripts
.append('bin/difftool/git-difftool')
54 scripts
.append('bin/difftool/git-difftool--helper')
56 if sys
.platform
== 'win32':
57 scripts
.append('win32/cola')
58 scripts
.append('win32/dirname')
59 scripts
.append('win32/py2exe-setup.py')
60 scripts
.append('win32/py2exe-setup.cmd')
62 setup(name
= 'git-cola',
63 version
= version
.version(),
65 author
= 'David Aguilar and contributors',
66 author_email
= 'davvid@gmail.com',
67 url
= 'http://cola.tuxfamily.org/',
68 description
= 'git-cola',
69 long_description
= 'A highly caffeinated git gui',
72 data_files
= cola_data_files())
75 def cola_data_files():
76 data
= [_app_path('share/git-cola/qm', '*.qm'),
77 _app_path('share/git-cola/icons', '*.png'),
78 _app_path('share/git-cola/icons', '*.svg'),
79 _app_path('share/git-cola/styles', '*.qss'),
80 _app_path('share/git-cola/styles/images', '*.png'),
81 _app_path('share/applications', '*.desktop'),
82 _app_path('share/doc/git-cola', '*.txt'),
83 _lib_path('cola/*.py'),
84 _lib_path('cola/models/*.py'),
85 _lib_path('cola/controllers/*.py'),
86 _lib_path('cola/views/*.py'),
87 _lib_path('jsonpickle/*.py'),
88 _lib_path('simplejson/*.py')]
90 if sys
.platform
== 'darwin':
91 data
.append(_app_path('libexec/git-cola', 'ssh-askpass-darwin'))
93 data
.append(_app_path('libexec/git-cola', 'ssh-askpass'))
97 dirname
= os
.path
.dirname(entry
)
98 app_dir
= os
.path
.join('share/git-cola/lib', dirname
)
99 return (app_dir
, glob(entry
))
102 def _app_path(dirname
, entry
):
103 return (dirname
, glob(os
.path
.join(dirname
, entry
)))
106 def _check_python_version():
107 """Check the minimum Python version
109 pyver
= '.'.join(map(lambda x
: str(x
), sys
.version_info
))
110 if not version
.check('python', pyver
):
111 print >> sys
.stderr
, ('Python version %s or newer required. '
112 'Found %s' % (version
.get('python'), pyver
))
116 def _check_git_version(git_ver
):
117 """Check the minimum GIT version
119 if not version
.check('git', git_ver
):
120 print >> sys
.stderr
, ('GIT version %s or newer required. '
121 'Found %s' % (version
.get('git'), git_ver
))
124 def _check_pyqt_version():
125 """Check the minimum PyQt version
130 from PyQt4
import QtCore
131 pyqtver
= QtCore
.PYQT_VERSION_STR
132 if version
.check('pyqt', pyqtver
):
136 print >> sys
.stderr
, ('PyQt4 version %s or newer required. '
137 'Found %s' % (version
.get('pyqt'), pyqtver
))
141 def _dirty(src
, dst
):
142 if not os
.path
.exists(dst
):
144 srcstat
= os
.stat(src
)
145 dststat
= os
.stat(dst
)
146 return srcstat
[stat
.ST_MTIME
] > dststat
[stat
.ST_MTIME
]
149 def _build_translations():
150 print 'running build_translations'
151 sources
= glob(resources
.share('po', '*.po'))
152 sources
= glob('share/git-cola/po/*.po')
154 dst
= resources
.qm(os
.path
.basename(src
)[:-3])
156 print '\tmsgfmt --qt %s -o %s' % (src
, dst
)
157 utils
.run_cmd(['msgfmt', '--qt', src
, '-o', dst
])
160 """Runs a command and returns its output."""
162 contents
= core
.read_nointr(pipe
).strip()
167 if __name__
== '__main__':