29 |
import os.path |
import os.path |
30 |
import copy |
import copy |
31 |
|
|
32 |
|
from distutils.core import setup |
33 |
|
from distutils.command.build_scripts import build_scripts |
34 |
|
|
35 |
from src import PACKAGE, VERSION |
from src import PACKAGE, VERSION |
36 |
|
|
37 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
40 |
|
|
41 |
if sys.hexversion < 0x02010000: |
if sys.hexversion < 0x02010000: |
42 |
print "%s needs at least Python version 2.1" % PACKAGE |
print "%s needs at least Python version 2.1" % PACKAGE |
43 |
sys.exit() |
sys.exit (1) |
44 |
|
|
45 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
46 |
# distutils won't allow us to set absolute path prefix on windows |
# distutils won't allow us to set absolute path prefix on windows |
47 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
48 |
|
|
49 |
if not 'sdist' in sys.argv: |
if "install" in sys.argv or "bdist_rpm" in sys.argv: |
50 |
if sys.platform != 'win32': |
if sys.platform != "win32": |
51 |
os.system ("""cp setup.cfg.in setup.cfg""") |
os.system ("cp setup.cfg.in setup.cfg") |
52 |
else: |
|
53 |
try: |
# ----------------------------------------------------------------------------- |
54 |
os.remove('setup.cfg') |
# sdist (Source distribution): build documentation, SQL scripts and manpage |
55 |
except: |
# ----------------------------------------------------------------------------- |
56 |
pass |
|
57 |
|
if "sdist" in sys.argv: |
58 |
# ----------------------------------------------------------------------------- |
# First check if we have everything installed we need to build the |
59 |
# Initalize stuff |
# distribution |
60 |
# ----------------------------------------------------------------------------- |
|
61 |
|
# Texinfo |
62 |
from distutils.core import setup |
if os.system ("makeinfo --version > /dev/null") != 0: |
63 |
from distutils.command.build_scripts import build_scripts |
print "Could not find 'makeinfo'. Please install Texinfo 4.0 or greater." |
64 |
|
sys.exit (1) |
65 |
docfiles = None |
|
66 |
manfiles = None |
# create-technote-index from gnue-common/utils |
67 |
|
file = "../gnue-common/utils/create-technote-index.py" |
68 |
# ----------------------------------------------------------------------------- |
if not os.path.isfile (file): |
69 |
# sdist (Source distribution): build docs |
print "Could not find file '%s'." % file |
70 |
# ----------------------------------------------------------------------------- |
print "Please download gnue-common 0.5.0 or greater." |
71 |
|
sys.exit (1) |
72 |
if 'sdist' in sys.argv: |
|
73 |
print """ |
# Sablotron |
74 |
We are going to create the docs needed for the |
if os.system ("sabcmd --version > /dev/null") != 0: |
75 |
source distro. You'll need texinfo installed. |
print "Could not find 'sabcmd'. Please install Sablotron." |
76 |
""" |
sys.exit (1) |
77 |
raw_input ("Press Control-D to abort or any other key to continue") |
|
78 |
os.system (""" |
# xsl scripts from gnue-common/utils/xml2sql |
79 |
cd doc/api |
for cmd in ["pgsql", "mysql", "mssql", "sybase", "interbase", "display", |
80 |
make html |
"strip.command"]: |
81 |
make txt |
file = "../gnue-common/utils/xml2sql/%s.xsl" % cmd |
82 |
make pdf |
if not os.path.isfile (file): |
83 |
cd ../whitepaper |
print "Could not find file '%s'." % file |
84 |
make html |
print "Please download gnue-common 0.5.0 or greater." |
85 |
make txt |
sys.exit (1) |
86 |
make pdf |
|
87 |
""") |
# is gacvs available (to build man pages)? |
88 |
|
if not os.path.isfile ("scripts/gacvs"): |
89 |
print "Now, we are going to create the man pages for our tools." |
print "Could not find file 'scripts/gacvs'. Please run 'setup-cvs.py'." |
90 |
os.system( """ |
sys.exit (1) |
91 |
if [ ! -e man ] |
|
92 |
then |
# --------------------------------------------------------------------------- |
93 |
mkdir man |
|
94 |
fi |
# Build documentation |
95 |
cd man |
print "building documentation: doc/api" |
96 |
../scripts/gacvs --generate-man-page |
if os.system ("cd doc/api && make txt") != 0: |
97 |
""") |
sys.exit (1) |
98 |
|
|
99 |
|
print "building documentation: doc/whitepaper" |
100 |
|
if os.system ("cd doc/whitepaper && make txt") != 0: |
101 |
|
sys.exit (1) |
102 |
|
|
103 |
|
print "building documentation: doc/technotes" |
104 |
|
if os.system ("cd doc/technotes && make") != 0: |
105 |
|
sys.exit (1) |
106 |
|
|
107 |
|
# Build sample SQL scripts |
108 |
|
print "building sample sql scripts" |
109 |
|
if os.system ("cd samples && make") != 0: |
110 |
|
sys.exit (1) |
111 |
|
|
112 |
|
# Build man page |
113 |
|
print "building man page" |
114 |
|
if os.system ("mkdir -p man && cd man " \ |
115 |
|
+ "&& ../scripts/gacvs --generate-man-page") != 0: |
116 |
|
sys.exit (1) |
117 |
|
|
118 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
119 |
# build and install: Check dependencies |
# build and install: Check dependencies |
120 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
121 |
|
|
122 |
if ('build' in sys.argv) or ('install' in sys.argv): |
if ("build" in sys.argv) or ("install" in sys.argv): |
|
|
|
|
## TODO: These checks will not work as gnue.common |
|
|
## TODO: isn't in python's default search path. |
|
|
|
|
|
# # Verify that gnue-common is installed |
|
|
# try: |
|
|
# print "Checking for GNUe-Common....", |
|
|
# from gnue import common |
|
|
# if common.__dict__.has_key('VERSION'): |
|
|
# print "OK (version %s)" % common.VERSION |
|
|
# else: |
|
|
# print "OK" |
|
|
# except ImportError: |
|
|
# print """ |
|
|
#You will need to install gnue-common before |
|
|
#GNUe Application Server will function. You can |
|
|
#obtain a copy from |
|
|
# |
|
|
#http://www.gnuenterprise.org/download.php |
|
|
#""" |
|
|
# sys.exit() |
|
|
# |
|
|
# # Verify that gnue-common has newest dbdriver/appserver |
|
|
# try: |
|
|
# print "Checking for dbdriver/appserver....", |
|
|
# from gnue.common.dbdrivers.appserver import DBdriver |
|
|
# print "OK (version %s)" % DBdriver.VERSION |
|
|
# |
|
|
# except ImportError: |
|
|
# print """ |
|
|
#You will need to install newer version of gnue-common before |
|
|
#GNUe Application Server will function. You can |
|
|
#obtain a copy from |
|
|
# |
|
|
#http://www.gnuenterprise.org/download.php |
|
|
#(You need at least version 0.2.0) |
|
|
#""" |
|
|
# sys.exit() |
|
|
# |
|
123 |
|
|
124 |
|
# xml |
125 |
|
try: |
126 |
|
print "checking Python xml library" |
127 |
|
import xml |
128 |
|
except ImportError: |
129 |
|
print "Could not import the xml package. " \ |
130 |
|
+ "Please install Python's XML library." |
131 |
|
print "The file 'INSTALL' contains more information about dependencies." |
132 |
|
sys.exit (1) |
133 |
|
|
|
# |
|
134 |
# Verify at least one RPC driver is installed |
# Verify at least one RPC driver is installed |
|
# |
|
135 |
RPCOK = 0 |
RPCOK = 0 |
136 |
|
|
137 |
print "Checking for available GNU-RPC drivers...." |
# xmlrpc |
138 |
# XMLRPC |
print "checking Python xmlrpc library (py-xmlrpc)" |
139 |
try: |
try: |
|
print " PY-XMLRPC....", |
|
140 |
import xmlrpc |
import xmlrpc |
|
print "OK" |
|
141 |
RPCOK = 1 |
RPCOK = 1 |
142 |
except ImportError: |
except ImportError: |
143 |
print "No" |
pass |
144 |
|
|
145 |
# PW_XMLRPC |
# pw_xmlrpc |
146 |
|
print "checking Python xmlrpclib library (pw-xmlrpc)" |
147 |
try: |
try: |
148 |
print " Pythonware XMLRPC....", |
import xmlrpclib |
|
try: |
|
|
import xmlrpclib |
|
|
except ImportError: |
|
|
from xmlrpclib import xmlrpclib |
|
|
print "OK" |
|
149 |
RPCOK = 1 |
RPCOK = 1 |
150 |
except ImportError: |
except ImportError: |
151 |
print "No" |
pass |
|
|
|
|
# SOAP |
|
|
try: |
|
|
print " SOAP (currently not working)....", |
|
|
from SOAP import SOAP |
|
|
print "OK" |
|
|
RPCOK = 1 |
|
|
except ImportError: |
|
|
print "No" |
|
|
|
|
152 |
|
|
153 |
|
# found any? |
154 |
if RPCOK != 1: |
if RPCOK != 1: |
155 |
print """ |
print """ |
156 |
No valid GNURRPC drivers are installed on this machine: |
No valid GNURRPC drivers are installed on this machine. |
157 |
Py-XMLRPC - http://sourceforge.net/projects/py-xmlrpc |
Please install one of the following packages. |
158 |
Pythonware XMLRPC - http://www.pythonware.com/products/xmlrpc/ |
py-xmlrpc - http://sourceforge.net/projects/py-xmlrpc |
159 |
SOAP - *** |
Pythonware XMLRPC - http://www.pythonware.com/products/xmlrpc |
160 |
CORBA - *** |
The file 'INSTALL' contains more information about dependencies. |
161 |
""" |
""" |
162 |
sys.exit() |
sys.exit (1) |
163 |
|
|
164 |
# List non-program files to be installed |
# gnue-common |
165 |
|
# TODO: Can't find out here where gnue-common is installed |
|
docfiles = ['README', 'INSTALL', 'AUTHORS', 'COPYING', 'NEWS', 'THANKS'] |
|
|
for file in ('doc/api/api.html', |
|
|
'doc/api/api.txt', |
|
|
'doc/api/api.pdf', |
|
|
'doc/whitepaper/whitepaper.html', |
|
|
'doc/whitepaper/whitepaper.txt', |
|
|
'doc/whitepaper/whitepaper.pdf'): |
|
|
if os.path.isfile(file): |
|
|
docfiles.append(file) |
|
|
else: |
|
|
print "WARNING: File %s does not exist... not installing!" % file |
|
|
|
|
|
manfiles = [] |
|
|
for file in ('man/gnue-appserver.1'): |
|
|
if os.path.isfile(file): |
|
|
manfiles.append(file) |
|
|
else: |
|
|
print "WARNING: File %s does not exist... not installing!" % file |
|
166 |
|
|
167 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
168 |
# Site config stuff |
# Some magic to create $script from $script.in while installing |
169 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
170 |
|
|
171 |
try: |
try: |
172 |
index = sys.argv.index('--cfg-file') |
index = sys.argv.index("--cfg-file") |
173 |
site_config = os.path.join(os.path.abspath(sys.argv[index+1])) |
site_config = os.path.join(os.path.abspath(sys.argv[index+1])) |
174 |
sys.argv.pop(index) |
sys.argv.pop(index) |
175 |
sys.argv.pop(index) |
sys.argv.pop(index) |
185 |
if self.finalized: |
if self.finalized: |
186 |
return |
return |
187 |
|
|
188 |
|
if sys.platform != "win32": |
189 |
if sys.platform != 'win32': |
dict = self.distribution.get_option_dict ("install") |
190 |
dict = self.distribution.get_option_dict("install") |
install_prefix = dict ["prefix"] [1] |
191 |
install_prefix = dict['prefix'][1] |
sys.path.append (dict ["install_lib"] [1]) |
|
|
|
192 |
gnue_env = \ |
gnue_env = \ |
193 |
"#######\n" \ |
"#######\n" \ |
194 |
+ "# The following variable were set when GNUe was installed\n" \ |
+ "# The following variable were set when GNUe was installed\n" \ |
195 |
+ "import os, sys\n" \ |
+ "import os, sys\n" \ |
196 |
+ "sys.path.append('%s')\n" % dict['install_lib'][1] \ |
+ "sys.path.append('%s')\n" % dict["install_lib"][1] \ |
197 |
+ "INST_GNUE_CONNECTIONS='%s/etc/connections.conf'\n" % dict['prefix'][1] \ |
+ "INST_GNUE_CONNECTIONS='%s/etc/connections.conf'\n" % dict["prefix"][1] \ |
198 |
+ "os.environ['INSTALL_LIB']='%s'\n" % dict['install_lib'][1] \ |
+ "os.environ['INSTALL_LIB']='%s'\n" % dict["install_lib"][1] \ |
199 |
+ "os.environ['INSTALL_PREFIX']='%s'\n" % dict['prefix'][1] \ |
+ "os.environ['INSTALL_PREFIX']='%s'\n" % dict["prefix"][1] \ |
200 |
+ config_line \ |
+ config_line \ |
201 |
+ "#######\n" |
+ "#######\n" |
202 |
else: |
else: |
203 |
|
options.append('install_lib = r"%s"' % sys.prefix) |
204 |
gnue_env = \ |
gnue_env = \ |
205 |
"#######\n" \ |
"#######\n" \ |
206 |
+ "# The following variables were set when GNUe was installed\n" \ |
+ "# The following variables were set when GNUe was installed\n" \ |
252 |
# and the packages will be created as GNUe-App-0.x.x-pre1.tar.gz |
# and the packages will be created as GNUe-App-0.x.x-pre1.tar.gz |
253 |
|
|
254 |
try: |
try: |
255 |
suffix = os.environ['GNUE_VERSION_SUFFIX'] |
suffix = os.environ["GNUE_VERSION_SUFFIX"] |
256 |
except KeyError: |
except KeyError: |
257 |
suffix = "" |
suffix = "" |
258 |
|
|
260 |
# Call the actual setup routine |
# Call the actual setup routine |
261 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
262 |
|
|
263 |
|
docfiles = ["AUTHORS", "COPYING", "INSTALL", "NEWS", "README", "ROADMAP", |
264 |
|
"THANKS", "TODO", "doc/api/api.txt", |
265 |
|
"doc/whitepaper/whitepaper.txt"] |
266 |
|
|
267 |
|
manfiles = ["man/gnue-appserver.1"] |
268 |
|
|
269 |
|
samplefiles = ["samples/sample.gfd", "samples/setup-pgsql.sh", |
270 |
|
"samples/setup-mysql.sh"] |
271 |
|
|
272 |
setup (name = "GNUe-AppServer", |
setup (name = "GNUe-AppServer", |
273 |
version = VERSION + suffix, |
version = VERSION + suffix, |
274 |
description = "GNU Enterprise Application Server", |
description = "GNU Enterprise Application Server", |
275 |
long_description = "", |
long_description = "", |
276 |
author = "GNUe Application Server Team", |
author = "GNUe Application Server Team", |
277 |
author_email = "gnue-gnue-appserver@gnue.org", |
author_email = "gnue-dev@gnue.org", |
278 |
url = "http://www.gnue.org", |
url = "http://www.gnue.org", |
279 |
|
|
280 |
# Override certain command classes with our own ones |
# Override certain command classes with our own ones |
281 |
cmdclass = {'build_scripts':my_build_scripts}, |
cmdclass = {"build_scripts": my_build_scripts}, |
282 |
|
|
283 |
data_files = [ ('doc/appserver', docfiles), |
data_files = [ ("doc/appserver", docfiles), |
284 |
('man/man1', manfiles), |
("man/man1", manfiles), |
285 |
('samples/appserver',['samples/appservertest.gfd', |
("samples/appserver", samplefiles), |
286 |
'samples/setup-pgsql.sh', |
("samples/appserver/interbase", |
287 |
# 'samples/setup-mysql.sh' |
["samples/interbase/full.sql"]), |
288 |
]), |
("samples/appserver/mssql", ["samples/mssql/full.sql"]), |
289 |
('shared/grpc',['grpc/appserver.grpc']) |
("samples/appserver/mysql", ["samples/mysql/full.sql"]), |
290 |
|
("samples/appserver/pgsql", ["samples/pgsql/full.sql"]), |
291 |
|
("samples/appserver/sybase", ["samples/sybase/full.sql"]), |
292 |
|
("shared/grpc", ["grpc/appserver.grpc"]), |
293 |
|
("lib/python/gnue/appserver/classrep", |
294 |
|
["src/classrep/repository.ini"]) |
295 |
], |
], |
296 |
|
|
297 |
packages = ["gnue.appserver", |
packages = ["gnue.appserver", |
298 |
"gnue.appserver.classrep", |
"gnue.appserver.classrep", |
299 |
"gnue.appserver.language",], |
"gnue.appserver.language"], |
300 |
|
|
301 |
package_dir = {"gnue.appserver" : "src"}, |
package_dir = {"gnue.appserver" : "src"}, |
302 |
|
|
303 |
scripts = ["scripts/gnue-appserver"] |
scripts = ["scripts/gnue-appserver"] |
304 |
) |
) |
305 |
|
|
306 |
if 'install' in sys.argv: |
# ----------------------------------------------------------------------------- |
307 |
print """ |
# Clean up |
308 |
Note: |
# ----------------------------------------------------------------------------- |
|
Warnings about the files not being installed in pythons search path can be ignored. |
|
309 |
|
|
310 |
Make sure you have a default gnue.conf file (typically in /usr/local/gnue/etc. |
if "install" in sys.argv or "bdist_rpm" in sys.argv: |
311 |
A sample is provided in that directory that you can typically just copy over. |
if sys.platform != "win32": |
312 |
""" |
os.system ("/bin/rm -rf setup.cfg") |
313 |
|
|
314 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
315 |
# Clean up |
# Be happy |
316 |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
317 |
|
|
318 |
if not 'sdist' in sys.argv: |
if "sdist" in sys.argv or "build" in sys.argv or "install" in sys.argv: |
319 |
if sys.platform != 'win32': |
print "./setup.py successfully completed." |
|
os.system (""" /bin/rm -rf setup.cfg""") |
|