From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7596 invoked by alias); 21 May 2010 17:57:35 -0000 Received: (qmail 7588 invoked by uid 22791); 21 May 2010 17:57:34 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 May 2010 17:57:30 +0000 Received: from kpbe17.cbf.corp.google.com (kpbe17.cbf.corp.google.com [172.25.105.81]) by smtp-out.google.com with ESMTP id o4LHvRgl019540 for ; Fri, 21 May 2010 10:57:28 -0700 Received: from pwj1 (pwj1.prod.google.com [10.241.219.65]) by kpbe17.cbf.corp.google.com with ESMTP id o4LHvQos030379 for ; Fri, 21 May 2010 10:57:26 -0700 Received: by pwj1 with SMTP id 1so549603pwj.22 for ; Fri, 21 May 2010 10:57:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.58.2 with SMTP id g2mr1429521rva.172.1274464646123; Fri, 21 May 2010 10:57:26 -0700 (PDT) Received: by 10.140.255.14 with HTTP; Fri, 21 May 2010 10:57:26 -0700 (PDT) In-Reply-To: References: <1274380803-25266-1-git-send-email-brobecker@adacore.com> <1274380803-25266-3-git-send-email-brobecker@adacore.com> Date: Fri, 21 May 2010 19:39:00 -0000 Message-ID: Subject: Re: [PATCH 2/2] Add gdb_libdir/python- in front of Python search path. From: Doug Evans To: tromey@redhat.com Cc: Joel Brobecker , gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-05/txt/msg00505.txt.bz2 On Fri, May 21, 2010 at 9:08 AM, Tom Tromey wrote: >>>>>> "Doug" =3D=3D Doug Evans writes: > > Doug> I think(!) this is a better approach. =A0Could be wrong of course. = :-) > Doug> I think adding one directory to sys.path is insufficient, and from > Doug> what I've read it seems like Py_SetProgramName is the preferred > Doug> solution to this problem. > > I read through this thread. =A0I also prefer this approach, mostly because > it doesn't change sys.path for the distro case. > > Doug> This patch doesn't currently handle your case, where the relationsh= ip > Doug> between the location of python and gdb at build time is different t= han > Doug> at runtime. =A0I think the solution to that is another config param= eter > Doug> to specify where to find python at run time. =A0Currently, when giv= en a > Doug> path, --with-python specifies where to find python at build time, a= nd, > Doug> for now, also at runtime. > > According to the docs you can also override some Py_ functions to allow > more complete control: > > The embedding application can steer the search by calling > `Py_SetProgramName(FILE)' =A0_before_ calling `Py_Initialize()'. =A0Note > that `PYTHONHOME' still overrides this and `PYTHONPATH' is still > inserted in front of the standard path. =A0An application that requires > total control has to provide its own implementation of `Py_GetPath()' , > `Py_GetPrefix()' , `Py_GetExecPrefix()' , and `Py_GetProgramFullPath()' = =A0(all > defined in `Modules/getpath.c'). I tweaked my patch a bit to only #define WITH_PYTHON_PATH if $build =3D $ho= st. I'll let it soak another day and then check in. [another config parameter to handle where-to-find-build-python vs where-to-find-runtime-python may yet be a reasonable thing to have, but I'll leave that for later. --with-build-python might be a better choice though]