From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Modified load-path proposal Date: Thu, 13 Oct 2005 19:21:13 +0100 Message-ID: <878xwx5ld2.fsf@ossau.uklinux.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1129228012 17112 80.91.229.2 (13 Oct 2005 18:26:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 13 Oct 2005 18:26:52 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Oct 13 20:26:51 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EQ7hh-00064s-5T for guile-user@m.gmane.org; Thu, 13 Oct 2005 20:21:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EQ7hg-00052L-GO for guile-user@m.gmane.org; Thu, 13 Oct 2005 14:21:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EQ7hc-00052G-KT for guile-user@gnu.org; Thu, 13 Oct 2005 14:21:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EQ7hc-000524-3b for guile-user@gnu.org; Thu, 13 Oct 2005 14:21:16 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EQ7hc-000521-09 for guile-user@gnu.org; Thu, 13 Oct 2005 14:21:16 -0400 Original-Received: from [80.84.72.33] (helo=mail3.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EQ7hb-0001FX-QU for guile-user@gnu.org; Thu, 13 Oct 2005 14:21:16 -0400 Original-Received: from laruns (host81-130-31-36.in-addr.btopenworld.com [81.130.31.36]) by mail3.uklinux.net (Postfix) with ESMTP id 00D0240A011 for ; Thu, 13 Oct 2005 18:21:15 +0000 (UTC) Original-Received: from laruns (laruns [127.0.0.1]) by laruns (Postfix) with ESMTP id 8540F6F71B for ; Thu, 13 Oct 2005 19:21:14 +0100 (BST) Original-To: Guile Users User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:4840 Archived-At: --=-=-= I think this meets everyone's desires ... please let me know what you think! Neil --=-=-= Content-Disposition: inline; filename=load-path.txt -*- scheme -*- ;; 1. Format and example contents of ;; $sysconfdir/guile/$EFFECTIVE_VERSION/config.scm ;; ;; The format is a single alist expression which Guile reads. ;; (config.scm is not a file which Guile loads, and which could ;; therefore contain arbitrary code, because (i) it is used before ;; boot-9.scm is loaded, which means that bits of Scheme are not ;; available yet, and (ii) the specification of a standard format ;; allows us to use automated tools for updating the contents of the ;; file.) ;; ;; Each element of the alist is (INFO-TYPE . INFO), where the only ;; currently supported INFO-TYPE is load-path. The alist format ;; allows us to extend the use of the config.scm in future, but in a ;; way that should not require existing code and tools (if well ;; written) to be updated. ;; ;; When INFO-TYPE is load-path, the form of INFO is (DEFAULT-TAG (TAG ;; DIRECTORY DESCRIPTION) ...), where: ;; ;; - DEFAULT-TAG is the tag of the default install location for Guile ;; packages. In other words, it identifies the location that ;; GUILE_SCHEME_DIR will return if a package's ./configure is run ;; without a --with-guile-scheme-dir option. ;; ;; - TAG is an arbitrary symbol which can be used to uniquely identify ;; each load path directory. ;; ;; - DIRECTORY is a load path directory (as a string). ;; ;; - DESCRIPTION is a string describing the use of that load path ;; directory. ((load-path local (guile-1.6 "/usr/share/guile/1.6" "Install location for Guile 1.6's own Scheme files") (site "/usr/share/guile/site" "Install location for site-specific Scheme files") (gnome "/opt/gnome/guile" "Install location for GNOME-related Scheme files") (local "/usr/local/share/guile" "Version-independent non-distribution-managed Scheme files") (local-1.6 "/usr/local/share/guile/1.6" "1.6-dependent non-distribution-managed Scheme files"))) ;; 2. Guile's startup logic ;; ;; Normal location of config.scm is hardcoded into Guile, based on the ;; setting of $sysconfdir at ./configure time. ;; ;; This location can be overridden at runtime by a --config=FILE ;; option (which we need to add). This will be needed by ;; pre-inst-guile (during a Guile build), for example. ;; ;; Guile will abort if config.scm is not found, or cannot be read, or ;; there are any errors in the format of the information in it. ;; ;; Otherwise, Guile sets %load-path to: ;; ;; (map cadr (cddr (assq 'load-path config))) ;; ;; (but in C code, not in Scheme). ;; ;; Thereafter %load-path is used as presently for the loading of ;; boot-9.scm, init.scm and so on. ;; 3. Code for guile-config add-load-path TAG DIRECTORY DESCRIPTION ;; ;; (To be integrated into guile-config, and will in practice need ;; error handling.) (define (add-load-path tag directory description) (let* ((config (with-input-from-file %sys-config-file read)) (load-path-info (assq 'load-path config))) (set-cdr! load-path-info (append! (cdr load-path-info) (list (list tag directory description)))) (with-output-to-file %sys-config-file (lambda () (pretty-print config))))) ;; 4. Code for guile-config get-load-path ARG ;; ;; Where ARG is the string that was given to --with-guile-scheme-dir, ;; or an empty string if --with-guile-scheme-dir was not used. ;; ;; (To be integrated into guile-config, and will in practice need ;; error handling.) (define (get-load-path arg) ;; If ARG begins with "/", use it directly. (if (and (>= (string-length arg) 1) (char=? (string-ref arg 0) #\/)) arg ;; Otherwise we need to read config. (let* ((config (with-input-from-file %sys-config-file read)) (load-path-info (assq 'load-path config)) (tag (if (zero? (string-length arg)) ;; Use the default tag. (cadr load-path-info) ;; ARG should be a tag. (string->symbol arg)))) ;; Return the directory for the chosen tag. (cadr (assq tag (cddr load-path-info)))))) ;; 5. Code for GUILE_SCHEME_DIR autoconf macro ;; ;; To be written, with these features/requirements: ;; ;; - Will check for a --with-guile-scheme-dir=ARG option. ;; ;; - Will use `guile-config get-load-path ARG` to get the appropriate ;; install directory. ;; ;; - Will NOT take a default-tag argument (in configure.in) as I ;; suggested before, because there is no way for the package author to ;; know what tags will be available on the distribution(s) where the ;; package is built. ;; ;; - Should fall back to other sensible mechanisms if `guile-config ;; get-load-path ARG` is not available. ;; ;; + Recent Guile distributions have the GUILE_SITE_DIR macro. In ;; my view this is better than nothing, but it feels wrong for Guile ;; package code to go under .../site. So my preference if using ;; GUILE_SITE_DIR would be to install to ${GUILE_SITE_DIR}/.. ;; ;; + One could run Guile to discover its %load-path, and decide ;; heuristically which of those directories to install under. ;; ;; + Note that there's no point in falling back to ;; $prefix/share/guile, because if the package author wanted that ;; they could have specified that directly instead of using ;; GUILE_SCHEME_DIR. --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user --=-=-=--