30 |
|
|
31 |
from distutils.core import setup |
from distutils.core import setup |
32 |
from distutils.command.build_scripts import build_scripts |
from distutils.command.build_scripts import build_scripts |
33 |
|
from distutils.command.install import install |
34 |
|
|
35 |
from src import PACKAGE, VERSION |
from src import PACKAGE, VERSION |
36 |
|
|
46 |
# Find out whether or not to use our setup.cfg |
# Find out whether or not to use our setup.cfg |
47 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
48 |
|
|
|
prefix = None |
|
49 |
have_prefix = 0 |
have_prefix = 0 |
|
i = 0 |
|
50 |
for arg in sys.argv: |
for arg in sys.argv: |
51 |
if arg == "--prefix": |
if arg == "--prefix" or arg [:9] == "--prefix=" or \ |
52 |
try: |
arg == "--home" or arg [:7] == "--home=": |
|
prefix = sys.argv [i+1] |
|
|
have_prefix = 1 |
|
|
except: |
|
|
pass |
|
|
if arg [:9] == "--prefix=": |
|
|
prefix = arg [9:] |
|
53 |
have_prefix = 1 |
have_prefix = 1 |
|
i = i + 1 |
|
54 |
|
|
55 |
if "install" in sys.argv or "bdist_rpm" in sys.argv: |
if "install" in sys.argv or "bdist_rpm" in sys.argv: |
56 |
if sys.platform != "win32" and not have_prefix: |
if sys.platform != "win32" and not have_prefix: |
127 |
sys.exit (1) |
sys.exit (1) |
128 |
|
|
129 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
130 |
# build and install: Check dependencies |
# User can supply a path to the config file |
|
# ----------------------------------------------------------------------------- |
|
|
|
|
|
if ("build" in sys.argv) or ("install" in sys.argv): |
|
|
|
|
|
# xml |
|
|
try: |
|
|
print "checking Python xml library" |
|
|
import xml |
|
|
except ImportError: |
|
|
print "Could not import the xml package. " \ |
|
|
+ "Please install Python's XML library." |
|
|
print "The file 'INSTALL' contains more information about dependencies." |
|
|
sys.exit (1) |
|
|
|
|
|
# Verify at least one RPC driver is installed |
|
|
RPCOK = 0 |
|
|
|
|
|
# xmlrpc |
|
|
print "checking Python xmlrpc library (py-xmlrpc)" |
|
|
try: |
|
|
import xmlrpc |
|
|
RPCOK = 1 |
|
|
except ImportError: |
|
|
pass |
|
|
|
|
|
# pw_xmlrpc |
|
|
print "checking Python xmlrpclib library (pw-xmlrpc)" |
|
|
try: |
|
|
import xmlrpclib |
|
|
RPCOK = 1 |
|
|
except ImportError: |
|
|
pass |
|
|
|
|
|
# found any? |
|
|
if RPCOK != 1: |
|
|
print """ |
|
|
No valid GNURRPC drivers are installed on this machine. |
|
|
Please install one of the following packages. |
|
|
py-xmlrpc - http://sourceforge.net/projects/py-xmlrpc |
|
|
Pythonware XMLRPC - http://www.pythonware.com/products/xmlrpc |
|
|
The file 'INSTALL' contains more information about dependencies. |
|
|
""" |
|
|
sys.exit (1) |
|
|
|
|
|
# gnue-common |
|
|
# TODO: Can't find out here where gnue-common is installed |
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
# Some magic to create $script from $script.in while installing |
|
131 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
132 |
|
|
133 |
try: |
try: |
139 |
except ValueError: |
except ValueError: |
140 |
config_line = "" |
config_line = "" |
141 |
|
|
142 |
if have_prefix: |
# ============================================================================= |
143 |
install_lib = os.path.join (prefix, "lib", "python%s" % sys.version [:3], |
# Before installation: check dependencies and create real scripts |
144 |
"site-packages") |
# ============================================================================= |
|
else: |
|
|
install_lib = None |
|
|
|
|
|
class my_build_scripts(build_scripts): |
|
|
def finalize_options(self): |
|
|
global prefix |
|
|
global install_lib |
|
145 |
|
|
146 |
build_scripts.finalize_options(self) |
class my_install (install): |
147 |
|
|
148 |
if self.finalized: |
# --------------------------------------------------------------------------- |
149 |
return |
# Check dependencies |
150 |
|
# --------------------------------------------------------------------------- |
151 |
|
|
152 |
if sys.platform != "win32": |
def _check_dependencies (self): |
153 |
if not have_prefix: |
|
154 |
dict = self.distribution.get_option_dict ("install") |
# ------------------------------------------------------------------------- |
155 |
prefix = dict ["prefix"] [1] |
# xml |
156 |
install_lib = dict ["install_lib"] [1] |
try: |
157 |
|
print "checking Python xml library" |
158 |
if install_lib in sys.path: |
import xml |
159 |
path_line = "" |
except ImportError: |
160 |
else: |
print "---" |
161 |
sys.path.append (install_lib) |
print "Could not import the xml package. " \ |
162 |
path_line = "import sys\nsys.path.append('%s')\n" % install_lib |
+ "Please install Python's XML library." |
163 |
|
print "The file 'INSTALL' contains more information about dependencies." |
164 |
|
sys.exit (1) |
165 |
|
|
166 |
|
# ------------------------------------------------------------------------- |
167 |
|
# Verify at least one RPC driver is installed |
168 |
|
RPCOK = 0 |
169 |
|
|
170 |
|
# xmlrpc |
171 |
|
print "checking Python xmlrpc library (py-xmlrpc)" |
172 |
|
try: |
173 |
|
import xmlrpc |
174 |
|
RPCOK = 1 |
175 |
|
except ImportError: |
176 |
|
pass |
177 |
|
|
178 |
|
# pw_xmlrpc |
179 |
|
print "checking Python xmlrpclib library (pw-xmlrpc)" |
180 |
|
try: |
181 |
|
import xmlrpclib |
182 |
|
RPCOK = 1 |
183 |
|
except ImportError: |
184 |
|
pass |
185 |
|
|
186 |
|
# found any? |
187 |
|
if RPCOK != 1: |
188 |
|
print "---" |
189 |
|
print """ |
190 |
|
No valid GNURRPC drivers are installed on this machine. |
191 |
|
Please install one of the following packages. |
192 |
|
py-xmlrpc - http://sourceforge.net/projects/py-xmlrpc |
193 |
|
Pythonware XMLRPC - http://www.pythonware.com/products/xmlrpc |
194 |
|
The file 'INSTALL' contains more information about dependencies. |
195 |
|
""" |
196 |
|
sys.exit (1) |
197 |
|
|
198 |
|
# ------------------------------------------------------------------------- |
199 |
|
# gnue-common |
200 |
|
print "checking GNUe-Common library" |
201 |
|
try: |
202 |
|
import gnue.common |
203 |
|
except ImportError: |
204 |
|
print "---" |
205 |
|
print "Could not import the gnue-common package. " \ |
206 |
|
+ "Please install GNUe-Common." |
207 |
|
print "Note that GNUe-Appserver has to be installed in the same" |
208 |
|
print "directory as GNUe-Common." |
209 |
|
print "The file 'INSTALL' contains more information about dependencies." |
210 |
|
sys.exit (1) |
211 |
|
if gnue.common.__hexversion__ < 0x00050100: |
212 |
|
print "---" |
213 |
|
print "The gnue-common package you have installed is too old." |
214 |
|
print "Please install GNUe-Common 0.5.1 or greater." |
215 |
|
print "The file 'INSTALL' contains more information about dependencies." |
216 |
|
sys.exit (1) |
217 |
|
if os.path.dirname (gnue.__path__[0]) != os.path.dirname (self.install_lib): |
218 |
|
print "---" |
219 |
|
print "GNUe-Common is installed in %s." % \ |
220 |
|
os.path.dirname (gnue.__path__ [0]) |
221 |
|
print "You are trying to install GNUe-AppServer in %s." % \ |
222 |
|
os.path.dirname (self.install_lib) |
223 |
|
print "GNUe-Appserver has to be installed in the same directory as GNUe-Common." |
224 |
|
sys.exit (1) |
225 |
|
|
226 |
|
# --------------------------------------------------------------------------- |
227 |
|
# Build the commands to place into the scripts |
228 |
|
# --------------------------------------------------------------------------- |
229 |
|
|
230 |
|
def _build_gnue_env (self, path_line, config_line): |
231 |
|
if sys.platform != "win32": |
232 |
gnue_env = \ |
gnue_env = \ |
233 |
"#######\n" \ |
"#######\n" \ |
234 |
+ "# The following variables were set when GNUe was installed\n" \ |
+ "# The following variables were set when GNUe was installed\n" \ |
235 |
+ "import os\n" \ |
+ "INST_GNUE_CONNECTIONS='%s/etc/connections.conf'\n" % self.prefix \ |
236 |
+ path_line \ |
+ path_line \ |
237 |
+ "INST_GNUE_CONNECTIONS='%s/etc/connections.conf'\n" % prefix \ |
+ "import os\n" \ |
238 |
+ "os.environ['INSTALL_LIB']='%s'\n" % install_lib \ |
+ "os.environ['INSTALL_LIB']='%s'\n" % self.install_lib \ |
239 |
+ "os.environ['INSTALL_PREFIX']='%s'\n" % prefix \ |
+ "os.environ['INSTALL_PREFIX']='%s'\n" % self.prefix \ |
240 |
+ config_line \ |
+ config_line \ |
241 |
+ "#######\n" |
+ "#######\n" |
242 |
else: |
else: |
|
options.append('install_lib = r"%s"' % sys.prefix) |
|
243 |
gnue_env = \ |
gnue_env = \ |
244 |
"#######\n" \ |
"#######\n" \ |
245 |
+ "# The following variables were set when GNUe was installed\n" \ |
+ "# The following variables were set when GNUe was installed\n" \ |
246 |
+ "# (Generated for a Win32 system)\n" \ |
+ "# (Generated for a Win32 system)\n" \ |
247 |
+ "import os, sys\n" \ |
+ "import os, sys\n" \ |
248 |
+ "if __name__ == '__main__': \n" \ |
+ "if __name__ == '__main__': \n" \ |
249 |
+ " _BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),'..'))\n" \ |
+ " _BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),'..'))\n" \ |
250 |
+ " try:\n" \ |
+ " try:\n" \ |
251 |
+ " os.environ['PATH']= os.path.abspath(os.path.dirname(sys.argv[0])) + ';' + os.environ['PATH']\n" \ |
+ " os.environ['PATH']= os.path.abspath(os.path.dirname(sys.argv[0])) + ';' + os.environ['PATH']\n" \ |
252 |
+ " except KeyError:\n" \ |
+ " except KeyError:\n" \ |
253 |
+ " os.environ['PATH']= os.path.abspath(os.path.dirname(sys.argv[0]))\n" \ |
+ " os.environ['PATH']= os.path.abspath(os.path.dirname(sys.argv[0]))\n" \ |
254 |
+ "else: \n" \ |
+ "else: \n" \ |
255 |
+ " _BASE = os.path.abspath(os.path.join(os.path.dirname(__file__),'..'))\n" \ |
+ " _BASE = os.path.abspath(os.path.join(os.path.dirname(__file__),'..'))\n" \ |
256 |
+ "INST_GNUE_CONNECTIONS=os.path.join(_BASE,'etc','connections.conf')\n" \ |
+ "INST_GNUE_CONNECTIONS=os.path.join(_BASE,'etc','connections.conf')\n" \ |
257 |
+ "os.environ['INSTALL_PREFIX']=_BASE\n" \ |
+ "os.environ['INSTALL_PREFIX']=_BASE\n" \ |
258 |
+ "os.environ['INSTALL_LIB']=_BASE\n" \ |
+ "os.environ['INSTALL_LIB']=_BASE\n" \ |
259 |
+ "os.putenv('PYTHONCASEOK','1')\n" \ |
+ "os.putenv('PYTHONCASEOK','1')\n" \ |
260 |
+ config_line \ |
+ config_line \ |
261 |
+ "if os.path.isdir(os.path.join(_BASE,'extras')):\n" \ |
+ "if os.path.isdir(os.path.join(_BASE,'extras')):\n" \ |
262 |
+ " sys.path.append(os.path.join(_BASE,'extras'))\n" \ |
+ " sys.path.append(os.path.join(_BASE,'extras'))\n" \ |
263 |
+ "#######\n\n" |
+ "#######\n\n" |
264 |
|
return gnue_env |
265 |
|
|
266 |
|
# --------------------------------------------------------------------------- |
267 |
|
# Generate the real scripts |
268 |
|
# --------------------------------------------------------------------------- |
269 |
|
|
270 |
for script in self.scripts: |
def _generate_scripts (self, path_line, config_line): |
271 |
print "Building %s..."% (script), |
gnue_env = self._build_gnue_env (path_line, config_line) |
272 |
|
|
273 |
|
for script in self.distribution.scripts: |
274 |
|
print "building script %s" % script |
275 |
|
|
276 |
fin = open(script+".in", "r") |
fin = open(script+".in", "r") |
277 |
fout = open(script, "w") |
fout = open(script, "w") |
278 |
|
|
|
print "Generating script %s from %s.in" % (script,script) |
|
|
|
|
279 |
lines = fin.readlines() |
lines = fin.readlines() |
280 |
|
|
281 |
for i in range(0, len(lines)): |
for i in range(0, len(lines)): |
283 |
lines[i] = gnue_env |
lines[i] = gnue_env |
284 |
|
|
285 |
fout.writelines(lines) |
fout.writelines(lines) |
286 |
|
|
287 |
fin.close() |
fin.close() |
288 |
fout.close() |
fout.close() |
289 |
print "OK" |
|
290 |
|
# --------------------------------------------------------------------------- |
291 |
|
# Do it all - this is called by setup () if option install is given |
292 |
|
# --------------------------------------------------------------------------- |
293 |
|
|
294 |
|
def finalize_options (self): |
295 |
|
install.finalize_options (self) |
296 |
|
if self.finalized: |
297 |
|
return |
298 |
|
|
299 |
|
# if install directory isn't in Python's search path, add it there |
300 |
|
if self.install_lib in sys.path: |
301 |
|
path_line = "" |
302 |
|
else: |
303 |
|
sys.path.append (self.install_lib) |
304 |
|
path_line = "import sys\nsys.path.append('%s')\n" % self.install_lib |
305 |
|
|
306 |
|
self._check_dependencies () |
307 |
|
|
308 |
|
self._generate_scripts (path_line, config_line) |
309 |
|
|
310 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
311 |
# GNUE_VERSION_SUFFIX handling |
# GNUE_VERSION_SUFFIX handling |
333 |
samplefiles = ["samples/sample.gfd", "samples/setup-pgsql.sh", |
samplefiles = ["samples/sample.gfd", "samples/setup-pgsql.sh", |
334 |
"samples/setup-mysql.sh"] |
"samples/setup-mysql.sh"] |
335 |
|
|
|
if have_prefix: |
|
|
classrepdir = os.path.join (install_lib, "gnue", "appserver", "classrep") |
|
|
else: |
|
|
classrepdir = "lib/python/gnue/appserver/classrep" |
|
|
|
|
336 |
setup (name = "GNUe-AppServer", |
setup (name = "GNUe-AppServer", |
337 |
version = VERSION + suffix, |
version = VERSION + suffix, |
338 |
description = "GNU Enterprise Application Server", |
description = "GNU Enterprise Application Server", |
340 |
author = "GNUe Application Server Team", |
author = "GNUe Application Server Team", |
341 |
author_email = "gnue-dev@gnue.org", |
author_email = "gnue-dev@gnue.org", |
342 |
url = "http://www.gnue.org", |
url = "http://www.gnue.org", |
343 |
|
licence = "GPL", |
344 |
|
|
345 |
# Override certain command classes with our own ones |
# Override certain command classes with our own ones |
346 |
cmdclass = {"build_scripts": my_build_scripts}, |
cmdclass = {"install": my_install}, |
347 |
|
|
348 |
data_files = [ ("doc/appserver", docfiles), |
data_files = [ ("doc/appserver", docfiles), |
349 |
("man/man1", manfiles), |
("man/man1", manfiles), |
355 |
("samples/appserver/pgsql", ["samples/pgsql/full.sql"]), |
("samples/appserver/pgsql", ["samples/pgsql/full.sql"]), |
356 |
("samples/appserver/sybase", ["samples/sybase/full.sql"]), |
("samples/appserver/sybase", ["samples/sybase/full.sql"]), |
357 |
("shared/grpc", ["grpc/appserver.grpc"]), |
("shared/grpc", ["grpc/appserver.grpc"]), |
358 |
(classrepdir, ["src/classrep/repository.ini"]) |
("share/gnue-appserver", ["src/classrep/repository.ini"]) |
359 |
], |
], |
360 |
|
|
361 |
packages = ["gnue.appserver", |
packages = ["gnue.appserver", |
374 |
if "install" in sys.argv or "bdist_rpm" in sys.argv: |
if "install" in sys.argv or "bdist_rpm" in sys.argv: |
375 |
if sys.platform != "win32": |
if sys.platform != "win32": |
376 |
os.system ("/bin/rm -rf setup.cfg") |
os.system ("/bin/rm -rf setup.cfg") |
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
# Be happy |
|
|
# ----------------------------------------------------------------------------- |
|
|
|
|
|
if "sdist" in sys.argv or "build" in sys.argv or "install" in sys.argv: |
|
|
print "./setup.py successfully completed." |
|