Subject: [UFC-dev] DESTDIR support for UFC

From: "Johannes Ring" <[email-masked]>
Date: Thu, 19 Feb 2009 12:00:30 +0100 (CET)

Hi,

I have added DESTDIR support [1] to the new SCons based build system. This
allows for installation into a temporary directory before the files are
copied into the intended location at a later stage. This is mainly useful
for package maintainers.

Please apply the attached patch.

Johannes

[1] http://www.gnu.org/prep/standards/html_node/DESTDIR.html
# HG changeset patch
# User Johannes Ring <[email-masked]>
# Date 1235041129 -3600
# Node ID 6eb47c8488701ad4578b9869972b277233e88d0f
# Parent  de6e253d6c9704ee706251fc7a76336388677923
Added DESTDIR support to build system.

diff -r de6e253d6c97 -r 6eb47c848870 SConstruct
--- a/SConstruct	Mon Feb 16 22:53:11 2009 +0100
+++ b/SConstruct	Thu Feb 19 11:58:49 2009 +0100
@@ -41,7 +41,10 @@
     PathOption("pkgConfDir", "Directory for installation of pkg-config files",
                join("$prefix","lib","pkgconfig"), PathOption.PathAccept),
     BoolOption("cleanOldUFC", "Clean any old installed UFC modules", "No"),
-    BoolOption("cacheOptions", "Cache command-line options for later invocations", "Yes")]
+    BoolOption("cacheOptions", "Cache command-line options for later invocations", "Yes"),
+    PathOption("DESTDIR", "Prepend DESTDIR to each installed target file",
+               None, PathOption.PathAccept),
+    ]
 
 # Set the options using any cached options
 cache_file = "options.cache"
@@ -49,11 +52,16 @@
 opts.AddOptions(*options)
 opts.Update(env)
 cache_options = env.get("cacheOptions", False)
+DESTDIR = env.get("DESTDIR")
 if cache_options:
     del env["cacheOptions"] # Don't store this value
+    if DESTDIR:
+        del env["DESTDIR"]
     opts.Save(cache_file, env)
     # Restore cacheOptions
     env["cacheOptions"] = cache_options
+    if DESTDIR:
+        env["DESTDIR"] = DESTDIR
 
 env.Help(opts.GenerateHelpText(env))
 
@@ -97,6 +105,12 @@
 file.write("Cflags: -I%s\n" % \
            repr(normpath(env.subst(env["includeDir"])))[1:-1])
 file.close()
+
+if env.get("DESTDIR"):
+    install_prefix = os.path.join("$DESTDIR", "$prefix")
+    tgts_dir = ["includeDir", "pythonModuleDir", "pythonExtDir", "pkgConfDir"]
+    for tgt_dir in tgts_dir:
+        env[tgt_dir] = env[tgt_dir].replace("$prefix", install_prefix)
 
 # Set up installation targets
 ufc_basename = join("src", "ufc", "ufc")

---

From: Harish Narayanan <[email-masked]>
Date: Thu, 19 Feb 2009 13:34:56 +0100

> Please apply the attached patch.

Along a similar note, could someone add the following lines (or
something like them) to SConstruct to smoothen the installation process
on Mac OS X?

The python lib directory discovery mechanism seems to work on the
buildbot but has failed on two other Mac machines (including mine).

--- a/SConstruct	Mon Feb 16 22:53:11 2009 +0100
+++ b/SConstruct	Thu Feb 19 13:32:44 2009 +0100
@@ -24,6 +24,8 @@

 if env["PLATFORM"].startswith("win"):
     default_python_dir = os.path.join("$prefix", "Lib", "site-packages")
+elif env["PLATFORM"] == "darwin":
+    default_python_dir = os.path.join("$prefix", "lib", "python2.5",
"site-packages")
 else:
     default_python_dir =
sysconfig.get_python_lib(prefix="$prefix",plat_specific=True)

Harish

---

From: Johan Hake <[email-masked]>
Date: Thu, 19 Feb 2009 14:21:51 +0100

On Thursday 19 February 2009 13:34:56 Harish Narayanan wrote:
> Johannes Ring wrote:
> > Hi,
> >
> > I have added DESTDIR support [1] to the new SCons based build system.
> > This allows for installation into a temporary directory before the files
> > are copied into the intended location at a later stage. This is mainly
> > useful for package maintainers.
> >

I have check it in now. Can you try it? I did not hard code the version number 
as you suggested.

Johan

---

From: "Garth N. Wells" <[email-masked]>
Date: Thu, 19 Feb 2009 14:33:31 +0000

It would be good to make a release before changing too much. There's no 
problem in making a subsequent release shortly after.

Garth

Johan Hake wrote:
> _______________________________________________
> UFC-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufc-dev

---

From: Harish Narayanan <[email-masked]>
Date: Thu, 19 Feb 2009 17:05:09 +0100

> I have check it in now. Can you try it? I did not hard code the version number 

I tried this and it works for both cases (setting a prefix and selecting
a suitable default if not.)

Thanks!
Harish

---

From: Johan Hake <[email-masked]>
Date: Thu, 19 Feb 2009 20:09:27 +0100

> problem in making a subsequent release shortly after.

Yes ofcourse, but this was a bug for macs that the buildbot did not catch.

Johannes/Ilmar would it be possible to clean the installation targets before 
calling scons install?

