Subject: Re: [UFC-dev] Bug in setup.py

From: Åsmund Ødegård <[email-masked]>
Date: Tue, 20 Mar 2007 20:34:08 +0100

I strongly advice against what you say below. Prefix should be respected, also by python. Only if prefix is not given the default path for the python that is used should be selected as install directory. In that case you can place ufc.h in the corresponding include directory, which is quite easy to look up. 

Everything else will be very nonstandard in my opinion.

Sorry for topposting:-) 

-----Opprinnelig melding-----
Fra: "Anders Logg" <[email-masked]>
Til: [email-masked]
Sendt: 20.03.07 16:55
Emne: Re: [UFC-dev] Bug in setup.py

On Tue, Mar 20, 2007 at 04:51:04PM +0100, Martin Sandve Alnæs wrote:
> 2007/3/20, Anders Logg <[email-masked]>:
> > On Mon, Mar 19, 2007 at 08:00:05PM +0100, Martin Sandve Alnæs wrote:
> > > setup.py installs in /usr instead of /usr/local, but ufc-1.pc still
> > > refers to /usr/local.
> > >
> > > This just cost me half an hour, looking in all other possible places first...
> > > Time to go home!
> > >
> > > martin
> >
> > Looks like you have an old version of ufc-1.pc or an old version of
> > ufc.h in /usr/include.
> 
> Nope.
> 
> > The current setup.py installs ufc.h under /usr/local/include and
> > write /usr/local/include to ufc-1.pc (unless specified otherwise with
> > --prefix).
> 
> Yes, but it installs the python parts to /usr/lib, not
> /usr/local/lib.

True.

> Since I already had ufc installed under /usr/local, this version was still used.
>
> And since I saw that ufc.h under /usr/local was updated, I missed for a while
> that the python parts went under /usr.
> 
> The default prefix of /usr/local hardcoded in the setup.py file isn't
> applied to the python module.

The setup.py file lets python decide where to install the Python parts
of the code (and it chooses /usr) and then we need to decide where to
put the ufc.h file. We chose to put it under /usr/local.

The best thing would be if we could ask distutils where it intends to
install things and then put the ufc.h file in the same place. But this
is problematic, since distutils does not know this until after the
setup() call and we need to specify the prefix for the ufc.h file in
the call to setup()...

/Anders
_______________________________________________
UFC-dev mailing list
[email-masked]
http://fenics.org/mailman/listinfo/ufc-dev

---

From: Anders Logg <[email-masked]>
Date: Tue, 20 Mar 2007 20:43:28 +0100

> Everything else will be very nonstandard in my opinion.

We do respect --prefix if it is given. The problem is when it is not
given. We then need to figure out what prefix to set (for the part not
set by distutils).

Any suggestions for how to figure this out are welcome. Now we just do

try:    prefix = [item for item in sys.argv[1:] \
                  if "--prefix=" in item][0].split ("=")[1]
except: prefix = "/usr/local"

/Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: Tue, 20 Mar 2007 21:17:39 +0100

Quoting Anders Logg <[email-masked]>:

> > I strongly advice against what you say below. Prefix should be respected,
> also by python. Only if prefix is not given the default path for the python
> that is used should be selected as install directory. In that case you can
> place ufc.h in the corresponding include directory, which is quite easy to
> look up. 
> > 

I don't see the problem. The Python code should be installed by default where
Python wants it, and ufc.h can be installed in /usr/local/include/. If one wants
a particular installation path, the user can supply the path, which is supported.

Garth

---

From: [email-masked]
Date: Tue, 20 Mar 2007 21:57:04 +0100 (CET)

> a particular installation path, the user can supply the path, which is

I think this basically sums it up. We put headers and libraries
in /usr/local by default (where autotools would put them), while python
modules are put where python choose to put it by default.

We can add a few comments about this in a README file.

The reason Martin and I have had trouble is probably that earlier I
guess ufc installed everything under /usr/local and we have /usr/local..
early in the PYTHONPATH such that old version were used.

Kent

---

From: Åsmund Ødegård <[email-masked]>
Date: Tue, 20 Mar 2007 23:42:41 +0100

On Mar 20, 2007, at 8:43 PM, Anders Logg wrote:

>> I strongly advice against what you say below. Prefix should be  
>> respected, also by python. Only if prefix is not given the default  
>> path for the python that is used should be selected as install  
>> directory. In that case you can place ufc.h in the corresponding  
>> include directory, which is quite easy to look up.
>>

aha - sorry for not catching that correctly.

You can use distutils.sysconfig.get_python_inc() to find the include- 
path
for python. Chopping off the last part should usually give you the  
regular
include. I.e get_python_inc() gives you /usr/include/python2.4, so  
you need
to remove the python2.4 part.

Maybe that can be used?

-- 
[simula.research laboratory]
                  Åsmund Ødegård
                  IT-Manager
                  phone: +4767828291 /+4790069915
                  http://www.simula.no/

---

From: Anders Logg <[email-masked]>
Date: Wed, 21 Mar 2007 11:23:49 +0100

> to remove the python2.4 part.

Good to know! But Kent has a good point that we install all other
headers (like DOLFIN) under /usr/local and all other Python modules
(like FFC, FIAT, etc) under /usr/lib/pythonx.y.

I'm not sure what is best.

/Anders

---

From: Åsmund Ødegård <[email-masked]>
Date: Wed, 21 Mar 2007 12:30:03 +0100

> I'm not sure what is best.
I think what Kent suggests is best - just use /usr/local as prefix  
for distutils
stuff if no explicit prefix is given - in this way both python stuff  
and headers will
go in /usr/local!

---

From: Anders Logg <[email-masked]>
Date: Wed, 21 Mar 2007 17:47:43 +0100

> stuff if no explicit prefix is given - in this way both python stuff  

We had a discussion about this (IRL) just now and came to the conclusion
that we'll let distutils install where it wants to install and use the
distutils.sysconfig.get_python_inc() trick to get the include path for
the ufc.h header.

Ola, will you implement this?

/Anders