Merge lp:~nataliabidart/ubuntu-sso-client/build-on-linux into lp:ubuntu-sso-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Roberto Alsina
Approved revision: 741
Merged at revision: 740
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/build-on-linux
Merge into: lp:ubuntu-sso-client
Diff against target: 401 lines (+117/-147)
3 files modified
run-tests (+1/-0)
setup.py (+115/-146)
ubuntu_sso/qt/controllers.py (+1/-1)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/build-on-linux
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+68311@code.launchpad.net

Commit message

- setup.py is now building on linux!

Description of the change

To test, run in linux:

./setup.py build

You should get an output like this:

nessita@dali:~/canonical/ussoc/build-on-linux$ ./setup.py build
ERROR: Python module pythoncom not found
ERROR: Python module win32com.server.policy not found
ERROR: Python module win32com.client not found
(15067)/kdeui (Wallet): The kwalletd service has been disabled
(15067)/kdeui (Wallet): The kwalletd service has been disabled
(15067)/kdeui (Wallet): The kwalletd service has been disabled
(15067)/kdeui (Wallet): The kwalletd service has been disabled
(15067)/kdeui (Wallet): The kwalletd service has been disabled
(15067)/kdeui (Wallet): The kwalletd service has been disabled
ERROR: Python module _winreg not found
ERROR: Python module ubuntu_sso.main.windows not found
ERROR: Python module ubuntu_sso.main.windows not found
ERROR: Python module ubuntu_sso.main.windows not found
ERROR: Python module ubuntu_sso.networkstate.windows not found
ERROR: Python module _winreg not found
ERROR: Python module ubuntu_sso.main.windows not found
running build
Compiled data/qt/error_message.ui into ubuntu_sso/qt/error_message_ui.py
Compiled data/qt/choose_sign_in.ui into ubuntu_sso/qt/choose_sign_in_ui.py
Compiled data/qt/setup_account.ui into ubuntu_sso/qt/setup_account_ui.py
Compiled data/qt/reset_password.ui into ubuntu_sso/qt/reset_password_ui.py
Compiled data/qt/terms_and_conditions.ui into ubuntu_sso/qt/terms_and_conditions_ui.py
Compiled data/qt/email_verification.ui into ubuntu_sso/qt/email_verification_ui.py
Compiled data/qt/success_message.ui into ubuntu_sso/qt/success_message_ui.py
Compiled data/qt/current_user_sign_in.ui into ubuntu_sso/qt/current_user_sign_in_ui.py
Compiled data/qt/forgotten_password.ui into ubuntu_sso/qt/forgotten_password_ui.py
running build_py
copying ubuntu_sso/qt/controllers.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/error_message_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/terms_and_conditions_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/forgotten_password_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/current_user_sign_in_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/reset_password_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/choose_sign_in_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/email_verification_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/setup_account_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
copying ubuntu_sso/qt/success_message_ui.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/qt
running build_i18n
intltool-update -p -g ubuntu-sso-client
running build_icons
running build_help
WARNING: the following files are not recognized by DistUtilsExtra.auto:
  _trial_temp/tmp/_trial_marker
  _trial_temp/tmp/test.log
  _trial_temp/xdg_cache/sso/sso-client.log
  bin/windows-ubuntu-sso-login
  pylintrc
  run-tests
  run-tests.bat
  ubuntu_sso/main/tests/ubuntuone.reg
  ubuntu_sso/tests/bin/show_gui
  ubuntu_sso/tests/bin/show_nm_state
  ubuntu_sso/tests/files/captcha.png
nessita@dali:~/canonical/ussoc/build-on-linux$

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

