1 |
#!/usr/bin/env python |
#!/usr/bin/env python |
2 |
# |
# |
3 |
|
# GNU Enterprise Forms - Installation Procedure |
4 |
|
# |
5 |
# Copyright 2001-2003 Free Software Foundation |
# Copyright 2001-2003 Free Software Foundation |
6 |
# |
# |
7 |
# This file is part of GNU Enterprise. |
# This file is part of GNU Enterprise. |
21 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
22 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
23 |
# |
# |
24 |
|
# $Id$ |
25 |
|
|
26 |
import sys |
import sys |
|
import string |
|
27 |
import os |
import os |
|
import os.path |
|
|
import copy |
|
|
|
|
|
from src import VERSION |
|
|
|
|
|
# |
|
|
# hack to deal w/ fact distutils won't |
|
|
# allow us to set absolute path prefix |
|
|
# on windows |
|
|
# |
|
|
|
|
|
if not 'sdist' in sys.argv: |
|
|
if sys.platform != 'win32' and '--prefix' not in sys.argv and '--root' not in sys.argv: |
|
|
os.system ("""cp setup.cfg.in setup.cfg""") |
|
|
else: |
|
|
try: |
|
|
os.remove('setup.cfg') |
|
|
except: |
|
|
pass |
|
28 |
|
|
29 |
|
from src import PACKAGE, VERSION |
30 |
|
|
31 |
try: |
try: |
32 |
import distutils |
from gnue.common.setup import GSetup |
|
from distutils.command.build_scripts import build_scripts |
|
|
from distutils.command.build import build |
|
|
from setupext import Data_Files, install_Data_Files |
|
33 |
except ImportError: |
except ImportError: |
34 |
print """ |
print "You need GNUe-Common 0.5.2 or newer installed to install %s" % PACKAGE |
35 |
Setup requires that python's distutils be |
sys.exit (1) |
|
installed. You can get a copy of it from |
|
|
http://www.python.org/sigs/distutils-sig/ |
|
|
""" |
|
|
sys.exit() |
|
|
|
|
|
|
|
|
if 'sdist' in sys.argv: |
|
|
|
|
|
## print """ |
|
|
##We are going to create the docs needed for the |
|
|
##source distro. You'll need lyx installed. |
|
|
##""" |
|
|
## raw_input ("Press Control-D to abort or any other key to continue") |
|
|
## os.system (""" |
|
|
##cd doc |
|
|
##lyx --export text techref.lyx |
|
|
##lyx --export pdf techref.lyx |
|
|
##lyx --export text user_guide.lyx |
|
|
##lyx --export pdf user_guide.lyx |
|
|
##""") |
|
|
|
|
|
|
|
|
print "Now, we are going to create the man pages for our tools." |
|
|
os.system( """ |
|
|
if [ ! -e man ] |
|
|
then |
|
|
mkdir man |
|
|
fi |
|
|
cd man |
|
|
../scripts/gfcvs --generate-man-page |
|
|
""") |
|
|
|
|
36 |
|
|
37 |
|
# ============================================================================= |
38 |
|
|
39 |
# Skip dependency checks? |
class setup (GSetup): |
|
try: |
|
|
index = sys.argv.index('--skip-tests') |
|
|
print "Skipping dependency checks..." |
|
|
doTests = 0 |
|
|
sys.argv.pop(index) |
|
|
|
|
|
except ValueError: |
|
|
doTests = 1 |
|
|
|
|
|
|
|
|
if doTests and (('build' in sys.argv) or ('install' in sys.argv)): |
|
|
# |
|
|
# Verify at least one UI is installed |
|
|
# |
|
|
UIOK = 0 |
|
|
|
|
|
print "Checking for available UI drivers...." |
|
|
# PyNcurses |
|
|
try: |
|
|
print " Pyncurses(Currently not working)....", |
|
|
import ncurses.form |
|
|
print "OK" |
|
|
UIOK = 0 |
|
|
except ImportError: |
|
|
print "No" |
|
|
|
|
|
# Curses |
|
|
try: |
|
|
print " Curses(Currently not working)....", |
|
|
import curses |
|
|
print "OK" |
|
|
UIOK = 0 |
|
|
except ImportError: |
|
|
print "No" |
|
|
|
|
|
# wxPython |
|
|
try: |
|
|
print " wxPython....", |
|
|
from wxPython.wx import * |
|
|
print "OK" |
|
|
UIOK = 1 |
|
|
except ImportError: |
|
|
print "No" |
|
|
|
|
|
# We have no reliable way of verifying the above! |
|
|
UIOK = 1 |
|
|
|
|
|
if UIOK != 1: |
|
|
print """ |
|
|
No valid UI drivers are installed on this machine: |
|
|
wxPython - www.wxpython.org |
|
|
pyncurses - pyncurses.sourceforge.net |
|
|
python curses - Read python install docs on how to activate |
|
|
""" |
|
|
sys.exit() |
|
|
|
|
|
# |
|
|
# Verify for that mx.DateTime exists |
|
|
# |
|
|
UIOK = 0 |
|
|
|
|
|
print "Checking for other dependencies...." |
|
|
# PyNcurses |
|
|
try: |
|
|
print " mx DateTime....", |
|
|
from mx.DateTime import DateTime |
|
|
print "OK" |
|
|
except ImportError: |
|
|
print "No" |
|
|
print """ |
|
|
the mx.DateTime Library is missing: |
|
|
you can get it from http://www.lemburg.com/files/python/mxDateTime.html |
|
|
""" |
|
|
sys.exit() |
|
|
|
|
|
|
|
|
|
|
|
# Site config stuff |
|
|
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 = "" |
|
|
|
|
|
|
|
|
|
|
|
class my_build_scripts(build_scripts): |
|
|
def finalize_options(self): |
|
|
|
|
|
build_scripts.finalize_options(self) |
|
|
|
|
|
if self.finalized: |
|
|
return |
|
|
|
|
|
|
|
|
if sys.platform != 'win32': |
|
|
dict = self.distribution.get_option_dict("install") |
|
|
install_prefix = dict['prefix'][1] |
|
|
|
|
|
gnue_env = \ |
|
|
"#######\n" \ |
|
|
+ "# The following variable were set when GNUe was installed\n" \ |
|
|
+ "import os, sys\n" \ |
|
|
+ "sys.path.append('%s')\n" % dict['install_lib'][1] \ |
|
|
+ "INST_GNUE_CONNECTIONS='%s/etc/connections.conf'\n" % dict['prefix'][1] \ |
|
|
+ "os.environ['INSTALL_LIB']='%s'\n" % dict['install_lib'][1] \ |
|
|
+ "os.environ['INSTALL_PREFIX']='%s'\n" % dict['prefix'][1] \ |
|
|
+ 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.environ['INSTALL_PREFIX']=_BASE\n" \ |
|
|
+ "os.environ['INSTALL_LIB']=_BASE\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" |
|
|
|
|
|
for script in self.scripts: |
|
|
print "Building %s..."% (script), |
|
|
|
|
|
|
|
|
fin = open(script+".in", "r") |
|
|
fout = open(script, "w") |
|
|
|
|
|
print "Generating script %s from %s.in" % (script,script) |
|
|
|
|
|
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() |
|
|
print "OK" |
|
|
|
|
|
docfiles = [] |
|
|
for file in ('doc/Developers-Guide.pdf','doc/Developers-Guide.txt', |
|
|
'doc/Developers-Guide.html', |
|
|
'doc/user_guide.txt','doc/user_guide.pdf'): |
|
|
if os.path.isfile(file): |
|
|
docfiles.append(file) |
|
|
else: |
|
|
print "WARNING: File %s does not exist... not installing!" % file |
|
|
|
|
|
|
|
|
dfiles = [ |
|
|
Data_Files( |
|
|
base_dir = 'install_data', |
|
|
copy_to = 'doc/forms', |
|
|
template = ['recursive-include doc *.pdf', |
|
|
'recursive-include doc *.html', |
|
|
'recursive-include doc *.txt', |
|
|
'prune doc/CVS'], |
|
|
strip_dirs = 1, # This is a number, not true/false |
|
|
preserve_path = 1), |
|
|
Data_Files( |
|
|
base_dir = 'install_data', |
|
|
copy_to = 'shared/images/forms', |
|
|
template = ['recursive-include images *.png', |
|
|
'recursive-include images *.bmp', |
|
|
'prune images/CVS'], |
|
|
strip_dirs = 1, # This is a number, not true/false |
|
|
preserve_path = 1), |
|
|
Data_Files( |
|
|
base_dir = 'install_data', |
|
|
copy_to = 'shared/dialogs', |
|
|
template = ['recursive-include dialogs *.gfd', |
|
|
], |
|
|
strip_dirs = 1, # This is a number, not true/false |
|
|
preserve_path = 1), |
|
|
Data_Files( |
|
|
base_dir = 'install_data', |
|
|
copy_to = 'man/man1', |
|
|
template = ['recursive-include man *'], |
|
|
strip_dirs = 1, # This is a number, not true/false |
|
|
preserve_path = 1) ] |
|
|
|
|
|
|
|
|
# |
|
|
# 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 |
|
|
# |
|
|
try: |
|
|
suffix = os.environ['GNUE_VERSION_SUFFIX'] |
|
|
except KeyError: |
|
|
suffix = "" |
|
|
|
|
|
distutils.core.setup (name = "GNUe-Forms", |
|
|
version = VERSION + suffix, |
|
|
description = "GNU Enterprise Forms", |
|
|
long_description = "", |
|
|
author = "GNUe Forms Team", |
|
|
author_email = "gnue-forms@gnue.org", |
|
|
url = "http://www.gnue.org", |
|
|
|
|
|
# Override certain command classes with our own ones |
|
|
|
|
|
data_files = dfiles, |
|
|
|
|
|
packages = ["gnue.forms", |
|
|
"gnue.forms.dialogs", |
|
|
"gnue.forms.dialogs.about", |
|
|
"gnue.forms.dialogs.jumpto", |
|
|
"gnue.forms.dialogs.messageBox", |
|
|
"gnue.forms.GFObjects", |
|
|
"gnue.forms.uidrivers", |
|
|
"gnue.forms.uidrivers._base", |
|
|
"gnue.forms.uidrivers._base.widgets", |
|
|
"gnue.forms.uidrivers._commonGuiToolkit", |
|
|
"gnue.forms.uidrivers.qt", |
|
|
"gnue.forms.uidrivers.qt.widgets", |
|
|
"gnue.forms.uidrivers.qt.widgets.form", |
|
|
"gnue.forms.uidrivers.win32", |
|
|
"gnue.forms.uidrivers.win32.widgets", |
|
|
"gnue.forms.uidrivers.win32.widgets.form", |
|
|
"gnue.forms.uidrivers.wx", |
|
|
"gnue.forms.uidrivers.wx.widgets", |
|
|
"gnue.forms.uidrivers.wx.widgets.form", |
|
|
"gnue.forms.uidrivers.curses", |
|
|
"gnue.forms.uidrivers.gtk2", |
|
|
"gnue.forms.uidrivers.gtk2.widgets", |
|
|
"gnue.forms.uidrivers.gtk2.widgets.form", |
|
|
], |
|
|
package_dir = {"gnue.forms" : "src"}, |
|
|
scripts = ["scripts/gnue-forms"], |
|
|
cmdclass = {'install_data':install_Data_Files, |
|
|
'build_scripts':my_build_scripts}, |
|
|
) |
|
|
|
|
|
if 'install' in sys.argv: |
|
|
print """ |
|
|
Note: |
|
|
Warnings about the files not being installed in pythons search path can be ignored. |
|
|
|
|
|
Make sure you have a default gnue.conf file (typically in /usr/local/gnue/etc. |
|
|
A sample is provided in that directory that you can typically just copy over. |
|
|
""" |
|
|
|
|
|
if not 'sdist' in sys.argv: |
|
|
if sys.platform != 'win32': |
|
|
os.system (""" /bin/rm -rf setup.cfg""") |
|
40 |
|
|
41 |
|
# --------------------------------------------------------------------------- |
42 |
|
# Definition of basic parameters for distribution and installation. |
43 |
|
# Please add new files/directories that should be installed here. |
44 |
|
# Note that you also have to add them to MANIFEST.in. |
45 |
|
# --------------------------------------------------------------------------- |
46 |
|
|
47 |
|
def set_params (self, params): |
48 |
|
|
49 |
|
# The Work |
50 |
|
params ["name"] = PACKAGE |
51 |
|
params ["version"] = VERSION |
52 |
|
params ["description"] = "GNU Enterprise Forms" |
53 |
|
params ["long_description"] = "" |
54 |
|
params ["license"] = "GPL" |
55 |
|
|
56 |
|
# 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.forms": "src"} |
63 |
|
params ["scripts"] = ["scripts/gnue-forms"] |
64 |
|
|
65 |
|
# The Data |
66 |
|
docfiles = self.allfiles ("doc") |
67 |
|
imagefiles = self.allfiles ("images") |
68 |
|
dialogfiles = self.allfiles ("dialogs") |
69 |
|
|
70 |
|
params ["data_files"] = \ |
71 |
|
[("share/gnue/dialogs", dialogfiles), |
72 |
|
("share/gnue/images/forms", imagefiles), |
73 |
|
("share/doc/gnue-forms", docfiles)] |
74 |
|
|
75 |
|
# --------------------------------------------------------------------------- |
76 |
|
# Build files to be distributed and installed: |
77 |
|
# Should generate the files that go in a distribution but aren't in CVS. |
78 |
|
# Gets called on sdist (always) and on build/install (only when run from CVS). |
79 |
|
# --------------------------------------------------------------------------- |
80 |
|
|
81 |
|
def build_files (self): |
82 |
|
# nothing to do here |
83 |
|
pass |
84 |
|
|
85 |
|
# --------------------------------------------------------------------------- |
86 |
|
# Check dependencies for installation: |
87 |
|
# Should sys.exit(1) in case any requirement isn't met. |
88 |
|
# Gets called on install. |
89 |
|
# --------------------------------------------------------------------------- |
90 |
|
|
91 |
|
def check_dependencies (self): |
92 |
|
|
93 |
|
# ------------------------------------------------------------------------- |
94 |
|
# mxDateTime |
95 |
|
try: |
96 |
|
print "checking mxDateTime library" |
97 |
|
from mx.DateTime import DateTime |
98 |
|
except ImportError: |
99 |
|
print "---" |
100 |
|
print "Could not import the mx.DateTime package." |
101 |
|
print "Please install mxDateTime from the mxtools suite." |
102 |
|
print "The file 'INSTALL' contains more information about dependencies." |
103 |
|
sys.exit (1) |
104 |
|
|
105 |
|
# ------------------------------------------------------------------------- |
106 |
|
# Verify at least one UI is installed |
107 |
|
UIOK = 0 |
108 |
|
|
109 |
|
# PyNcurses |
110 |
|
print "checking Python ncurses library (pyncurses) (currently not working)" |
111 |
|
try: |
112 |
|
import ncurses.form |
113 |
|
UIOK = 0 |
114 |
|
except ImportError: |
115 |
|
pass |
116 |
|
|
117 |
|
# Curses |
118 |
|
print "checking Python curses library (curses) (currently not working)" |
119 |
|
try: |
120 |
|
import curses |
121 |
|
UIOK = 0 |
122 |
|
except ImportError: |
123 |
|
pass |
124 |
|
|
125 |
|
# wxPython |
126 |
|
print "checking wxPython library" |
127 |
|
try: |
128 |
|
from wxPython.wx import * |
129 |
|
UIOK = 1 |
130 |
|
except ImportError: |
131 |
|
pass |
132 |
|
|
133 |
|
# FIXME: We have more UIDrivers! |
134 |
|
|
135 |
|
# We have no reliable way of verifying the above! FIXME |
136 |
|
UIOK = 1 |
137 |
|
|
138 |
|
if UIOK != 1: |
139 |
|
print "---" |
140 |
|
print """ |
141 |
|
No valid UI drivers are installed on this machine. |
142 |
|
Please install one of the following packages: |
143 |
|
wxPython - www.wxpython.org |
144 |
|
pyncurses - pyncurses.sourceforge.net |
145 |
|
python curses - Read python install docs on how to activate |
146 |
|
The file 'INSTALL' contains more information about dependencies. |
147 |
|
""" |
148 |
|
sys.exit (1) |
149 |
|
|
150 |
|
# ============================================================================= |
151 |
|
|
152 |
|
if __name__ == "__main__": |
153 |
|
setup().run() |