1004
by pap(openerp)
Changed encoding to coding ref: PEP: 0263 |
1 |
# -*- coding: utf-8 -*-
|
1001
by PSO(OpenERP)
changed licencing |
2 |
##############################################################################
|
1843
by Olivier Dony
[FIX] all: fix incorrect copyright/licensing terms |
3 |
#
|
4 |
# This following code is based on the gnome-distutils module that is
|
|
5 |
# part of Gnomolicious, from http://www.nongnu.org/gnomolicious/
|
|
6 |
# The original licensing terms and copyright are included below.
|
|
7 |
#
|
|
8 |
# Subsequent modifications to the original code were done by OpenERP S.A,
|
|
9 |
# and distributed under the GNU AGPL. These licensing terms are also
|
|
10 |
# included below.
|
|
11 |
#
|
|
12 |
# ---------------- OpenERP Licensing Terms ---------------------------------
|
|
13 |
#
|
|
14 |
# OpenERP, Open Source Management Solution
|
|
15 |
# Copyright (C) 2004-2011 OpenERP S.A. (<http://openerp.com>).
|
|
16 |
#
|
|
17 |
# This program is free software: you can redistribute it and/or modify
|
|
18 |
# it under the terms of the GNU Affero General Public License as
|
|
19 |
# published by the Free Software Foundation, either version 3 of the
|
|
20 |
# License, or (at your option) any later version.
|
|
21 |
#
|
|
22 |
# This program is distributed in the hope that it will be useful,
|
|
23 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25 |
# GNU Affero General Public License for more details.
|
|
26 |
#
|
|
27 |
# You should have received a copy of the GNU Affero General Public License
|
|
28 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29 |
#
|
|
30 |
# ---------------- Original Gnomolicious Licensing terms --------------------
|
|
1
by pinky
New trunk |
31 |
#
|
32 |
# Gnomolicious is free software; you can redistribute it and/or modify
|
|
33 |
# it under the terms of the GNU General Public License as published by
|
|
34 |
# the Free Software Foundation; either version 2 of the License, or
|
|
35 |
# (at your option) any later version.
|
|
36 |
#
|
|
37 |
# Gnomolicious is distributed in the hope that it will be useful,
|
|
38 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
39 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
40 |
# GNU General Public License for more details.
|
|
41 |
#
|
|
42 |
# You should have received a copy of the GNU General Public License
|
|
43 |
# along with Gnomolicious; if not, write to the Free Software
|
|
44 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
45 |
#
|
|
1843
by Olivier Dony
[FIX] all: fix incorrect copyright/licensing terms |
46 |
# (C) 2003, 2005 Terje Rosten <terjeros@phys.ntnu.no>, Nicolas Evrard
|
1001
by PSO(OpenERP)
changed licencing |
47 |
#
|
48 |
##############################################################################
|
|
49 |
||
1
by pinky
New trunk |
50 |
|
51 |
import sys |
|
52 |
import os |
|
53 |
import os.path |
|
54 |
import msgfmt |
|
55 |
||
1775.1.1
by xrg
[FIX] packaging linux |
56 |
from setuptools import Command, Distribution |
57 |
from distutils.command.build_scripts import build_scripts |
|
58 |
from setuptools.command.install import install |
|
1
by pinky
New trunk |
59 |
from distutils.command.install_data import install_data |
60 |
from distutils.dep_util import newer |
|
1775.1.1
by xrg
[FIX] packaging linux |
61 |
import distutils.core |
62 |
||
63 |
from distutils.errors import DistutilsSetupError |
|
1
by pinky
New trunk |
64 |
|
65 |
try: |
|
66 |
from dsextras import BuildExt |
|
1775.1.1
by xrg
[FIX] packaging linux |
67 |
_pyflakes_hush = [ BuildExt, ] |
1
by pinky
New trunk |
68 |
except ImportError: |
69 |
try: |
|
70 |
from gtk.dsextras import BuildExt |
|
1775.1.1
by xrg
[FIX] packaging linux |
71 |
_pyflakes_hush = [ BuildExt, ] |
1
by pinky
New trunk |
72 |
except ImportError: |
73 |
sys.exit('Error: Can not find dsextras or gtk.dsextras') |
|
74 |
||
991
by HDA(OpenERP)
[Merged] |
75 |
# get python short version
|
76 |
py_short_version = '%s.%s' % sys.version_info[:2] |
|
77 |
||
1775.1.1
by xrg
[FIX] packaging linux |
78 |
class build_scripts_app(build_scripts): |
79 |
""" Create the shortcut to the application
|
|
80 |
"""
|
|
81 |
||
82 |
description = 'build the OpenERP Client Linux script' |
|
83 |
||
84 |
def get_source_files(self): |
|
85 |
return [ x for x in self.scripts if x != 'openerp-client'] |
|
86 |
||
87 |
def run(self): |
|
88 |
if sys.platform != 'win32': |
|
89 |
self.announce("create startup script") |
|
90 |
opj = os.path.join |
|
91 |
# Peek into "install" command to find out where it is going to install to
|
|
92 |
inst_cmd = self.get_finalized_command('install') |
|
93 |
if inst_cmd: |
|
94 |
# Note: we user the "purelib" because we don't ship binary
|
|
95 |
# executables. If we ever compile things into execs, we shall
|
|
96 |
# use "platlib"
|
|
97 |
openerp_site_packages = opj(inst_cmd.install_purelib,'openerp-client') |
|
98 |
if inst_cmd.root and openerp_site_packages.startswith(inst_cmd.root): |
|
99 |
# trick: when we install relative to root, we mostly mean to
|
|
100 |
# temporary put the files there, and then move back to the
|
|
101 |
# stripped prefix dir. So we don't write the full root into
|
|
102 |
# the script
|
|
103 |
iroot = inst_cmd.root |
|
104 |
if iroot.endswith('/'): |
|
105 |
iroot = iroot[:-1] |
|
106 |
openerp_site_packages = openerp_site_packages[len(iroot):] |
|
1775.1.3
by Thibault Francois
[ADD] dependencies python-pydot in INSTALL |
107 |
|
1775.1.1
by xrg
[FIX] packaging linux |
108 |
else: |
109 |
# Hard-code the Linux /usr/lib/pythonX.Y/... path
|
|
110 |
openerp_site_packages = opj('/usr', 'lib', 'python%s' % py_short_version, 'site-packages', 'openerp-client') |
|
111 |
start_script = "#!/bin/sh\ncd %s\nexec %s ./openerp-client.py $@\n" % (openerp_site_packages, sys.executable) |
|
112 |
# write script
|
|
113 |
f = open('openerp-client', 'w') |
|
114 |
f.write(start_script) |
|
115 |
f.close() |
|
116 |
build_scripts.run(self) |
|
1
by pinky
New trunk |
117 |
|
118 |
class build_mo(Command): |
|
119 |
||
120 |
description = 'build binary message catalog' |
|
121 |
||
122 |
user_options = [ |
|
123 |
('build-base=', 'b', 'directory to build to')] |
|
124 |
||
125 |
def initialize_options(self): |
|
126 |
self.build_base = None |
|
127 |
self.translations = self.distribution.translations |
|
128 |
self.force = None |
|
1775.1.1
by xrg
[FIX] packaging linux |
129 |
|
1
by pinky
New trunk |
130 |
def finalize_options(self): |
131 |
self.set_undefined_options('build', |
|
132 |
('build_base', 'build_base'), |
|
133 |
('force', 'force')) |
|
134 |
def run(self): |
|
1775.1.1
by xrg
[FIX] packaging linux |
135 |
if not self.translations: |
136 |
return
|
|
1
by pinky
New trunk |
137 |
self.announce('Building binary message catalog') |
1775.1.1
by xrg
[FIX] packaging linux |
138 |
for mo, po in self.translations: |
139 |
dest = os.path.normpath( os.path.join(self.build_base, mo)) |
|
140 |
self.mkpath(os.path.dirname(dest)) |
|
141 |
if not self.force and not newer(po, dest): |
|
142 |
self.announce("not building %s (up-to-date)" % dest) |
|
143 |
else: |
|
144 |
msgfmt.make(po, dest) |
|
1
by pinky
New trunk |
145 |
|
146 |
class install_mo(install_data): |
|
147 |
||
148 |
description = 'install generated binary message catalog' |
|
149 |
||
150 |
def initialize_options(self): |
|
151 |
install_data.initialize_options(self) |
|
152 |
self.translations = self.distribution.translations |
|
153 |
self.install_dir = None |
|
154 |
self.build_dir = None |
|
155 |
self.skip_build = None |
|
156 |
self.outfiles = [] |
|
157 |
||
158 |
def finalize_options(self): |
|
159 |
install_data.finalize_options(self) |
|
160 |
self.set_undefined_options('build_mo', ('build_base', 'build_dir')) |
|
161 |
self.set_undefined_options('install', |
|
162 |
('install_data', 'install_dir'), |
|
163 |
('skip_build', 'skip_build')) |
|
164 |
def run(self): |
|
165 |
if not self.skip_build: |
|
166 |
self.run_command('build_mo') |
|
1775.1.1
by xrg
[FIX] packaging linux |
167 |
if self.translations: |
1
by pinky
New trunk |
168 |
for mo, po in self.translations: |
169 |
src = os.path.normpath(self.build_dir + '/' + mo) |
|
170 |
if not os.path.isabs(mo): |
|
171 |
dest = os.path.normpath(self.install_dir + '/' + mo) |
|
172 |
elif self.root: |
|
173 |
dest = self.root + mo |
|
174 |
else: |
|
175 |
dest = mo |
|
176 |
self.mkpath(os.path.dirname(dest)) |
|
177 |
(out, _) = self.copy_file(src, dest) |
|
178 |
self.outfiles.append(out) |
|
179 |
||
180 |
def get_outputs (self): |
|
181 |
return self.outfiles |
|
182 |
||
183 |
def get_inputs (self): |
|
184 |
return [ po for mo, po in self.translations ] |
|
185 |
||
1775.1.1
by xrg
[FIX] packaging linux |
186 |
class ClientDistribution(Distribution): |
187 |
def __init__(self, attrs=None): |
|
1
by pinky
New trunk |
188 |
self.translations = [] |
189 |
Distribution.__init__(self, attrs) |
|
190 |
self.cmdclass = { |
|
191 |
'install_mo' : install_mo, |
|
192 |
'build_mo' : build_mo, |
|
1775.1.1
by xrg
[FIX] packaging linux |
193 |
# 'build_conf' : build_conf,
|
225
by ced
CLIENT: improve client setup |
194 |
'build_ext': BuildExt, |
1775.1.1
by xrg
[FIX] packaging linux |
195 |
'build_scripts': build_scripts_app, |
225
by ced
CLIENT: improve client setup |
196 |
}
|
1775.1.1
by xrg
[FIX] packaging linux |
197 |
self.command_obj['build_scripts'] = None |
198 |
||
1775.1.3
by Thibault Francois
[ADD] dependencies python-pydot in INSTALL |
199 |
|
1775.1.1
by xrg
[FIX] packaging linux |
200 |
#eof
|