commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue-appserver setup.py


From: Reinhard Mueller
Subject: gnue-appserver setup.py
Date: Fri, 19 Sep 2003 10:23:21 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue-appserver
Branch:         
Changes by:     Reinhard Mueller <address@hidden>       03/09/19 10:23:21

Modified files:
        .              : setup.py 

Log message:
        Now this is the ultimate setup.py!

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/setup.py.diff?tr1=1.17&tr2=1.18&r1=text&r2=text

Patches:
Index: gnue-appserver/setup.py
diff -c gnue-appserver/setup.py:1.17 gnue-appserver/setup.py:1.18
*** gnue-appserver/setup.py:1.17        Fri Sep 19 07:12:51 2003
--- gnue-appserver/setup.py     Fri Sep 19 10:23:21 2003
***************
*** 21,27 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: setup.py,v 1.17 2003/09/19 11:12:51 reinhard Exp $
  
  import sys
  import string
--- 21,27 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: setup.py,v 1.18 2003/09/19 14:23:21 reinhard Exp $
  
  import sys
  import string
***************
*** 30,35 ****
--- 30,36 ----
  
  from distutils.core import setup
  from distutils.command.build_scripts import build_scripts
+ from distutils.command.install import install
  
  from src import PACKAGE, VERSION
  
***************
*** 45,64 ****
  # Find out whether or not to use our setup.cfg
  # 
-----------------------------------------------------------------------------
  
- prefix = None
  have_prefix = 0
- i = 0
  for arg in sys.argv:
!   if arg == "--prefix":
!     try:
!       prefix = sys.argv [i+1]
!       have_prefix = 1
!     except:
!       pass
!   if arg [:9] == "--prefix=":
!     prefix = arg [9:]
      have_prefix = 1
-   i = i + 1
  
  if "install" in sys.argv or "bdist_rpm" in sys.argv:
    if sys.platform != "win32" and not have_prefix:
--- 46,56 ----
  # Find out whether or not to use our setup.cfg
  # 
-----------------------------------------------------------------------------
  
  have_prefix = 0
  for arg in sys.argv:
!   if arg == "--prefix" or arg [:9] == "--prefix=" or \
!      arg == "--home"   or arg [:7] == "--home=":
      have_prefix = 1
  
  if "install" in sys.argv or "bdist_rpm" in sys.argv:
    if sys.platform != "win32" and not have_prefix:
***************
*** 135,190 ****
      sys.exit (1)
  
  # 
-----------------------------------------------------------------------------
! # build and install: Check dependencies
! # 
-----------------------------------------------------------------------------
! 
! 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
  # 
-----------------------------------------------------------------------------
  
  try:
--- 127,133 ----
      sys.exit (1)
  
  # 
-----------------------------------------------------------------------------
! # User can supply a path to the config file
  # 
-----------------------------------------------------------------------------
  
  try:
***************
*** 196,272 ****
  except ValueError:
    config_line = ""
  
! if have_prefix:
!   install_lib = os.path.join (prefix, "lib", "python%s" % sys.version [:3],
!                               "site-packages")
! else:
!   install_lib = None
! 
! class my_build_scripts(build_scripts):
!   def finalize_options(self):
!     global prefix
!     global install_lib
  
!     build_scripts.finalize_options(self)
  
!     if self.finalized:
!       return
  
!     if sys.platform != "win32":
!       if not have_prefix:
!         dict = self.distribution.get_option_dict ("install")
!         prefix = dict ["prefix"] [1]
!         install_lib = dict ["install_lib"] [1]
! 
!       if install_lib in sys.path:
!         path_line = ""
!       else:
!         sys.path.append (install_lib)
!         path_line = "import sys\nsys.path.append('%s')\n" % install_lib
  
        gnue_env = \
