[Zope-Checkins] CVS: Zope/inst - setup.py:1.1.2.6

Chris McDonough chrism@zope.com
Fri, 11 Oct 2002 12:11:03 -0400


Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv26129

Modified Files:
      Tag: chrism-install-branch
	setup.py 
Log Message:
Testing a custom installation scheme which prevents distutils from trying to guess where to put our files.


=== Zope/inst/setup.py 1.1.2.5 => 1.1.2.6 ===
--- Zope/inst/setup.py:1.1.2.5	Wed Oct  9 16:22:30 2002
+++ Zope/inst/setup.py	Fri Oct 11 12:11:02 2002
@@ -116,39 +116,40 @@
                             (out, _) = self.copy_file(g, dir)
                             self.outfiles.append(out)
 
-class install(install):
-    def finalize_unix (self):
-        if self.install_base is not None or self.install_platbase is not None:
-            if ((self.install_lib is None and
-                 self.install_purelib is None and
-                 self.install_platlib is None) or
-                self.install_headers is None or
-                self.install_scripts is None or
-                self.install_data is None):
-                raise DistutilsOptionError, \
-                      "install-base or install-platbase supplied, but " + \
-                      "installation scheme is incomplete"
-            return
+# We create a custom "install scheme" that works the same way on all
+# platforms.  We do this in order to prevent distutils from trying to
+# guess where to put our files on a per-platform basis.
 
-        if self.home is not None:
-            self.install_base = self.install_platbase = self.home
-            self.select_scheme("unix_home")
-        else:
-            if self.prefix is None:
-                if self.exec_prefix is not None:
-                    raise DistutilsOptionError, \
-                          "must not supply exec-prefix without prefix"
-                raise DistutilsOptionError, "must supply installation path"
-            else:
-                if self.exec_prefix is None:
-                    self.exec_prefix = self.prefix
+ZOPE_INSTALL_SCHEME = {
+    'purelib': '$base/lib/python',
+    'platlib': '$base/lib/python',
+    'headers': '$base/lib/python',
+    'scripts': '$base/lib/python',
+    'data'   : '$base/lib/python',
+    }
 
-            self.install_base = self.prefix
-            self.install_platbase = self.exec_prefix
-            self.select_scheme("unix_prefix")
+class install(install):
+    def select_scheme(self, name):
+        """
+        Override the default platform installation schemes, ignoring whatever
+        'name' is passed in.  For our purposes, we want to put all library,
+        header, data, and scripts into [install_base]/lib/python.  Comment
+        this method out to achieve distutils-standard platform-specific
+        behavior for 'setup.py install'.  This is most useful if you set the
+        [install-base] by using the '--prefix' or '--home' flags on the
+        setup.py install command line.  Otherwise, all Zope software
+        will probably be installed to your Python's 'lib/python' directory.
+        """
+        scheme = ZOPE_INSTALL_SCHEME
+        for key in distutils.command.install.SCHEME_KEYS:
+            attrname = 'install_' + key
+            if getattr(self, attrname) is None:
+                setattr(self, attrname, scheme[key])
 
-AUTHOR = 'Zope Corporation and Contributors'
+# presumes we're currently cd'ed to the build root directory
 ZOPE_ROOT = os.path.abspath(os.getcwd())
+
+AUTHOR = 'Zope Corporation and Contributors'
 EXTENSIONCLASS_ROOT = os.path.join(ZOPE_ROOT, 'lib', 'Components', 'ExtensionClass')
 EXTENSIONCLASS_SRCDIR = os.path.join(EXTENSIONCLASS_ROOT, 'src')
 PACKAGES_ROOT = os.path.join(ZOPE_ROOT, 'lib', 'python')