Hey, it does! :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'run-tests'
2--- run-tests 2011-04-27 03:31:27 +0000
3+++ run-tests 2011-07-19 00:45:37 +0000
4@@ -27,6 +27,7 @@
5 fi
6
7 style_check() {
8+ ./setup.py clean
9 u1lint
10 if [ -x `which pep8` ]; then
11 pep8 --repeat bin/ $MODULE
12
13=== modified file 'setup.py'
14--- setup.py 2011-06-24 19:02:21 +0000
15+++ setup.py 2011-07-19 00:45:37 +0000
16@@ -1,10 +1,11 @@
17 #!/usr/bin/env python
18 # setup.py - Build system for Ubuntu SSO Client package
19 #
20-# Author: Natalia B. Bidart <natalia.bidart@canonical.com>
21-# Author: Manuel de la Pena <manuel@canonical.com>
22+# Authors: Natalia B. Bidart <natalia.bidart@canonical.com>
23+# Manuel de la Pena <manuel@canonical.com>
24+# Alejandro J. Cura <alecu@canonical.com>
25 #
26-# Copyright 2010 Canonical Ltd.
27+# Copyright 2010-2011 Canonical Ltd.
28 #
29 # This program is free software: you can redistribute it and/or modify it
30 # under the terms of the GNU General Public License version 3, as published
31@@ -17,9 +18,10 @@
32 #
33 # You should have received a copy of the GNU General Public License along
34 # with this program. If not, see <http://www.gnu.org/licenses/>.
35-"""setup.py"""
36-
37-import cgi
38+"""Setup.py: build, distribute, clean."""
39+
40+# pylint: disable=W0404, W0511
41+
42 import os
43 import sys
44
45@@ -34,71 +36,42 @@
46 'needs DistUtilsExtra.auto >= 2.18'
47
48 from distutils import log
49-from distutils.command import clean
50-from distutils.spawn import find_executable
51-
52-# Defining variables for various rules here, similar to a Makefile.am
53-LINUX_CLEANFILES = ['data/com.ubuntu.sso.service', 'po/ubuntu-sso-client.pot',
54- 'MANIFEST']
55-
56-
57-# pylint: disable=W0511
58-# This needs some serious cleanup
59-class SSOLinuxBuild(build_extra.build_extra):
60- """Build the extra files required on Linux.."""
61-
62- description = 'build extra files needed by ubuntu-sso-client'
63-
64- def __init__(self, *args):
65- build_extra.build_extra.__init__(self, *args)
66-
67- def run(self):
68- """Do the build."""
69- sed = find_executable('sed')
70- if sed is None:
71- sys.stderr.write('Cannont find sed; required to build')
72- sys.exit(-1)
73-
74- in_file = 'data/com.ubuntu.sso.service.in'
75- out_file = 'data/com.ubuntu.sso.service'
76- replaced_path = '/usr/lib/ubuntu-sso-client'
77-
78- cmd = "%(cmd)s -e 's|\@libexecdir\@|%(rep)s|g' < %(in)s > %(out)s"
79- os.system( cmd %
80- {'cmd' : sed,
81- 'rep' : replaced_path,
82- 'in' : in_file,
83- 'out' : out_file,
84- }
85- )
86-
87- # Run the parent build command
88- build_extra.build_extra.run(self)
89-
90-
91-class SSOLinuxClean(clean.clean):
92- """Class to clean up after the build."""
93-
94- description = 'Clean up built files.'
95-
96- def run(self):
97- """Clean up the built files."""
98- for built_file in LINUX_CLEANFILES:
99- if os.path.exists(built_file):
100- os.unlink(built_file)
101-
102- # Run the parent clean command
103- clean.clean.run(self)
104-
105-
106-class SSOWindowsBuild(build_extra.build_extra):
107+
108+POT_FILE = 'po/ubuntu-sso-client.pot'
109+SERVICE_FILE = 'data/com.ubuntu.sso.service'
110+
111+CLEANFILES = [SERVICE_FILE, POT_FILE, 'MANIFEST']
112+QT_UI_DIR = os.path.join('ubuntu_sso', 'qt')
113+
114+def replace_prefix(prefix):
115+ """Replace every '@prefix@' with prefix within 'filename' content."""
116+ # replace .service file, DATA_DIR constant
117+ for filename in (SERVICE_FILE,):
118+ with open(filename + '.in') as in_file:
119+ content = in_file.read()
120+ with open(filename, 'w') as out_file:
121+ out_file.write(content.replace('@prefix@', prefix))
122+
123+
124+class SSOInstall(DistUtilsExtra.auto.install_auto):
125+ """Class to install proper files."""
126+
127+ def run(self):
128+ """Do the install.
129+
130+ Read from *.service.in and generate .service files by replacing
131+ @prefix@ by self.prefix.
132+
133+ """
134+ replace_prefix(self.prefix)
135+ DistUtilsExtra.auto.install_auto.run(self)
136+
137+
138+class SSOBuild(build_extra.build_extra):
139 """Build PyQt (.ui) files and resources."""
140
141 description = "build PyQt GUIs (.ui) and resources (.qrc)"
142
143- def __init__(self, *args):
144- build_extra.build_extra.__init__(self, *args)
145-
146 def compile_ui(self, ui_file, py_file=None):
147 """Compile the .ui files to python modules."""
148 # Search for pyuic4 in python bin dir, then in the $Path.
149@@ -107,7 +80,7 @@
150 # python file in the qt moodule
151 py_file = os.path.split(ui_file)[1]
152 py_file = os.path.splitext(py_file)[0] + '_ui.py'
153- py_file = os.path.join('ubuntu_sso', 'qt', py_file)
154+ py_file = os.path.join(QT_UI_DIR, py_file)
155 # we indeed want to catch Exception, is ugly but we need it
156 # pylint: disable=W0703
157 try:
158@@ -120,7 +93,7 @@
159 fp.close()
160 log.info('Compiled %s into %s', ui_file, py_file)
161 except Exception, e:
162- self.warn('Unable to compile user interface %s: %s', py_file, e)
163+ self.warn('Unable to compile user interface %s: %s' % (py_file, e))
164 if not os.path.exists(py_file) or not file(py_file).read():
165 raise SystemExit(1)
166 return
167@@ -133,13 +106,14 @@
168 if py_file is None:
169 py_file = os.path.split(qrc_file)[1]
170 py_file = os.path.splitext(py_file)[0] + '_rc.py'
171- py_file = os.path.join('ubuntu_sso', 'qt', py_file)
172+ py_file = os.path.join(QT_UI_DIR, py_file)
173 path = os.getenv('PATH')
174- os.putenv('PATH', path + ';' + os.path.join(
175- os.path.dirname(PyQt4.__file__),'bin'))
176+ os.putenv('PATH', path + os.path.pathsep + os.path.join(
177+ os.path.dirname(PyQt4.__file__), 'bin'))
178 if os.system('pyrcc4 "%s" -o "%s"' % (qrc_file, py_file)) > 0:
179- self.warn('Unable to generate python module %s '
180- + 'for resource file %s', py_file, qrc_file)
181+ self.warn('Unable to generate python module {py_file}'
182+ ' for resource file {qrc_file}'.format(
183+ py_file=py_file, qrc_file=qrc_file))
184 if not os.path.exists(py_file) or not file(py_file).read():
185 raise SystemExit(1)
186 else:
187@@ -152,6 +126,7 @@
188 f = open(qrc_file, 'w')
189 try:
190 f.write('<!DOCTYPE RCC><RCC version="1.0">\n')
191+ import cgi
192 f.write(' <qresource prefix="%s">\n' % cgi.escape(prefix))
193 for e in srcfiles:
194 relpath = e[len(basedir) + 1:]
195@@ -191,8 +166,11 @@
196 elif filename.endswith('.qrc'):
197 self.compile_rc(os.path.join(dirpath, filename))
198
199+ build_extra.build_extra.run(self)
200+
201 # pylint: disable=E1002
202 _wrappeduic = False
203+
204 @classmethod
205 def _wrapuic(cls):
206 """Wrap uic to use gettext's _() in place of tr()"""
207@@ -207,13 +185,13 @@
208 def createToplevelWidget(self, classname, widgetname):
209 o = indenter.getIndenter()
210 o.level = 0
211- o.write('from ubuntu_sso.utils.ui import _')
212+ o.write('from gettext import gettext as _')
213 return super(_UICompiler, self).createToplevelWidget(classname,
214 widgetname)
215 compiler.UICompiler = _UICompiler
216
217 class _i18n_string(qtproxies.i18n_string):
218- """Provide a trnalated text."""
219+ """Provide a translated text."""
220
221 def __str__(self):
222 return "_('%s')" % self.string.encode('string-escape')
223@@ -224,20 +202,25 @@
224 # pylint: enable=C0103
225 # pylint: enable=E1002
226
227-class SSOWindowsClean(clean.clean):
228- """Clean the files from a Windows build."""
229
230- description = 'Clean up built files.'
231+class SSOClean(DistUtilsExtra.auto.clean_build_tree):
232+ """Class to clean up after the build."""
233
234 def run(self):
235 """Clean up the built files."""
236- # remove the generated ui files
237- for dirpath, _, filenames in os.walk(os.path.join('ubuntu_sso', 'qt')):
238+ for built_file in CLEANFILES:
239+ if os.path.exists(built_file):
240+ os.unlink(built_file)
241+
242+ for dirpath, _, filenames in os.walk(os.path.join(QT_UI_DIR)):
243 for current_file in filenames:
244 if current_file.endswith('_ui.py') or\
245 current_file.endswith('_rc.py'):
246 os.unlink(os.path.join(dirpath, current_file))
247
248+ DistUtilsExtra.auto.clean_build_tree.run(self)
249+
250+
251 def set_py2exe_paths():
252 """Set the path so that py2exe finds the required modules."""
253 # Pylint does not understand same spaced imports which is what lazr uses
254@@ -319,76 +302,62 @@
255
256 return MediaCollector
257
258+# pylint: disable=C0103
259+
260+cmdclass = {
261+ 'install': SSOInstall,
262+ 'build': SSOBuild,
263+ 'clean': SSOClean,
264+}
265+
266 def setup_windows():
267 """Provide the required info to setup the project on windows."""
268 set_py2exe_paths()
269- _scripts = []
270 _data_files = []
271- _packages = ['ubuntu_sso', 'ubuntu_sso.qt', 'ubuntu_sso.utils',
272- 'ubuntu_sso.keyring', 'ubuntu_sso.networkstate',
273- 'ubuntu_sso.main']
274- _extra = {}
275- _cmdclass = {'build' : SSOWindowsBuild,
276- 'clean' : SSOWindowsClean,
277- 'py2exe' : get_py2exe_extension()}
278-
279+ cmdclass['py2exe'] = get_py2exe_extension()
280 # for PyQt, see http://www.py2exe.org/index.cgi/Py2exeAndPyQt
281 _includes = ['sip', 'email', 'ubuntu_sso.qt.gui',
282- 'ubuntu_sso.qt.controllers', 'PyQt4.QtNetwork', 'PIL']
283- # exclude the modules that are not part of windows, this will not do much
284- # besides the fact that the warnings wont be returned.
285- _excludes = ['dbus', 'dbus.mainloop.glib', 'osx_keychain', 'gobject',
286- 'gnomekeyring']
287-
288- _extra['options'] = {
289- 'py2exe' : {
290- 'bundle_files' : 1,
291- 'skip_archive' : 0,
292- 'includes' : _includes,
293- 'optimize' : 1,
294- 'dll_excludes': [ "mswsock.dll", "powrprof.dll" ]
295- }
296- }
297- # add the console script so that py2exe compiles it
298- _extra['console'] = ['bin/windows-ubuntu-sso-login',]
299- _extra['zipfile'] = None
300- return _scripts, _data_files, _packages, _extra, _cmdclass
301-
302-def setup_linux():
303- """Provide the required info to setup the project on linux."""
304- _scripts = []
305- _data_files = [('share/dbus-1/services', ['data/com.ubuntu.sso.service']),
306+ 'ubuntu_sso.qt.controllers', 'PyQt4.QtNetwork', 'PIL']
307+ _extra = {
308+ 'options': {
309+ 'py2exe': {
310+ 'bundle_files': 1,
311+ 'skip_archive': 0,
312+ 'includes': _includes,
313+ 'optimize': 1,
314+ 'dll_excludes': ["mswsock.dll", "powrprof.dll"],
315+ },
316+ },
317+ # add the console script so that py2exe compiles it
318+ 'console': ['bin/windows-ubuntu-sso-login',],
319+ 'zipfile': None,
320+ }
321+ return _data_files, _extra
322+
323+if sys.platform == 'win32':
324+ data_files, extra = setup_windows()
325+else:
326+ data_files = [('share/dbus-1/services', ['data/com.ubuntu.sso.service']),
327 ('lib/ubuntu-sso-client', ['bin/ubuntu-sso-login']),
328 ('share/ubuntu-sso-client/data/gtk', ['data/gtk/ui.glade'])]
329- _packages = ['ubuntu_sso', 'ubuntu_sso.gtk', 'ubuntu_sso.utils',
330- 'ubuntu_sso.keyring', 'ubuntu_sso.networkstate',
331- 'ubuntu_sso.main']
332- _extra = {}
333- _cmdclass = {'build' : SSOLinuxBuild,
334- 'clean' : SSOLinuxClean}
335- return _scripts, _data_files, _packages, _extra, _cmdclass
336-
337-if __name__ == "__main__":
338-
339- # pylint: disable=C0103
340- scripts = data_files = packages = extra = cmdclass = None
341- if sys.platform == 'win32':
342- scripts, data_files, packages, extra, cmdclass = setup_windows()
343- else:
344- scripts, data_files, packages, extra, cmdclass = setup_linux()
345-
346- DistUtilsExtra.auto.setup(
347- name='ubuntu-sso-client',
348- version='1.3.1',
349- license='GPL v3',
350- author='Natalia Bidart',
351- author_email='natalia.bidart@canonical.com',
352- description='Ubuntu Single Sign-On client',
353- long_description='Desktop service to allow applications to sign in' \
354- 'to Ubuntu services via SSO',
355- url='https://launchpad.net/ubuntu-sso-client',
356- scripts=scripts,
357- data_files=data_files,
358- packages=packages,
359- cmdclass=cmdclass,
360- **extra)
361+ extra = {}
362+
363+DistUtilsExtra.auto.setup(
364+ name='ubuntu-sso-client',
365+ version='1.3.1',
366+ license='GPL v3',
367+ author='Natalia Bidart',
368+ author_email='natalia.bidart@canonical.com',
369+ description='Ubuntu Single Sign-On client',
370+ long_description='Desktop service to allow applications to sign in' \
371+ 'to Ubuntu services via SSO',
372+ url='https://launchpad.net/ubuntu-sso-client',
373+ extra_path='ubuntu-sso-client',
374+ data_files=data_files,
375+ packages=[
376+ 'ubuntu_sso', 'ubuntu_sso.utils', 'ubuntu_sso.keyring',
377+ 'ubuntu_sso.networkstate', 'ubuntu_sso.main',
378+ 'ubuntu_sso.gtk', 'ubuntu_sso.qt',
379+ ],
380+ cmdclass=cmdclass,
381+ **extra)
382
383=== modified file 'ubuntu_sso/qt/controllers.py'
384--- ubuntu_sso/qt/controllers.py 2011-07-06 17:10:13 +0000
385+++ ubuntu_sso/qt/controllers.py 2011-07-19 00:45:37 +0000
386@@ -31,7 +31,6 @@
387
388 from ubuntu_sso import NO_OP
389 from ubuntu_sso.logger import setup_logging
390-from ubuntu_sso.main.windows import UbuntuSSOClient
391 from ubuntu_sso.utils.ui import (
392 CAPTCHA_SOLUTION_ENTRY,
393 EMAIL1_ENTRY,
394@@ -98,6 +97,7 @@
395 """Return the backend used by the controller."""
396 # get the back end from the root
397 if self.root is None:
398+ from ubuntu_sso.main.windows import UbuntuSSOClient
399 self.root = UbuntuSSOClient()
400 self.root = yield self.root.connect()
401 self.backend = self.root.sso_login

Subscribers

People subscribed via source and target branches