!            "#######\n" \
!          + "# The following variables were set when GNUe was installed\n" \
!          + "import os\n" \
!          + path_line \
!          + "INST_GNUE_CONNECTIONS='%s/etc/connections.conf'\n" % prefix \
!          + "os.environ['INSTALL_LIB']='%s'\n" % install_lib \
!          + "os.environ['INSTALL_PREFIX']='%s'\n" % prefix \
!          + config_line \
!          + "#######\n"
      else:
-       options.append('install_lib = r"%s"' % sys.prefix)
        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)):
--- 139,281 ----
  except ValueError:
    config_line = ""
  
! # 
=============================================================================
! # Before installation: check dependencies and create real scripts
! # 
=============================================================================
  
! class my_install (install):
  
!   # 
---------------------------------------------------------------------------
!   # Check dependencies
!   # 
---------------------------------------------------------------------------
  
!   def _check_dependencies (self):
! 
!     # 
-------------------------------------------------------------------------
!     # xml
!     try:
!       print "checking Python xml library"
!       import xml
!     except ImportError:
!       print "---"
!       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 "---"
+       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
+     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)
+     if os.path.dirname (gnue.__path__[0]) != os.path.dirname 
(self.install_lib):
+       print "---"
+       print "GNUe-Common is installed in %s." % \
+                                 os.path.dirname (gnue.__path__ [0])
+       print "You are trying to install GNUe-AppServer in %s." % \
+                                 os.path.dirname (self.install_lib)
+       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" \
!         + "os.environ['INSTALL_LIB']='%s'\n" % self.install_lib \
!         + "os.environ['INSTALL_PREFIX']='%s'\n" % self.prefix \
!         + 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"
!     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)):
***************
*** 274,282 ****
            lines[i] = gnue_env
  
        fout.writelines(lines)
        fin.close()
        fout.close()
!       print "OK"
  
  # 
-----------------------------------------------------------------------------
  # GNUE_VERSION_SUFFIX handling
--- 283,311 ----
            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
***************
*** 304,314 ****
  samplefiles = ["samples/sample.gfd", "samples/setup-pgsql.sh",
                 "samples/setup-mysql.sh"]
  
- if have_prefix:
-   classrepdir = os.path.join (install_lib, "gnue", "appserver", "classrep")
- else:
-   classrepdir = "lib/python/gnue/appserver/classrep"
- 
  setup (name = "GNUe-AppServer",
         version = VERSION + suffix,
         description = "GNU Enterprise Application Server",
--- 333,338 ----
***************
*** 316,324 ****
         author = "GNUe Application Server Team",
         author_email = "address@hidden",
         url = "http://www.gnue.org";,
  
         # Override certain command classes with our own ones
!        cmdclass = {"build_scripts": my_build_scripts},
  
         data_files = [ ("doc/appserver", docfiles),
                        ("man/man1", manfiles),
--- 340,349 ----
         author = "GNUe Application Server Team",
         author_email = "address@hidden",
         url = "http://www.gnue.org";,
+        licence = "GPL",
  
         # Override certain command classes with our own ones
!        cmdclass = {"install": my_install},
  
         data_files = [ ("doc/appserver", docfiles),
                        ("man/man1", manfiles),
***************
*** 330,336 ****
                        ("samples/appserver/pgsql", ["samples/pgsql/full.sql"]),
                        ("samples/appserver/sybase", 
["samples/sybase/full.sql"]),
                        ("shared/grpc", ["grpc/appserver.grpc"]),
!                       (classrepdir, ["src/classrep/repository.ini"])
                         ],
  
         packages = ["gnue.appserver",
--- 355,361 ----
                        ("samples/appserver/pgsql", ["samples/pgsql/full.sql"]),
                        ("samples/appserver/sybase", 
["samples/sybase/full.sql"]),
                        ("shared/grpc", ["grpc/appserver.grpc"]),
!                       ("share/gnue-appserver", 
["src/classrep/repository.ini"])
                         ],
  
         packages = ["gnue.appserver",
***************
*** 349,358 ****
  if "install" in sys.argv or "bdist_rpm" in sys.argv:
    if sys.platform != "win32":
      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."
--- 374,376 ----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]