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
=== modified file 'run-tests'
--- run-tests 2011-04-27 03:31:27 +0000
+++ run-tests 2011-07-19 00:45:37 +0000
@@ -27,6 +27,7 @@
27fi27fi
2828
29style_check() {29style_check() {
30 ./setup.py clean
30 u1lint31 u1lint
31 if [ -x `which pep8` ]; then32 if [ -x `which pep8` ]; then
32 pep8 --repeat bin/ $MODULE33 pep8 --repeat bin/ $MODULE
3334
=== modified file 'setup.py'
--- setup.py 2011-06-24 19:02:21 +0000
+++ setup.py 2011-07-19 00:45:37 +0000
@@ -1,10 +1,11 @@
1#!/usr/bin/env python1#!/usr/bin/env python
2# setup.py - Build system for Ubuntu SSO Client package2# setup.py - Build system for Ubuntu SSO Client package
3#3#
4# Author: Natalia B. Bidart <natalia.bidart@canonical.com>4# Authors: Natalia B. Bidart <natalia.bidart@canonical.com>
5# Author: Manuel de la Pena <manuel@canonical.com>5# Manuel de la Pena <manuel@canonical.com>
6# Alejandro J. Cura <alecu@canonical.com>
6#7#
7# Copyright 2010 Canonical Ltd.8# Copyright 2010-2011 Canonical Ltd.
8#9#
9# This program is free software: you can redistribute it and/or modify it10# This program is free software: you can redistribute it and/or modify it
10# under the terms of the GNU General Public License version 3, as published11# under the terms of the GNU General Public License version 3, as published
@@ -17,9 +18,10 @@
17#18#
18# You should have received a copy of the GNU General Public License along19# You should have received a copy of the GNU General Public License along
19# with this program. If not, see <http://www.gnu.org/licenses/>.20# with this program. If not, see <http://www.gnu.org/licenses/>.
20"""setup.py"""21"""Setup.py: build, distribute, clean."""
2122
22import cgi23# pylint: disable=W0404, W0511
24
23import os25import os
24import sys26import sys
2527
@@ -34,71 +36,42 @@
34 'needs DistUtilsExtra.auto >= 2.18'36 'needs DistUtilsExtra.auto >= 2.18'
3537
36from distutils import log38from distutils import log
37from distutils.command import clean39
38from distutils.spawn import find_executable40POT_FILE = 'po/ubuntu-sso-client.pot'
3941SERVICE_FILE = 'data/com.ubuntu.sso.service'
40# Defining variables for various rules here, similar to a Makefile.am42
41LINUX_CLEANFILES = ['data/com.ubuntu.sso.service', 'po/ubuntu-sso-client.pot',43CLEANFILES = [SERVICE_FILE, POT_FILE, 'MANIFEST']
42 'MANIFEST']44QT_UI_DIR = os.path.join('ubuntu_sso', 'qt')
4345
4446def replace_prefix(prefix):
45# pylint: disable=W051147 """Replace every '@prefix@' with prefix within 'filename' content."""
46# This needs some serious cleanup48 # replace .service file, DATA_DIR constant
47class SSOLinuxBuild(build_extra.build_extra):49 for filename in (SERVICE_FILE,):
48 """Build the extra files required on Linux.."""50 with open(filename + '.in') as in_file:
4951 content = in_file.read()
50 description = 'build extra files needed by ubuntu-sso-client'52 with open(filename, 'w') as out_file:
5153 out_file.write(content.replace('@prefix@', prefix))
52 def __init__(self, *args):54
53 build_extra.build_extra.__init__(self, *args)55
5456class SSOInstall(DistUtilsExtra.auto.install_auto):
55 def run(self):57 """Class to install proper files."""
56 """Do the build."""58
57 sed = find_executable('sed')59 def run(self):
58 if sed is None:60 """Do the install.
59 sys.stderr.write('Cannont find sed; required to build')61
60 sys.exit(-1)62 Read from *.service.in and generate .service files by replacing
6163 @prefix@ by self.prefix.
62 in_file = 'data/com.ubuntu.sso.service.in'64
63 out_file = 'data/com.ubuntu.sso.service'65 """
64 replaced_path = '/usr/lib/ubuntu-sso-client'66 replace_prefix(self.prefix)
6567 DistUtilsExtra.auto.install_auto.run(self)
66 cmd = "%(cmd)s -e 's|\@libexecdir\@|%(rep)s|g' < %(in)s > %(out)s"68
67 os.system( cmd %69
68 {'cmd' : sed,70class SSOBuild(build_extra.build_extra):
69 'rep' : replaced_path,
70 'in' : in_file,
71 'out' : out_file,
72 }
73 )
74
75 # Run the parent build command
76 build_extra.build_extra.run(self)
77
78
79class SSOLinuxClean(clean.clean):
80 """Class to clean up after the build."""
81
82 description = 'Clean up built files.'
83
84 def run(self):
85 """Clean up the built files."""
86 for built_file in LINUX_CLEANFILES:
87 if os.path.exists(built_file):
88 os.unlink(built_file)
89
90 # Run the parent clean command
91 clean.clean.run(self)
92
93
94class SSOWindowsBuild(build_extra.build_extra):
95 """Build PyQt (.ui) files and resources."""71 """Build PyQt (.ui) files and resources."""
9672
97 description = "build PyQt GUIs (.ui) and resources (.qrc)"73 description = "build PyQt GUIs (.ui) and resources (.qrc)"
9874
99 def __init__(self, *args):
100 build_extra.build_extra.__init__(self, *args)
101
102 def compile_ui(self, ui_file, py_file=None):75 def compile_ui(self, ui_file, py_file=None):
103 """Compile the .ui files to python modules."""76 """Compile the .ui files to python modules."""
104 # Search for pyuic4 in python bin dir, then in the $Path.77 # Search for pyuic4 in python bin dir, then in the $Path.
@@ -107,7 +80,7 @@
107 # python file in the qt moodule80 # python file in the qt moodule
108 py_file = os.path.split(ui_file)[1]81 py_file = os.path.split(ui_file)[1]
109 py_file = os.path.splitext(py_file)[0] + '_ui.py'82 py_file = os.path.splitext(py_file)[0] + '_ui.py'
110 py_file = os.path.join('ubuntu_sso', 'qt', py_file)83 py_file = os.path.join(QT_UI_DIR, py_file)
111 # we indeed want to catch Exception, is ugly but we need it84 # we indeed want to catch Exception, is ugly but we need it
112 # pylint: disable=W070385 # pylint: disable=W0703
113 try:86 try:
@@ -120,7 +93,7 @@
120 fp.close()93 fp.close()
121 log.info('Compiled %s into %s', ui_file, py_file)94 log.info('Compiled %s into %s', ui_file, py_file)
122 except Exception, e:95 except Exception, e:
123 self.warn('Unable to compile user interface %s: %s', py_file, e)96 self.warn('Unable to compile user interface %s: %s' % (py_file, e))
124 if not os.path.exists(py_file) or not file(py_file).read():97 if not os.path.exists(py_file) or not file(py_file).read():
125 raise SystemExit(1)98 raise SystemExit(1)
126 return99 return
@@ -133,13 +106,14 @@
133 if py_file is None:106 if py_file is None:
134 py_file = os.path.split(qrc_file)[1]107 py_file = os.path.split(qrc_file)[1]
135 py_file = os.path.splitext(py_file)[0] + '_rc.py'108 py_file = os.path.splitext(py_file)[0] + '_rc.py'
136 py_file = os.path.join('ubuntu_sso', 'qt', py_file)109 py_file = os.path.join(QT_UI_DIR, py_file)
137 path = os.getenv('PATH')110 path = os.getenv('PATH')
138 os.putenv('PATH', path + ';' + os.path.join(111 os.putenv('PATH', path + os.path.pathsep + os.path.join(
139 os.path.dirname(PyQt4.__file__),'bin'))112 os.path.dirname(PyQt4.__file__), 'bin'))
140 if os.system('pyrcc4 "%s" -o "%s"' % (qrc_file, py_file)) > 0:113 if os.system('pyrcc4 "%s" -o "%s"' % (qrc_file, py_file)) > 0:
141 self.warn('Unable to generate python module %s '114 self.warn('Unable to generate python module {py_file}'
142 + 'for resource file %s', py_file, qrc_file)115 ' for resource file {qrc_file}'.format(
116 py_file=py_file, qrc_file=qrc_file))
143 if not os.path.exists(py_file) or not file(py_file).read():117 if not os.path.exists(py_file) or not file(py_file).read():
144 raise SystemExit(1)118 raise SystemExit(1)
145 else:119 else:
@@ -152,6 +126,7 @@
152 f = open(qrc_file, 'w')126 f = open(qrc_file, 'w')
153 try:127 try:
154 f.write('<!DOCTYPE RCC><RCC version="1.0">\n')128 f.write('<!DOCTYPE RCC><RCC version="1.0">\n')
129 import cgi
155 f.write(' <qresource prefix="%s">\n' % cgi.escape(prefix))130 f.write(' <qresource prefix="%s">\n' % cgi.escape(prefix))
156 for e in srcfiles:131 for e in srcfiles:
157 relpath = e[len(basedir) + 1:]132 relpath = e[len(basedir) + 1:]
@@ -191,8 +166,11 @@
191 elif filename.endswith('.qrc'):166 elif filename.endswith('.qrc'):
192 self.compile_rc(os.path.join(dirpath, filename))167 self.compile_rc(os.path.join(dirpath, filename))
193168
169 build_extra.build_extra.run(self)
170
194 # pylint: disable=E1002171 # pylint: disable=E1002
195 _wrappeduic = False172 _wrappeduic = False
173
196 @classmethod174 @classmethod
197 def _wrapuic(cls):175 def _wrapuic(cls):
198 """Wrap uic to use gettext's _() in place of tr()"""176 """Wrap uic to use gettext's _() in place of tr()"""
@@ -207,13 +185,13 @@
207 def createToplevelWidget(self, classname, widgetname):185 def createToplevelWidget(self, classname, widgetname):
208 o = indenter.getIndenter()186 o = indenter.getIndenter()
209 o.level = 0187 o.level = 0
210 o.write('from ubuntu_sso.utils.ui import _')188 o.write('from gettext import gettext as _')
211 return super(_UICompiler, self).createToplevelWidget(classname,189 return super(_UICompiler, self).createToplevelWidget(classname,
212 widgetname)190 widgetname)
213 compiler.UICompiler = _UICompiler191 compiler.UICompiler = _UICompiler
214192
215 class _i18n_string(qtproxies.i18n_string):193 class _i18n_string(qtproxies.i18n_string):
216 """Provide a trnalated text."""194 """Provide a translated text."""
217195
218 def __str__(self):196 def __str__(self):
219 return "_('%s')" % self.string.encode('string-escape')197 return "_('%s')" % self.string.encode('string-escape')
@@ -224,20 +202,25 @@
224 # pylint: enable=C0103202 # pylint: enable=C0103
225 # pylint: enable=E1002203 # pylint: enable=E1002
226204
227class SSOWindowsClean(clean.clean):
228 """Clean the files from a Windows build."""
229205
230 description = 'Clean up built files.'206class SSOClean(DistUtilsExtra.auto.clean_build_tree):
207 """Class to clean up after the build."""
231208
232 def run(self):209 def run(self):
233 """Clean up the built files."""210 """Clean up the built files."""
234 # remove the generated ui files211 for built_file in CLEANFILES:
235 for dirpath, _, filenames in os.walk(os.path.join('ubuntu_sso', 'qt')):212 if os.path.exists(built_file):
213 os.unlink(built_file)
214
215 for dirpath, _, filenames in os.walk(os.path.join(QT_UI_DIR)):
236 for current_file in filenames:216 for current_file in filenames:
237 if current_file.endswith('_ui.py') or\217 if current_file.endswith('_ui.py') or\
238 current_file.endswith('_rc.py'):218 current_file.endswith('_rc.py'):
239 os.unlink(os.path.join(dirpath, current_file))219 os.unlink(os.path.join(dirpath, current_file))
240220
221 DistUtilsExtra.auto.clean_build_tree.run(self)
222
223
241def set_py2exe_paths():224def set_py2exe_paths():
242 """Set the path so that py2exe finds the required modules."""225 """Set the path so that py2exe finds the required modules."""
243 # Pylint does not understand same spaced imports which is what lazr uses226 # Pylint does not understand same spaced imports which is what lazr uses
@@ -319,76 +302,62 @@
319302
320 return MediaCollector303 return MediaCollector
321304
305# pylint: disable=C0103
306
307cmdclass = {
308 'install': SSOInstall,
309 'build': SSOBuild,
310 'clean': SSOClean,
311}
312
322def setup_windows():313def setup_windows():
323 """Provide the required info to setup the project on windows."""314 """Provide the required info to setup the project on windows."""
324 set_py2exe_paths()315 set_py2exe_paths()
325 _scripts = []
326 _data_files = []316 _data_files = []
327 _packages = ['ubuntu_sso', 'ubuntu_sso.qt', 'ubuntu_sso.utils',317 cmdclass['py2exe'] = get_py2exe_extension()
328 'ubuntu_sso.keyring', 'ubuntu_sso.networkstate',
329 'ubuntu_sso.main']
330 _extra = {}
331 _cmdclass = {'build' : SSOWindowsBuild,
332 'clean' : SSOWindowsClean,
333 'py2exe' : get_py2exe_extension()}
334
335 # for PyQt, see http://www.py2exe.org/index.cgi/Py2exeAndPyQt318 # for PyQt, see http://www.py2exe.org/index.cgi/Py2exeAndPyQt
336 _includes = ['sip', 'email', 'ubuntu_sso.qt.gui',319 _includes = ['sip', 'email', 'ubuntu_sso.qt.gui',
337 'ubuntu_sso.qt.controllers', 'PyQt4.QtNetwork', 'PIL']320 'ubuntu_sso.qt.controllers', 'PyQt4.QtNetwork', 'PIL']
338 # exclude the modules that are not part of windows, this will not do much321 _extra = {
339 # besides the fact that the warnings wont be returned.322 'options': {
340 _excludes = ['dbus', 'dbus.mainloop.glib', 'osx_keychain', 'gobject',323 'py2exe': {
341 'gnomekeyring']324 'bundle_files': 1,
342325 'skip_archive': 0,
343 _extra['options'] = {326 'includes': _includes,
344 'py2exe' : {327 'optimize': 1,
345 'bundle_files' : 1,328 'dll_excludes': ["mswsock.dll", "powrprof.dll"],
346 'skip_archive' : 0,329 },
347 'includes' : _includes,330 },
348 'optimize' : 1,331 # add the console script so that py2exe compiles it
349 'dll_excludes': [ "mswsock.dll", "powrprof.dll" ]332 'console': ['bin/windows-ubuntu-sso-login',],
350 }333 'zipfile': None,
351 }334 }
352 # add the console script so that py2exe compiles it335 return _data_files, _extra
353 _extra['console'] = ['bin/windows-ubuntu-sso-login',]336
354 _extra['zipfile'] = None337if sys.platform == 'win32':
355 return _scripts, _data_files, _packages, _extra, _cmdclass338 data_files, extra = setup_windows()
356339else:
357def setup_linux():340 data_files = [('share/dbus-1/services', ['data/com.ubuntu.sso.service']),
358 """Provide the required info to setup the project on linux."""
359 _scripts = []
360 _data_files = [('share/dbus-1/services', ['data/com.ubuntu.sso.service']),
361 ('lib/ubuntu-sso-client', ['bin/ubuntu-sso-login']),341 ('lib/ubuntu-sso-client', ['bin/ubuntu-sso-login']),
362 ('share/ubuntu-sso-client/data/gtk', ['data/gtk/ui.glade'])]342 ('share/ubuntu-sso-client/data/gtk', ['data/gtk/ui.glade'])]
363 _packages = ['ubuntu_sso', 'ubuntu_sso.gtk', 'ubuntu_sso.utils',343 extra = {}
364 'ubuntu_sso.keyring', 'ubuntu_sso.networkstate',344
365 'ubuntu_sso.main']345DistUtilsExtra.auto.setup(
366 _extra = {}346 name='ubuntu-sso-client',
367 _cmdclass = {'build' : SSOLinuxBuild,347 version='1.3.1',
368 'clean' : SSOLinuxClean}348 license='GPL v3',
369 return _scripts, _data_files, _packages, _extra, _cmdclass349 author='Natalia Bidart',
370350 author_email='natalia.bidart@canonical.com',
371if __name__ == "__main__":351 description='Ubuntu Single Sign-On client',
372352 long_description='Desktop service to allow applications to sign in' \
373 # pylint: disable=C0103353 'to Ubuntu services via SSO',
374 scripts = data_files = packages = extra = cmdclass = None354 url='https://launchpad.net/ubuntu-sso-client',
375 if sys.platform == 'win32':355 extra_path='ubuntu-sso-client',
376 scripts, data_files, packages, extra, cmdclass = setup_windows()356 data_files=data_files,
377 else:357 packages=[
378 scripts, data_files, packages, extra, cmdclass = setup_linux()358 'ubuntu_sso', 'ubuntu_sso.utils', 'ubuntu_sso.keyring',
379359 'ubuntu_sso.networkstate', 'ubuntu_sso.main',
380 DistUtilsExtra.auto.setup(360 'ubuntu_sso.gtk', 'ubuntu_sso.qt',
381 name='ubuntu-sso-client',361 ],
382 version='1.3.1',362 cmdclass=cmdclass,
383 license='GPL v3',363 **extra)
384 author='Natalia Bidart',
385 author_email='natalia.bidart@canonical.com',
386 description='Ubuntu Single Sign-On client',
387 long_description='Desktop service to allow applications to sign in' \
388 'to Ubuntu services via SSO',
389 url='https://launchpad.net/ubuntu-sso-client',
390 scripts=scripts,
391 data_files=data_files,
392 packages=packages,
393 cmdclass=cmdclass,
394 **extra)
395364
=== modified file 'ubuntu_sso/qt/controllers.py'
--- ubuntu_sso/qt/controllers.py 2011-07-06 17:10:13 +0000
+++ ubuntu_sso/qt/controllers.py 2011-07-19 00:45:37 +0000
@@ -31,7 +31,6 @@
3131
32from ubuntu_sso import NO_OP32from ubuntu_sso import NO_OP
33from ubuntu_sso.logger import setup_logging33from ubuntu_sso.logger import setup_logging
34from ubuntu_sso.main.windows import UbuntuSSOClient
35from ubuntu_sso.utils.ui import (34from ubuntu_sso.utils.ui import (
36 CAPTCHA_SOLUTION_ENTRY,35 CAPTCHA_SOLUTION_ENTRY,
37 EMAIL1_ENTRY,36 EMAIL1_ENTRY,
@@ -98,6 +97,7 @@
98 """Return the backend used by the controller."""97 """Return the backend used by the controller."""
99 # get the back end from the root98 # get the back end from the root
100 if self.root is None:99 if self.root is None:
100 from ubuntu_sso.main.windows import UbuntuSSOClient
101 self.root = UbuntuSSOClient()101 self.root = UbuntuSSOClient()
102 self.root = yield self.root.connect()102 self.root = yield self.root.connect()
103 self.backend = self.root.sso_login103 self.backend = self.root.sso_login

Subscribers

People subscribed via source and target branches