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 version
.write_builtin_version()
29 _run_setup(git_version
)
31 version
.delete_builtin_version()
32 # restore the old mask
35 def _setup_environment():
36 """Adds win32/ to our path for windows only"""
37 if sys
.platform
!= 'win32':
39 path
= os
.environ
['PATH']
40 win32
= os
.path
.join(os
.path
.dirname(__file__
), 'win32')
41 os
.environ
['PATH'] = win32
+ os
.pathsep
+ path
43 def _run_setup(git_version
):
44 """Runs distutils.setup()"""
46 scripts
= ['bin/git-cola']
48 # git-difftool first moved out of git.git's contrib area in git 1.6.3
49 if (os
.environ
.get('INSTALL_GIT_DIFFTOOL', '') or
50 not version
.check('difftool-builtin', git_version
)):
51 scripts
.append('bin/difftool/git-difftool')
52 scripts
.append('bin/difftool/git-difftool--helper')
54 if sys
.platform
== 'win32':
55 scripts
.append('win32/cola')
56 scripts
.append('win32/dirname')
57 scripts
.append('win32/py2exe-setup.py')
58 scripts
.append('win32/py2exe-setup.cmd')
60 setup(name
= 'git-cola',
61 version
= version
.version(),
63 author
= 'David Aguilar and contributors',
64 author_email
= 'davvid@gmail.com',
65 url
= 'http://cola.tuxfamily.org/',
66 description
= 'git-cola',
67 long_description
= 'A highly caffeinated git gui',
70 data_files
= cola_data_files())
73 def cola_data_files():
74 return [_app_path('share/git-cola/qm', '*.qm'),
75 _app_path('share/git-cola/icons', '*.png'),
76 _app_path('share/git-cola/icons', '*.svg'),
77 _app_path('share/git-cola/styles', '*.qss'),
78 _app_path('share/git-cola/styles/images', '*.png'),
79 _app_path('share/applications', '*.desktop'),
80 _app_path('share/doc/git-cola', '*.txt'),
81 _lib_path('cola/*.py'),
82 _lib_path('cola/models/*.py'),
83 _lib_path('cola/controllers/*.py'),
84 _lib_path('cola/views/*.py'),
85 _lib_path('jsonpickle/*.py'),
86 _lib_path('simplejson/*.py')]
89 dirname
= os
.path
.dirname(entry
)
90 app_dir
= os
.path
.join('share/git-cola/lib', dirname
)
91 return (app_dir
, glob(entry
))
94 def _app_path(dirname
, entry
):
95 return (dirname
, glob(os
.path
.join(dirname
, entry
)))
98 def _check_python_version():
99 """Check the minimum Python version
101 pyver
= '.'.join(map(lambda x
: str(x
), sys
.version_info
))
102 if not version
.check('python', pyver
):
103 print >> sys
.stderr
, ('Python version %s or newer required. '
104 'Found %s' % (version
.get('python'), pyver
))
108 def _check_git_version(git_ver
):
109 """Check the minimum GIT version
111 if not version
.check('git', git_ver
):
112 print >> sys
.stderr
, ('GIT version %s or newer required. '
113 'Found %s' % (version
.get('git'), git_ver
))
116 def _check_pyqt_version():
117 """Check the minimum PyQt version
122 from PyQt4
import QtCore
123 pyqtver
= QtCore
.PYQT_VERSION_STR
124 if version
.check('pyqt', pyqtver
):
128 print >> sys
.stderr
, ('PyQt4 version %s or newer required. '
129 'Found %s' % (version
.get('pyqt'), pyqtver
))
133 def _dirty(src
, dst
):
134 if not os
.path
.exists(dst
):
136 srcstat
= os
.stat(src
)
137 dststat
= os
.stat(dst
)
138 return srcstat
[stat
.ST_MTIME
] > dststat
[stat
.ST_MTIME
]
141 def _build_translations():
142 print 'running build_translations'
143 sources
= glob(resources
.share('po', '*.po'))
144 sources
= glob('share/git-cola/po/*.po')
146 dst
= resources
.qm(os
.path
.basename(src
)[:-3])
148 print '\tmsgfmt --qt %s -o %s' % (src
, dst
)
149 utils
.run_cmd(['msgfmt', '--qt', src
, '-o', dst
])
152 """Runs a command and returns its output."""
154 contents
= core
.read_nointr(pipe
).strip()
159 if __name__
== '__main__':