Johan

> >>> This allows for installation into a temporary directory before the
> >>> files are copied into the intended location at a later stage. This is
> >>> mainly useful for package maintainers.
> >>>
> >>      default_python_dir = os.path.join("$prefix", "Lib",
> >> "site-packages") +elif env["PLATFORM"] == "darwin":
> > I have check it in now. Can you try it? I did not hard code the version
> > number as you suggested.
> >
> > Johan

---

From: Anders Logg <[email-masked]>
Date: Thu, 19 Feb 2009 21:25:23 +0100

Are we ready for a release of UFC 1.1.1?

-- 
Anders

---

From: Johan Hake <[email-masked]>
Date: Thu, 19 Feb 2009 21:35:59 +0100

> Are we ready for a release of UFC 1.1.1?

Oh, yes!

Instant have to follow.

Johan

---

From: Anders Logg <[email-masked]>
Date: Thu, 19 Feb 2009 21:46:31 +0100

> > Are we ready for a release of UFC 1.1.1?

ok, I'll make the release tomorrow morning.

-- 
Anders

---

From: Anders Logg <[email-masked]>
Date: Fri, 20 Feb 2009 10:24:16 +0100

> ok, I'll make the release tomorrow morning.

UFC 1.1.1 has been released. Now we're just waiting for Instant.

-- 
Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 20 Feb 2009 09:32:53 +0000

> UFC 1.1.1 has been released. Now we're just waiting for Instant.

Nice. I have a few more suggestions for UFC 1.2.

We have now

     function ufc::finite_element::evaluate_basis
     function ufc::finite_element::evaluate_basis_derivatives
     . . .
     etc

which take the real coordinates as arguments. It would be useful to pass 
a 'bool reference'  which indicates whether the coordinates are the real 
coordinates or the reference domain coordinates .

Garth

> 
> 
> ------------------------------------------------------------------------
>

---

From: Anders Logg <[email-masked]>
Date: Fri, 20 Feb 2009 10:40:31 +0100

> coordinates or the reference domain coordinates .

I think it would be better to either overload evaluate_basis with a
version that does not take a cell argument or introduce new function
names instead of a boolean flag.

-- 
Anders

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Fri, 20 Feb 2009 10:53:45 +0100

> names instead of a boolean flag.

I vote for the overloaded version without cell argument.

Martin

---

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 20 Feb 2009 09:54:02 +0000

> names instead of a boolean flag.

That was my first thought, so that would be fine with me too.

Garth

---

From: "Johannes Ring" <[email-masked]>
Date: Mon, 23 Feb 2009 09:01:49 +0100 (CET)

> Yes ofcourse, but this was a bug for macs that the buildbot did not catch.

The buildbot did not catch this error because we could not reproduce it on
our setup. We discussed this with Harish but couldn't figure out why it
worked on the buildbot and not on his setup.

> Johannes/Ilmar would it be possible to clean the installation targets

Yes, the new buildbot runs 'scons --clean install' to uninstall before
running 'scons install'.

Johannes

---

From: Johan Hake <[email-masked]>
Date: Mon, 23 Feb 2009 09:33:26 +0100

> worked on the buildbot and not on his setup.

Was this the old buildbots or the "new" one where you clean the install 
targets too?

The bug appeard while installing and the old buildbot never installed.

Johan

---

From: Harish Narayanan <[email-masked]>
Date: Mon, 23 Feb 2009 09:36:42 +0100

> The bug appeard while installing and the old buildbot never installed.

I'm not so sure it would have manifested even if the buildbot installed.
I talked to Johannes about this and the python installation on the
buildbot (also from fink, strangely) seemed to pick out the python lib
directory correctly.

(In other words, I don't really know what's going on, so figured it
couldn't hurt to hard code it.)

Harish

---

From: "Johannes Ring" <[email-masked]>
Date: Mon, 23 Feb 2009 09:41:23 +0100 (CET)

> buildbot (also from fink, strangely) seemed to pick out the python lib

Yes, that is correct.

Johannes

---

From: Johan Hake <[email-masked]>
Date: Mon, 23 Feb 2009 09:53:32 +0100

On Monday 23 February 2009 09:36:42 Harish Narayanan wrote:
> >>>> It would be good to make a release before changing too much. There's
> >>>> no problem in making a subsequent release shortly after.
> >>>
> >> The buildbot did not catch this error because we could not reproduce it
> >> on our setup. We discussed this with Harish but couldn't figure out why
> >> it worked on the buildbot and not on his setup.
> >

Ok. 

I notice that the way you "hardcode" the default python directory is the same 
way we do it in simula-scons, and it is probably therefore you do not get any 
problems with installing PyDOLFIN.

Not sure if we should put a notice about this in the SConstruct file of UFC?

Johan

---

From: Harish Narayanan <[email-masked]>
Date: Mon, 23 Feb 2009 10:04:32 +0100

> Not sure if we should put a notice about this in the SConstruct file of UFC?

I don't think it is necessary.

Harish

---

From: "Johannes Ring" <[email-masked]>
Date: Mon, 23 Feb 2009 10:04:57 +0100 (CET)

> Not sure if we should put a notice about this in the SConstruct file of

I think it is okay like it is. If someone doesn't like the default
installation directory they can simply specify another directory with
pythonModuleDir and pythonExtDir.

Johannes