FHS, zopectl, #925, Re: [Zope-dev] 2.7 installation

Adrian van den Dries avdd@flow.com.au
Fri, 20 Jun 2003 15:38:53 +1000


--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On June 19, Chris McDonough wrote:
> On Thu, 2003-06-19 at 20:24, Adrian van den Dries wrote:
> > Why not avoid that altogether and let the user supply the
> > correct python?
> 
> This is somewhat of a style choice

OK, ZC's call. ;-)

> Well, as we all know, shell scripting kinda blows.  There is no way that
> I know of to portably use an array in shell, and I wanted to eventually
> make it possible to use something other than bash to run the configure
> script (bash has arrays, but I'm not sure if bourne shell does).

You may be interested in Kenneth Almquist's ash (aka dash in Debian):

Description: The Debian Almquist Shell
 "dash" is a POSIX compliant shell that is much smaller than "bash".
 We take advantage of that by making it the shell on the installation
 root floppy, where space is at a premium.
 .
 It can be usefully installed as /bin/sh (because it executes scripts
 somewhat faster than "bash"), or as the default shell either of root
 or of a second user with a userid of 0 (because it depends on fewer
 libraries, and is therefore less likely to be affected by an upgrade
 problem or a disk failure).  It is also useful for checking that a
 script uses only POSIX syntax.

> You're suggesting that "--prefix" be changed to "--home".
...
> You're suggesting that specifying a "--home" implies that libraries will
> be installed to $home/lib/python.
> 
> This is where I get a little confused.  How does a user signify that
> Zope libraries should get installed into the Python site-package
> directory?  What happens if "--home" is left unspecified?  Is the 
> "--prefix" option still around?  If so, what does it do?  Can you give
> an example of a configure command that would imply that Zope libraries
> get installed to site-packages?

Erm, yes.  I originally wanted --home and --prefix aliased, but I've
changed my mind.  It should mirror the behaviour of the same options
to the distutils' install target.

With the distutils, ``--home`` is version-agnostic (installs package
``foo`` into ``$HOME/lib/python/foo/``) and ``--prefix`` is
version-aware (installs into ``$PREFIX/lib/pythonX.Y/site-packages``).

``inst/Makefile.in`` could probably be updated to do a --prefix install
if $(PREFIX) is defined, else it defaults to a --home install.

(Mockups)

  # the next commands are all equivalent
  # and produce the install target
  # ``python setup.py --home=/usr/local/zope``

  python inst/configure.py --home=/usr/local/zope
  ./configure --home=/usr/local/zope
  ./configure

  # the next command produces the install target
  # ``python setup.py --prefix=/usr/local``
  # which installs packages to /usr/local/lib/python2.2/site-packages

  python inst/configure.py --prefix=/usr/local
  
> I think it is possible to tweak many things now via make -e after
> examination of the makefile.

OK, that is what the Deb should do.

> Well, if you ignore the shell scripts, I think we're ok, then!

Peaches!

...

(Couple of hours later).

OK, attached is a patch to inst/Makefile.in and inst/configure.py that
distinguishes --home and --prefix parameters and passes them onto the
distutils.  But for some reason, there is still no difference between
--prefix and --home, even though it's passing those options to the
distutils.  I suspect it might have something to do with this exerpt
from setup.py::

  # 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.

  ZOPE_INSTALL_SCHEME = {
    'purelib': '$base/lib/python',
    'platlib': '$base/lib/python',
    'headers': '$base/lib/python',
    'scripts': '$base/bin',
    'data'   : '$base/lib/python',
  }

That looks a little evil to me.

a.

-- 
 Adrian van den Dries                           avdd@flow.com.au
 Development team                               www.dev.flow.com.au
 FLOW Communications Pty. Ltd.                  www.flow.com.au

--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="configure-prefix-home.diff"

Index: doc/INSTALL.txt
===================================================================
RCS file: /var/lib/cvs/flowcom/Zope/dist/doc/INSTALL.txt,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 INSTALL.txt
--- doc/INSTALL.txt	18 Jun 2003 02:27:46 -0000	1.1.1.1
+++ doc/INSTALL.txt	20 Jun 2003 05:03:29 -0000
@@ -13,7 +13,7 @@
 
 Recommendations
 
-  - You are recommended to build and install Zope as a non-root user.
+  - We recommend you build and install Zope as a non-root user.
 
 Building Zope
 
@@ -23,8 +23,25 @@
     ./configure --prefix=/where/to/install/zope
     make
 
-  If you do not specify a '--prefix' option, during a later step, Zope
-  will be installed into a default location.
+  or
+
+    ./configure --home=/where/to/install/zope
+    make
+
+  If you do not specify the '--home' or '--prefix' options, during a
+  later step, Zope will be installed into a default location.
+
+  --prefix differs from --home by installing Python packages into
+  $PREFIX/lib/pythonX.Y/site-packages, where --home installs the
+  packages into $HOME/lib/python.  These options map directly to
+  the respective options for the distutils install target.
+
+  - '--prefix' is more suited for distributions and more highly
+  controlled environments.
+
+  - '--home' will suit most environments that use multiple versions of
+    Python or Zope, or require a higher level of isolation from system
+    software.
 
   If the configure script cannot find a suitable Python interpreter
   for use with Zope, it will complain with an informative error
Index: inst/Makefile.in
===================================================================
RCS file: /var/lib/cvs/flowcom/Zope/dist/inst/Makefile.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile.in
--- inst/Makefile.in	18 Jun 2003 02:27:46 -0000	1.1.1.1
+++ inst/Makefile.in	20 Jun 2003 05:25:33 -0000
@@ -35,26 +35,33 @@
 .PHONY : clean install uninstall instance untestinst testinst build unbuild
 .PHONY : default
 
+BUILD_STAMP=${BASE_DIR}/.build-stamp
+
 # default:     The default step (invoked when make is called without a target)
 default: build
-	@echo
-	@echo Zope built.  Next, do \'make install\' \(or \'make instance\'
-	@echo to run a Zope instance directly from the build directory\).
-	@echo
 
 # build:       Do whatever 'setup.py build' implies
