forked from paradoxxxzero/qtile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
develop.py
296 lines (201 loc) · 7.25 KB
/
develop.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
"""
A helper script to set up Qtile's dependencies completely inside a virtualenv.
This removes the need to link to the libraries in the global site-packages and
allows updating dependencies without affecting the system Qtile install (if
you're using Qtile).
Usage
=====
#. Create a virtual environment for Qtile and activate it. (the script
requires the virtual environment to be activated). For example,::
virtualenv --no-site-packages --distribute /some/path/qtile
source /some/path/qtile/bin/activate
#. Navigate to your Qtile development directory and run ``develop.py``::
cd /path/to/development/qtile
python develop.py
This will download the source, build (when required) and install all the
dependencies, excluding some of the ones listed in the ``pip`` requirements
file, which will need to be performed separately.
The downloaded source code will be located at $VIRTUAL_ENV/src.
#. Installing the requirements specified in the ``pip`` requirements file
using::
pip install -r requirements.txt
should complete the development environment setup.
At least the following tools are required to build the dependencies (I may
have missed out a few):
* git
* pkgconfig
* automake
* autoconf
* libtool
* python 2.x (ideally python 2.7)
* gperf
* gtk-doc
The script has been tested using Python 2.7 on an Arch Linux box. For most of
the requirements, I used Arch Linux's ABS and AUR PKGBUILDS to obtain the
required steps.
"""
import subprocess as sp
import os
VENV = None
DEST_DIR = None
#==============================================================================
# Requirements start
#==============================================================================
def xorg_util_macros():
url = 'git://anongit.freedesktop.org/git/xorg/util/macros'
version = 'master'
# ACLOCAL should only be set after xorg_util_macros is installed.
aclocal = os.environ['ACLOCAL']
export('ACLOCAL', '')
get_git_src(url, 'xorg_util_macros', version)
autogen()
configure()
make_make_install()
export('ACLOCAL', aclocal)
def libxau():
url = 'git://anongit.freedesktop.org/git/xorg/lib/libXau'
version = 'master'
get_git_src(url, 'libxau', version)
autogen()
configure()
make_make_install()
def libxdmcp():
url = 'git://anongit.freedesktop.org/git/xorg/lib/libXdmcp'
version = 'master'
get_git_src(url, 'libxdmcp', version)
autogen()
configure()
make_make_install()
def pthread_stubs():
url = 'git://anongit.freedesktop.org/git/xcb/pthread-stubs'
version = 'master'
get_git_src(url, 'pthread_stubs', version)
autogen()
configure()
make_make_install()
def xcb_proto():
url = 'git://anongit.freedesktop.org/git/xcb/proto'
# http://groups.google.com/group/qtile-dev/browse_thread/thread/1a184316e991a119
version = '661fe8dd7727c27467e61a0d20dc91557ce3747f'
get_git_src(url, 'xcb_proto', version)
autogen()
configure()
make_make_install()
def libxcb():
url = 'git://anongit.freedesktop.org/git/xcb/libxcb'
# master doesn't build against the specified xcb_proto version. Requires
# recent xcb_proto version which we can't use.
version = '8c2707773b3621fb8bbda9021d23944f5be34aab'
# First commit that doesn't work: 80322d11636dd638902660d80481080d2fad40fe,
# I think. Used git bisect.
get_git_src(url, 'libxcb', version)
autogen()
configure('--enable-xinput')
make_make_install()
def xcb_util():
# http://aur.archlinux.org/packages/xc/xcb-util-git/PKGBUILD
url = 'git://anongit.freedesktop.org/git/xcb/util'
version = 'master'
get_git_src(url, 'xcb_util', version, cloneargs=['--recursive'])
autogen()
configure()
make_make_install()
def pixman():
url = 'git://anongit.freedesktop.org/git/pixman.git'
version = 'master'
get_git_src(url, 'pixman', version)
autogen()
configure()
make_make_install()
def cairo_xcb():
# http://aur.archlinux.org/packages/ca/cairo-xcb/PKGBUILD
url = 'git://anongit.freedesktop.org/git/cairo'
version = 'master'
get_git_src(url, 'cairo_xcb', version)
autogen()
configure('--enable-xcb')
make_make_install()
def xpyb_ng():
pip_install('-e git://github.com/dequis/xpyb-ng.git#egg=xpyb')
def py2cairo_xcb():
# http://aur.archlinux.org/packages/py/pycairo-xcb-git/PKGBUILD
url = 'git://git.cairographics.org/git/py2cairo'
version = 'master'
get_git_src(url, 'py2cairo_xcb', version)
autogen()
configure('--enable-xcb')
make_make_install()
def pygobject():
url = 'git://git.gnome.org/pygobject'
version = 'PYGOBJECT_2_28_6'
get_git_src(url, 'pygobject', version)
autogen()
configure('--disable-introspection')
make_make_install()
def pygtk():
url = 'git://git.gnome.org/pygtk'
version = 'master'
get_git_src(url, 'pygtk', version)
autogen()
configure()
make_make_install()
def python_xlib():
pip_install('http://downloads.sourceforge.net/python-xlib/python-xlib-0.15rc1.tar.gz')
#==============================================================================
# Requirements end
#==============================================================================
def pip_install(*args):
call('pip install {0}'.format(' '.join(args)))
def export(key, value):
print 'export {0}={1}'.format(key, value)
os.environ[key] = value
def get_git_src(url, destination, revision, cloneargs=[], checkoutargs=[]):
# If directory exists checkout version, else clone and checkout version.
d = dest(destination)
if not os.path.exists(d):
git_clone(url, d, *cloneargs)
os.chdir(d)
git_checkout(revision, *checkoutargs)
def git_clone(url, dest, *args):
call('git clone {0} {1} {2}'.format(url, dest, ' '.join(args)))
def git_checkout(revision, *args):
call('git checkout {0} {1}'.format(revision, ' '.join(args)))
def dest(d):
return os.path.join(DEST_DIR, d)
def autogen(*args):
call('./autogen.sh {0}'.format(' '.join(args)))
def configure(*args):
call('./configure --prefix={0} {1}'.format(VENV, ' '.join(args)))
def make_make_install():
call('make')
call('make install')
def call(cmd):
print cmd
out = sp.call(cmd, shell=True)
if out != 0:
raise Exception('Ah! $@#%^&!! Error!!')
return out
def main():
global VENV
global DEST_DIR
# Assumes the virtualenv has been activated.
VENV = os.environ['VIRTUAL_ENV']
DEST_DIR = os.path.join(VENV, 'src')
bin = os.path.join(VENV, 'bin')
python = os.path.join(bin, 'python')
lib = os.path.join(VENV, 'lib')
pkgconfig = os.path.join(lib, 'pkgconfig')
aclocal = os.path.join(VENV, 'share', 'aclocal')
# Most of Qtile's requirements. Includes some but not all the requirements
# in the pip requirements file. Order matters.
reqs = [xorg_util_macros, libxau, libxdmcp, pthread_stubs, xcb_proto,
libxcb, xcb_util, xpyb_ng, pixman, cairo_xcb, py2cairo_xcb,
pygobject, pygtk, python_xlib]
export('ACLOCAL', 'aclocal -I {0}'.format(aclocal))
export('PKG_CONFIG_PATH', pkgconfig)
export('LD_LIBRARY_PATH', lib)
export('PYTHON', python)
for r in reqs:
r()
if __name__ == '__main__':
main()