28 |
import os |
import os |
29 |
import copy |
import copy |
30 |
|
|
|
from distutils.core import setup |
|
|
from distutils.command.build import build |
|
|
from distutils.command.install import install |
|
|
|
|
31 |
from src import PACKAGE, VERSION |
from src import PACKAGE, VERSION |
32 |
|
|
33 |
# ----------------------------------------------------------------------------- |
try: |
34 |
# Check Python version |
from gnue.common.setup import GSetup |
35 |
# ----------------------------------------------------------------------------- |
except ImportError: |
36 |
|
print "You need GNUe-Common 0.5.2 or newer installed to install %s" % PACKAGE |
|
if sys.hexversion < 0x02010000: |
|
|
print "%s needs at least Python version 2.1" % PACKAGE |
|
37 |
sys.exit (1) |
sys.exit (1) |
38 |
|
|
39 |
# ----------------------------------------------------------------------------- |
class setup (GSetup): |
40 |
# Find out whether or not to use our setup.cfg |
|
41 |
# ----------------------------------------------------------------------------- |
# --------------------------------------------------------------------------- |
42 |
|
# Definition of basic parameters for distribution and installation. |
43 |
have_prefix = 0 |
# Please add new files/directories that should be installed here. |
44 |
for arg in sys.argv: |
# Note that you also have to add them to MANIFEST.in. |
45 |
if arg == "--prefix" or arg [:9] == "--prefix=" or \ |
# --------------------------------------------------------------------------- |
46 |
arg == "--home" or arg [:7] == "--home=": |
|
47 |
have_prefix = 1 |
def set_params (self, params): |
48 |
|
|
49 |
if "install" in sys.argv or "bdist_rpm" in sys.argv: |
# The Work |
50 |
if sys.platform != "win32" and not have_prefix: |
params ["name"] = PACKAGE |
51 |
os.system ("cp setup.cfg.in setup.cfg") |
params ["version"] = VERSION |
52 |
else: |
params ["description"] = "GNU Enterprise Application Server" |
53 |
try: |
params ["long_description"] = "" |
54 |
os.remove ("setup.cfg") |
params ["license"] = "GPL" |
55 |
except: |
|
56 |
pass |
# The Author |
57 |
|
params ["author"] = "GNU Enterprise Team" |
58 |
|
params ["author_email"] = "gnue-dev@gnu.org" |
59 |
|
params ["url"] = "http://www.gnue.org" |
60 |
|
|
61 |
|
# The Programs |
62 |
|
params ["package_dir"] = {"gnue.appserver": "src"} |
63 |
|
params ["scripts"] = ["scripts/gnue-appserver"] |
64 |
|
|
65 |
|
# The Data |
66 |
|
datafiles = ["src/classrep/repository.ini"] |
67 |
|
grpcfiles = ["grpc/appserver.grpc"] |
68 |
|
docfiles = ["doc/api/api.txt", "doc/whitepaper/whitepaper.txt"] |
69 |
|
samplefiles = self.allfiles ("samples") |
70 |
|
wfefiles = ["extensions/webfrontend/gnue-forms.js", |
71 |
|
"extensions/webfrontend/vcXMLRPC.js"] |
72 |
|
wfeimages = self.allfiles ("extensions/webfrontend/images") |
73 |
|
|
74 |
|
params ["data_files"] = \ |
75 |
|
[("share/gnue-appserver", datafiles), |
76 |
|
("shared/grpc", grpcfiles), |
77 |
|
("share/doc/gnue-appserver", docfiles), |
78 |
|
("share/doc/gnue-appserver/samples", samplefiles), |
79 |
|
("share/gnue-appserver/webfrontend", wfefiles), |
80 |
|
("share/gnue-appserver/webfrontend/images", wfeimages)] |
81 |
|
|
82 |
|
# --------------------------------------------------------------------------- |
83 |
|
# Build files to be distributed and installed: |
84 |
|
# Should generate the files that go in a distribution but aren't in CVS. |
85 |
|
# Gets called on sdist (always) and on build/install (only when run from CVS). |
86 |
|
# --------------------------------------------------------------------------- |
87 |
|
|
88 |
# ----------------------------------------------------------------------------- |
def build_files (self): |
89 |
# Build files to be distributed and installed |
|
90 |
# ----------------------------------------------------------------------------- |
# all this only works on posix systems :-( |
91 |
|
if os.name != "posix": |
92 |
def build_files (): |
return |
93 |
# First check if we have everything installed we need to build the |
|
94 |
# distribution |
# First check if we have everything installed we need to build the |
95 |
|
# distribution |
96 |
# Texinfo |
|
97 |
if os.system ("makeinfo --version > /dev/null") != 0: |
# Texinfo |
98 |
print "Could not find 'makeinfo'. Please install Texinfo 4.0 or greater." |
if os.system ("makeinfo --version > /dev/null") != 0: |
99 |
sys.exit (1) |
print "Could not find 'makeinfo'. Please install Texinfo 4.0 or greater." |
100 |
|
sys.exit (1) |
101 |
# create-technote-index from gnue-common/utils |
|
102 |
file = "../gnue-common/utils/create-technote-index.py" |
# create-technote-index from gnue-common/utils |
103 |
if not os.path.isfile (file): |
file = "../gnue-common/utils/create-technote-index.py" |
|
print "Could not find file '%s'." % file |
|
|
print "Please download gnue-common 0.5.0 or greater." |
|
|
sys.exit (1) |
|
|
|
|
|
# Sablotron |
|
|
if os.system ("sabcmd --version > /dev/null") != 0: |
|
|
print "Could not find 'sabcmd'. Please install Sablotron." |
|
|
sys.exit (1) |
|
|
|
|
|
# xsl scripts from gnue-common/utils/xml2sql |
|
|
for cmd in ["pgsql", "mysql", "mssql", "sybase", "interbase", "display", |
|
|
"strip.command"]: |
|
|
file = "../gnue-common/utils/xml2sql/%s.xsl" % cmd |
|
104 |
if not os.path.isfile (file): |
if not os.path.isfile (file): |
105 |
print "Could not find file '%s'." % file |
print "Could not find file '%s'." % file |
106 |
print "Please download gnue-common 0.5.0 or greater." |
print "Please download gnue-common 0.5.0 or greater." |
107 |
sys.exit (1) |
sys.exit (1) |
108 |
|
|
109 |
# is gacvs available (to build man pages)? |
# Sablotron |
110 |
if not os.path.isfile ("scripts/gacvs"): |
if os.system ("sabcmd --version > /dev/null") != 0: |
111 |
print "Could not find file 'scripts/gacvs'. Please run 'setup-cvs.py'." |
print "Could not find 'sabcmd'. Please install Sablotron." |
112 |
sys.exit (1) |
sys.exit (1) |
|
|
|
|
# --------------------------------------------------------------------------- |
|
|
|
|
|
# Build documentation |
|
|
print "building documentation: doc/api" |
|
|
if os.system ("cd doc/api && make txt") != 0: |
|
|
sys.exit (1) |
|
|
|
|
|
print "building documentation: doc/whitepaper" |
|
|
if os.system ("cd doc/whitepaper && make txt") != 0: |
|
|
sys.exit (1) |
|
|
|
|
|
print "building documentation: doc/technotes" |
|
|
if os.system ("cd doc/technotes && make") != 0: |
|
|
sys.exit (1) |
|
|
|
|
|
# Build sample SQL scripts |
|
|
print "building sample sql scripts" |
|
|
if os.system ("cd samples && make") != 0: |
|
|
sys.exit (1) |
|
|
|
|
|
# Build man page |
|
|
print "building man page" |
|
|
if os.system ("mkdir -p man && cd man " \ |
|
|
+ "&& ../scripts/gacvs --generate-man-page") != 0: |
|
|
sys.exit (1) |
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
# Source distribution: Build files to be distributed |
|
|
# ----------------------------------------------------------------------------- |
|
|
|
|
|
if "sdist" in sys.argv: |
|
|
build_files () |
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
# User can supply a path to the config file |
|
|
# ----------------------------------------------------------------------------- |
|
|
|
|
|
try: |
|
|
index = sys.argv.index("--cfg-file") |
|
|
site_config = os.path.join(os.path.abspath(sys.argv[index+1])) |
|
|
sys.argv.pop(index) |
|
|
sys.argv.pop(index) |
|
|
config_line = "os.environ['GNUE_INSTALLED_SITE_CFG']='%s'\n" % site_config |
|
|
except ValueError: |
|
|
config_line = "" |
|
113 |
|
|
114 |
# ============================================================================= |
# xsl scripts from gnue-common/utils/xml2sql |
115 |
# Before build: if done from CVS, build files to be installed |
for cmd in ["pgsql", "mysql", "mssql", "sybase", "interbase", "display", |
116 |
# ============================================================================= |
"strip.command"]: |
117 |
|
file = "../gnue-common/utils/xml2sql/%s.xsl" % cmd |
118 |
|
if not os.path.isfile (file): |
119 |
|
print "Could not find file '%s'." % file |
120 |
|
print "Please download gnue-common 0.5.0 or greater." |
121 |
|
sys.exit (1) |
122 |
|
|
123 |
class gnue_build (build): |
# ------------------------------------------------------------------------- |
124 |
|
|
125 |
def finalize_options (self): |
# Build documentation |
126 |
build.finalize_options (self) |
print "building documentation: doc/api" |
127 |
if self.finalized: |
if os.system ("cd doc/api && make txt") != 0: |
128 |
return |
sys.exit (1) |
129 |
|
|
130 |
if not os.path.isfile ("PKG-INFO"): # downloaded from CVS? |
print "building documentation: doc/whitepaper" |
131 |
if sys.platform != 'win32': |
if os.system ("cd doc/whitepaper && make txt") != 0: |
132 |
build_files () |
sys.exit (1) |
133 |
|
|
134 |
# ============================================================================= |
print "building documentation: doc/technotes" |
135 |
# Before installation: check dependencies and create real scripts |
if os.system ("cd doc/technotes && make") != 0: |
136 |
# ============================================================================= |
sys.exit (1) |
137 |
|
|
138 |
class gnue_install (install): |
# Build sample SQL scripts |
139 |
|
print "building sample sql scripts" |
140 |
|
if os.system ("cd samples && make") != 0: |
141 |
|
sys.exit (1) |
142 |
|
|
143 |
# --------------------------------------------------------------------------- |
# --------------------------------------------------------------------------- |
144 |
# Check dependencies |
# Check dependencies for installation: |
145 |
|
# Should sys.exit(1) in case any requirement isn't met. |
146 |
|
# Gets called on install. |
147 |
# --------------------------------------------------------------------------- |
# --------------------------------------------------------------------------- |
148 |
|
|
149 |
def _check_dependencies (self): |
def check_dependencies (self): |
150 |
|
|
151 |
# ------------------------------------------------------------------------- |
# ------------------------------------------------------------------------- |
152 |
# xml |
# xml |
192 |
""" |
""" |
193 |
sys.exit (1) |
sys.exit (1) |
194 |
|
|
195 |
# ------------------------------------------------------------------------- |
# ============================================================================= |
|
# gnue-common |
|
|
print "checking GNUe-Common library" |
|
|
try: |
|
|
import gnue.common |
|
|
except ImportError: |
|
|
print "---" |
|
|
print "Could not import the gnue-common package. " \ |
|
|
+ "Please install GNUe-Common." |
|
|
print "Note that GNUe-Appserver has to be installed in the same" |
|
|
print "directory as GNUe-Common." |
|
|
print "The file 'INSTALL' contains more information about dependencies." |
|
|
sys.exit (1) |
|
|
if gnue.common.__hexversion__ < 0x00050100: |
|
|
print "---" |
|
|
print "The gnue-common package you have installed is too old." |
|
|
print "Please install GNUe-Common 0.5.1 or greater." |
|
|
print "The file 'INSTALL' contains more information about dependencies." |
|
|
sys.exit (1) |
|
|
appserver_path = os.path.normcase (os.path.dirname (self.install_lib)) |
|
|
common_path = os.path.normcase (os.path.dirname (gnue.__path__ [0])) |
|
|
if appserver_path != common_path: |
|
|
print "---" |
|
|
print "GNUe-Common is installed in %s." % common_path |
|
|
print "You are trying to install GNUe-AppServer in %s." % appserver_path |
|
|
print "GNUe-Appserver has to be installed in the same directory as GNUe-Common." |
|
|
sys.exit (1) |
|
|
|
|
|
# --------------------------------------------------------------------------- |
|
|
# Build the commands to place into the scripts |
|
|
# --------------------------------------------------------------------------- |
|
|
|
|
|
def _build_gnue_env (self, path_line, config_line): |
|
|
if sys.platform != "win32": |
|
|
gnue_env = \ |
|
|
"#######\n" \ |
|
|
+ "# The following variables were set when GNUe was installed\n" \ |
|
|
+ "INST_GNUE_CONNECTIONS='%s/etc/connections.conf'\n" % self.prefix \ |
|
|
+ path_line \ |
|
|
+ "import os\n" \ |
|
|
+ config_line \ |
|
|
+ "#######\n" |
|
|
else: |
|
|
gnue_env = \ |
|
|
"#######\n" \ |
|
|
+ "# The following variables were set when GNUe was installed\n" \ |
|
|
+ "# (Generated for a Win32 system)\n" \ |
|
|
+ "import os, sys\n" \ |
|
|
+ "if __name__ == '__main__': \n" \ |
|
|
+ " _BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),'..'))\n" \ |
|
|
+ " try:\n" \ |
|
|
+ " os.environ['PATH']= os.path.abspath(os.path.dirname(sys.argv[0])) + ';' + os.environ['PATH']\n" \ |
|
|
+ " except KeyError:\n" \ |
|
|
+ " os.environ['PATH']= os.path.abspath(os.path.dirname(sys.argv[0]))\n" \ |
|
|
+ "else: \n" \ |
|
|
+ " _BASE = os.path.abspath(os.path.join(os.path.dirname(__file__),'..'))\n" \ |
|
|
+ "INST_GNUE_CONNECTIONS=os.path.join(_BASE,'etc','connections.conf')\n" \ |
|
|
+ "os.putenv('PYTHONCASEOK','1')\n" \ |
|
|
+ config_line \ |
|
|
+ "if os.path.isdir(os.path.join(_BASE,'extras')):\n" \ |
|
|
+ " sys.path.append(os.path.join(_BASE,'extras'))\n" \ |
|
|
+ "#######\n\n" |
|
|
return gnue_env |
|
|
|
|
|
# --------------------------------------------------------------------------- |
|
|
# Generate the real scripts |
|
|
# --------------------------------------------------------------------------- |
|
|
|
|
|
def _generate_scripts (self, path_line, config_line): |
|
|
gnue_env = self._build_gnue_env (path_line, config_line) |
|
|
|
|
|
for script in self.distribution.scripts: |
|
|
print "building script %s" % script |
|
|
|
|
|
fin = open(script+".in", "r") |
|
|
fout = open(script, "w") |
|
|
|
|
|
lines = fin.readlines() |
|
|
|
|
|
for i in range(0, len(lines)): |
|
|
if string.strip(lines[i]) == "__GNUEENV__": |
|
|
lines[i] = gnue_env |
|
|
|
|
|
fout.writelines(lines) |
|
|
|
|
|
fin.close() |
|
|
fout.close() |
|
|
|
|
|
# --------------------------------------------------------------------------- |
|
|
# Do it all - this is called by setup () if option install is given |
|
|
# --------------------------------------------------------------------------- |
|
|
|
|
|
def finalize_options (self): |
|
|
install.finalize_options (self) |
|
|
if self.finalized: |
|
|
return |
|
|
|
|
|
# if install directory isn't in Python's search path, add it there |
|
|
if self.install_lib in sys.path: |
|
|
path_line = "" |
|
|
else: |
|
|
sys.path.append (self.install_lib) |
|
|
path_line = "import sys\nsys.path.append('%s')\n" % self.install_lib |
|
|
|
|
|
self._check_dependencies () |
|
|
|
|
|
self._generate_scripts (path_line, config_line) |
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
# GNUE_VERSION_SUFFIX handling |
|
|
# ----------------------------------------------------------------------------- |
|
|
|
|
|
# You can run: |
|
|
# $ GNUE_VERSION_SUFFIX=-pre1 ./setup.py sdist |
|
|
# and the packages will be created as GNUe-App-0.x.x-pre1.tar.gz |
|
196 |
|
|
197 |
try: |
if __name__ == "__main__": |
198 |
suffix = os.environ["GNUE_VERSION_SUFFIX"] |
setup().run() |
|
except KeyError: |
|
|
suffix = "" |
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
# Call the actual setup routine |
|
|
# ----------------------------------------------------------------------------- |
|
|
|
|
|
datafiles = ["src/classrep/repository.ini"] |
|
|
|
|
|
grpcfiles = ["grpc/appserver.grpc"] |
|
|
|
|
|
# check if warnings should be printed |
|
|
phony = 1 |
|
|
if ('--help' in sys.argv) or (len(sys.argv)==1): |
|
|
phony = 0 |
|
|
|
|
|
manfiles = [] |
|
|
for file in ("man/gnue-appserver.1",): |
|
|
if os.path.isfile(file): |
|
|
manfiles.append(file) |
|
|
else: |
|
|
if phony: |
|
|
print "WARNING: File %s does not exist... not installing!" % file |
|
|
|
|
|
docfiles = [] |
|
|
for file in ("AUTHORS", "COPYING", "INSTALL", "NEWS", "README", "ROADMAP", |
|
|
"THANKS", "TODO", "doc/api/api.txt", |
|
|
"doc/whitepaper/whitepaper.txt"): |
|
|
if os.path.isfile(file): |
|
|
docfiles.append(file) |
|
|
else: |
|
|
if phony: |
|
|
print "WARNING: File %s does not exist... not installing!" % file |
|
|
|
|
|
samplefiles = [] |
|
|
for file in ("samples/sample.gfd", "samples/GNUe_ClassRepository.gfd", |
|
|
"samples/interbase.sql", "samples/mssql.sql", |
|
|
"samples/mysql.sql", "samples/pgsql.sql", "samples/sybase.sql", |
|
|
"samples/setup-mysql.sh", "samples/setup-pgsql.sh"): |
|
|
if os.path.isfile(file): |
|
|
samplefiles.append(file) |
|
|
else: |
|
|
if phony: |
|
|
print "WARNING: File %s does not exist... not installing!" % file |
|
|
|
|
|
wfefiles = ["extensions/webfrontend/gnue-forms.js", |
|
|
"extensions/webfrontend/vcXMLRPC.js"] |
|
|
|
|
|
wfeimages = [] |
|
|
for file in os.listdir ("extensions/webfrontend/images"): |
|
|
if not file == "CVS": |
|
|
wfeimages.append ("extensions/webfrontend/images/" + file) |
|
|
|
|
|
setup (name = "GNUe-AppServer", |
|
|
version = VERSION + suffix, |
|
|
description = "GNU Enterprise Application Server", |
|
|
long_description = "", |
|
|
author = "GNUe Application Server Team", |
|
|
author_email = "gnue-dev@gnue.org", |
|
|
url = "http://www.gnue.org", |
|
|
license = "GPL", |
|
|
|
|
|
# Override certain command classes with our own ones |
|
|
cmdclass = {"build": gnue_build, |
|
|
"install": gnue_install}, |
|
|
|
|
|
data_files = [("share/gnue-appserver", datafiles), |
|
|
("shared/grpc", grpcfiles), |
|
|
("share/man/man1", manfiles), |
|
|
("share/doc/gnue-appserver", docfiles), |
|
|
("share/doc/gnue-appserver/samples", samplefiles), |
|
|
("share/gnue-appserver/webfrontend", wfefiles), |
|
|
("share/gnue-appserver/webfrontend/images", wfeimages)], |
|
|
|
|
|
packages = ["gnue.appserver", |
|
|
"gnue.appserver.classrep", |
|
|
"gnue.appserver.language"], |
|
|
|
|
|
package_dir = {"gnue.appserver" : "src"}, |
|
|
|
|
|
scripts = ["scripts/gnue-appserver"] |
|
|
) |
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
# Clean up |
|
|
# ----------------------------------------------------------------------------- |
|
|
|
|
|
if "install" in sys.argv or "bdist_rpm" in sys.argv: |
|
|
if sys.platform != "win32": |
|
|
os.system ("/bin/rm -rf setup.cfg") |
|