-build:
+build: ${BUILD_STAMP}
+
+${BUILD_STAMP}:
 	${PYTHON} "${BASE_DIR}/setup.py" \
            ${DISTUTILS_OPTS} build ${BUILD_FLAGS}
+	touch ${BUILD_STAMP}
+	@echo
+	@echo Zope built.  Next, do \'make install\' \(or \'make instance\'
+	@echo to run a Zope instance directly from the build directory\).
+	@echo
 
 # unbuild:     Remove the build directory (undo the make build step)
 unbuild:
 	${RMRF} ${BUILD_BASE}
+	${RM} ${BUILD_STAMP}
 
 # install:     Install a software home.
-install: build
+install: ${BUILD_STAMP}
 	${PYTHON} "${BASE_DIR}/setup.py" ${DISTUTILS_OPTS} install \
-	   --home="${PREFIX}" ${BUILD_FLAGS} ${INSTALL_FLAGS}
+	   <<PREFIX_ARG>>="${PREFIX}" ${BUILD_FLAGS} ${INSTALL_FLAGS}
+	touch ${INSTALL_STAMP}
 	@echo
 	@echo Zope binaries installed successfully.
 	@echo Now run \'${PREFIX}/bin/mkzopeinstance\'
Index: inst/configure.py
===================================================================
RCS file: /var/lib/cvs/flowcom/Zope/dist/inst/configure.py,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 configure.py
--- inst/configure.py	18 Jun 2003 02:27:47 -0000	1.1.1.1
+++ inst/configure.py	20 Jun 2003 04:41:22 -0000
@@ -20,28 +20,31 @@
 
 QUIET=0
 
+PREFIX="/opt"
+MAKEFILE_MOD=""
+MAKE_COMMAND="make"
+
 if sys.platform == 'win32':
