10 from distutils
.core
import setup
11 from distutils
.command
import build_scripts
14 from extras
import cmdclass
18 # Prevent distuils from changing "#!/usr/bin/env python"
19 build_scripts
.first_line_re
= re
.compile('^should not match$')
21 # Look for modules in the root and thirdparty directories
22 srcdir
= os
.path
.dirname(os
.path
.abspath(__file__
))
23 sys
.path
.insert(0, os
.path
.join(srcdir
, 'thirdparty'))
24 sys
.path
.insert(0, srcdir
)
26 from cola
import version
28 # --standalone prevents installing thirdparty libraries
29 if '--standalone' in sys
.argv
:
30 sys
.argv
.remove('--standalone')
37 # ensure readable files
38 old_mask
= os
.umask(0022)
40 _check_python_version()
45 # First see if there is a version file (included in release tarballs),
46 # then try git-describe, then default.
47 builtin_version
= os
.path
.join('cola', 'builtin_version.py')
48 if os
.path
.exists('version') and not os
.path
.exists(builtin_version
):
49 shutil
.copy('version', builtin_version
)
51 elif os
.path
.exists('.git'):
52 version
.write_builtin_version()
55 # restore the old mask
58 def _setup_environment():
59 """Adds win32/ to our path for windows only"""
60 if sys
.platform
!= 'win32':
62 path
= os
.environ
['PATH']
63 win32
= os
.path
.join(srcdir
, 'win32')
64 os
.environ
['PATH'] = win32
+ os
.pathsep
+ path
67 """Runs distutils.setup()"""
69 scripts
= ['bin/git-cola']
71 # git-difftool first moved out of git.git's contrib area in git 1.6.3
72 if (os
.environ
.get('INSTALL_GIT_DIFFTOOL', '') or
73 not version
.check('difftool-builtin', version
.git_version())):
74 scripts
.append('bin/difftool/git-difftool')
75 scripts
.append('bin/difftool/git-difftool--helper')
77 if sys
.platform
== 'win32':
78 scripts
.append('win32/cola')
79 scripts
.append('win32/dirname')
80 scripts
.append('win32/py2exe-setup.py')
81 scripts
.append('win32/py2exe-setup.cmd')
83 setup(name
= 'git-cola',
84 version
= version
.version(),
85 description
= 'A highly caffeinated git GUI',
87 author
= 'The git-cola community',
88 author_email
= 'git-cola@googlegroups.com',
89 url
= 'http://cola.tuxfamily.org/',
90 long_description
= 'A highly caffeinated git GUI',
93 data_files
= cola_data_files())
96 def cola_data_files(standalone
=_standalone
):
97 data
= [_app_path('share/git-cola/icons', '*.png'),
98 _app_path('share/git-cola/icons', '*.svg'),
99 _app_path('share/git-cola/styles', '*.qss'),
100 _app_path('share/git-cola/styles/images', '*.png'),
101 _app_path('share/applications', '*.desktop'),
102 _app_path('share/doc/git-cola', '*.txt'),
103 _app_path('share/locale', '*/LC_MESSAGES/git-cola.mo'),
105 _package('cola.models'),
106 _package('cola.controllers'),
107 _package('cola.views')]
110 data
.extend([_thirdparty_package('jsonpickle'),
111 _thirdparty_package('simplejson')])
113 if sys
.platform
== 'darwin':
114 data
.append(_app_path('share/git-cola/bin', 'ssh-askpass-darwin'))
116 data
.append(_app_path('share/git-cola/bin', 'ssh-askpass'))
120 def _package(package
, subdir
=None):
121 subdirs
= package
.split('.')
122 app_dir
= os
.path
.join('share', 'git-cola', 'lib', *subdirs
)
124 subdirs
.insert(0, subdir
)
125 src_dir
= os
.path
.join(*subdirs
)
126 return (app_dir
, glob(os
.path
.join(src_dir
, '*.py')))
129 def _thirdparty_package(package
):
130 return _package(package
, subdir
='thirdparty')
133 def _app_path(dirname
, entry
):
134 return (dirname
, glob(os
.path
.join(dirname
, entry
)))
137 def _check_python_version():
138 """Check the minimum Python version
140 pyver
= platform
.python_version()
141 if not version
.check('python', pyver
):
142 print >> sys
.stderr
, ('Python version %s or newer required. '
143 'Found %s' % (version
.get('python'), pyver
))
147 def _check_git_version():
148 """Check the minimum GIT version
150 if not version
.check('git', version
.git_version()):
151 print >> sys
.stderr
, ('GIT version %s or newer required. '
152 'Found %s' % (version
.get('git'),
153 version
.git_version()))
157 def _check_pyqt_version():
158 """Check the minimum PyQt version
163 from PyQt4
import QtCore
164 pyqtver
= QtCore
.PYQT_VERSION_STR
165 if version
.check('pyqt', pyqtver
):
169 print >> sys
.stderr
, ('PyQt4 version %s or newer required. '
170 'Found %s' % (version
.get('pyqt'), pyqtver
))
174 if __name__
== '__main__':