-    PREFIX = 'c:\\Zope-' + versions.ZOPE_MAJOR_VERSION
-    IN_MAKEFILE = 'Makefile.win.in'
+    PREFIX="C:"
+    MAKEFILE_MOD=".win"
     MAKE_COMMAND='the Visual C++ batch file "VCVARS32.bat" and then "nmake build"'
-else:
-    PREFIX = '/opt/Zope-' + versions.ZOPE_MAJOR_VERSION
-    IN_MAKEFILE = 'Makefile.in'
-    MAKE_COMMAND='make'
+
+PREFIX = os.path.join(PREFIX, 'Zope-%s' % versions.ZOPE_MAJOR_VERSION)
 
 def main():
     # below assumes this script is in the BASE_DIR/inst directory
     global PREFIX
+    PREFIX_ARG="--home"
     BASE_DIR=os.path.abspath(os.path.dirname(os.path.dirname(sys.argv[0])))
     BUILD_BASE=os.path.join(os.getcwd(), 'build-base')
     PYTHON=sys.executable
-    MAKEFILE=open(os.path.join(BASE_DIR, 'inst', IN_MAKEFILE)).read()
+    MAKEFILE=open(os.path.join(BASE_DIR, 'inst', "Makefile%s.in" % MAKEFILE_MOD)).read()
     REQUIRE_LF_ENABLED = 1
     REQUIRE_ZLIB=1
     INSTALL_FLAGS = ''
     DISTUTILS_OPTS = ''
     try:
-        longopts = ["help", "ignore-largefile", "ignore-zlib", "prefix=",
+        longopts = ["help", "ignore-largefile", "ignore-zlib", "prefix=", "home=",
                     "build-base=", "optimize", "quiet"]
         opts, args = getopt.getopt(sys.argv[1:], "h", longopts)
     except getopt.GetoptError, v:
@@ -52,7 +55,10 @@
         if o in ('-h', '--help'):
             usage()
             sys.exit()
-        if o == '--prefix':
+        if o in ('--home', '--prefix'):
+            if not a: sys.exit(usage())
+            if o=='--prefix':
+                PREFIX_ARG='--prefix'
             PREFIX=os.path.abspath(os.path.expanduser(a))
         if o == "--ignore-largefile":
             REQUIRE_LF_ENABLED=0
@@ -76,6 +82,7 @@
     idata = {
         '<<PYTHON>>':PYTHON,
         '<<PREFIX>>':PREFIX,
+        '<<PREFIX_ARG>>':PREFIX_ARG,
         '<<BASE_DIR>>':BASE_DIR,
         '<<BUILD_BASE>>':BUILD_BASE,
         '<<INSTALL_FLAGS>>':INSTALL_FLAGS,
@@ -94,7 +101,7 @@
     out("")
 
 def usage():
-    usage = ("""
+    usage = """
 %(program)s configures and writes a Makefile for Zope.
 
 Defaults for options are specified in brackets.
@@ -119,14 +126,21 @@
 Directories:
 
   --build-base=DIR              use DIR to store temporary build files
-
-  --prefix=DIR                  install Zope files in DIR [%(TARGET_DIR)s]
+                              
+  --home=DIR                    install Zope software in DIR [%(PREFIX)s]
+                                Python packages go in DIR/lib/python
+                                
+  --prefix=DIR                  install Zope files in DIR [%(PREFIX)s]
+                                Python packages go in
+                                DIR/lib/pythonX.Y/site-packages
 
 By default, 'make install' will install Zope software files in
-'%(target_dir)s'  You can specify an alternate location for these
-files by using '--prefix', for example: '--prefix=$HOME/zope'.
-""" % ({'program':sys.argv[0], 'TARGET_DIR':TARGET_DIR})
-             )
+'%(PREFIX)s'  You can specify an alternate location for these
+files by using '--home' or '--prefix', for example:
+'--home=$HOME/zope'.
+
+""" % ({'program': sys.argv[0],
+        'PREFIX': PREFIX})
     print usage
 
 def test_zlib():

--bg08WKrSYDhXBjb5--