Subject: [UFC-dev] [HG UFC] If needed SCons now create any installation directories

From: [email-masked] (UFC)
Date: Tue, 3 Feb 2009 11:51:00 +0100 (CET)

One or more new changesets pushed to the primary ufc repository.
A short summary of the last three changesets is included below.

changeset:   239:415b0fd0400cf838a1fa57b62b85f5c9164d0969
tag:         tip
user:        "Johan Hake <[email-masked]>"
date:        Tue Feb 03 11:47:22 2009 +0100
files:       SConstruct
description:
If needed SCons now create any installation directories
Added a platform specific python default path for windows

changeset:   238:fdece63f4e78ddc02cd7adea018eb98dea098aef
user:        "Johan Hake <[email-masked]>"
date:        Fri Jan 30 15:00:41 2009 +0100
files:       ChangeLog
description:
Updated Changelog

changeset:   237:d7de2313d2cd7fda8dba6de9aa2d4d06bf11286d
user:        "Johan Hake <[email-masked]>"
date:        Fri Jan 30 14:58:56 2009 +0100
files:       SConstruct src/ufc/ufc.i swig_config.py
description:
Added SCons build system for ufc
 - It comes with better build logics
 - type scons -h to get help on building and installing UFC.
 - keep the setup.py for now, should be deprecated

----------------------------------------------------------------------
For more details, visit http://www.fenics.org/hg/ufc

---

From: Johan Hake <[email-masked]>
Date: Tue, 3 Feb 2009 11:55:17 +0100

Hello!

SCons now install your UFC.

I will remove the setup.py as soon I do not here any complains about the build 
system.

Also...
The swig version that was used to compile the extension module is now added as

   ufc.__swigversion__

This will be used in PyDOLFIN and FFC to check that the extension modules are 
created with the same swig version.

These packages will soon be updated.

Johan

On Tuesday 03 February 2009 11:51:00 UFC wrote:
> _______________________________________________
> UFC-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufc-dev

---

From: Anders Logg <[email-masked]>
Date: Mon, 9 Feb 2009 11:20:44 +0100

Could you also update the README file, it still says to use setup.py.

-- 
Anders

---

From: Johan Hake <[email-masked]>
Date: Mon, 9 Feb 2009 12:00:43 +0100

> Could you also update the README file, it still says to use setup.py.

Of course, and I will remove the setup.py as soon as there's no problem with 
the new installation script. Me and Johannes are still working on some small 
issues.

Johan

---

From: Anders Logg <[email-masked]>
Date: Mon, 9 Feb 2009 12:01:29 +0100

> the new installation script. Me and Johannes are still working on some small 

ok, nice. It works here.

-- 
Anders

---

From: Johan Hake <[email-masked]>
Date: Mon, 9 Feb 2009 12:09:37 +0100

On Monday 09 February 2009 12:01:29 Anders Logg wrote:
> > Of course, and I will remove the setup.py as soon as there's no problem
> > with the new installation script. Me and Johannes are still working on
> > some small issues.
> >
> > Johan
>
> ok, nice. It works here.

That's good! 

We ave a problem when a user tries to

  scons prefix=/superuser/directory

and the /superuser/directory is non excisting. Then scons tries to create that 
direcory during the build call, instead of the more logical install call, 
i.e., 

  sudo scons install

This can possibly be bug in SCons. I am waiting for answer from the SCons 
mailing list. If it really is a bug Johannes have _another_ workaround for 
this.

Johan

---

From: "Johannes Ring" <[email-masked]>
Date: Mon, 9 Feb 2009 12:18:26 +0100 (CET)

> mailing list. If it really is a bug Johannes have _another_ workaround for

Yes, attached is a patch for this workaround (including some other fixes).

Johannes
diff -r e2e0c5e8d6a6 SConstruct
--- a/SConstruct	Tue Feb 03 13:54:51 2009 +0100
+++ b/SConstruct	Mon Feb 09 12:13:57 2009 +0100
@@ -16,7 +16,7 @@
 
 # Build the commandline options for SCons:
 if env["PLATFORM"].startswith("win"):
-    default_prefix = join("c:","local")
+    default_prefix = r"c:\local"
 elif env["PLATFORM"] == "darwin":
     default_prefix = join(sep,"sw")
 else:
@@ -29,17 +29,17 @@
 
 options = [
     # configurable options for installation:
-    PathOption("prefix", "Installation prefix", default_prefix, PathOption.PathIsDirCreate),
+    PathOption("prefix", "Installation prefix", default_prefix, PathOption.PathAccept),
     PathOption("includeDir", "ufc.h installation directory",
-               join("$prefix","include"), PathOption.PathIsDirCreate),
+               join("$prefix","include"), PathOption.PathAccept),
     PathOption("pythonModuleDir", "Python module installation directory", 
-               default_python_dir, PathOption.PathIsDirCreate),
+               default_python_dir, PathOption.PathAccept),
     BoolOption("enablePyUFC", "Compile and install the python extension module", "Yes"),
     PathOption("pythonExtDir", "Python extension module installation directory",
-               default_python_dir, PathOption.PathIsDirCreate),
+               default_python_dir, PathOption.PathAccept),
     PathOption("boostDir", "Specify path to Boost", None),
     PathOption("pkgConfDir", "Directory for installation of pkg-config files",
-               join("$prefix","lib","pkgconfig"), PathOption.PathIsDirCreate),
+               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")]
 
@@ -126,6 +126,12 @@
 # Set the alias for install
 env.Alias("install", targets)
 
+# Create installation target folders if they don't exists:
+if 'install' in COMMAND_LINE_TARGETS:
+    for target_dir in [env.subst(d) for d in targets]:
+        if not os.path.isdir(target_dir):
+            os.makedirs(target_dir)
+
 # If the user are cleaning remove any old ufc python modules
 #if env.GetOption("clean") and isdir(join(env.subst(env["pythonModuleDir"]),"ufc")):
 if old_ufc_modules and env["cleanOldUFC"]:
diff -r e2e0c5e8d6a6 swig_config.py
--- a/swig_config.py	Tue Feb 03 13:54:51 2009 +0100
+++ b/swig_config.py	Mon Feb 09 12:13:57 2009 +0100
@@ -72,15 +72,20 @@
     python_version = "%s.%s" % (sys.version_info[0],sys.version_info[1])
     context.env["PYTHON_VERSION"] = python_version
     if context.env["PLATFORM"].startswith("win"):
-        python_dir = os.path.join(sys.prefix,"include")
+        python_inc_dir = os.path.join(sys.prefix,"include")
+        python_lib_dir = os.path.join(sys.prefix,"libs")
+        python_lib = "python%s%s" % (sys.version_info[0],sys.version_info[1])
     else:
-        python_dir = os.path.join(sys.prefix,"include","python"+python_version)
+        python_inc_dir = os.path.join(sys.prefix,"include","python"+python_version)
 
-    python_is_found = os.path.isfile(os.path.join(python_dir, "Python.h"))
+    python_is_found = os.path.isfile(os.path.join(python_inc_dir, "Python.h"))
     
     # Add path to python if found
     if python_is_found:
-        context.env.Append(CPPPATH = [python_dir])
+        context.env.Append(CPPPATH=[python_inc_dir])
+        if context.env["PLATFORM"].startswith("win"):
+            context.env.Append(LIBPATH=[python_lib_dir])
+            context.env.Append(LIBS=[python_lib])
     context.Result(python_is_found)
     return python_is_found
 
@@ -88,13 +93,15 @@
 def checkBoost(context):
     context.Message("Checking for Boost...")
     # Set a default directory for the boost installation
-    if sys.platform == "darwin":
+    if context.env["PLATFORM"] == "darwin":
         # use fink as default
         default = os.path.join(os.path.sep,"sw")
+    elif context.env["PLATFORM"].startswith("win"):
+        default = r'C:\local'
     else:
         default = os.path.join(os.path.sep,"usr")
             
-    boost_dir = context.env.get("boostDir",context.env.get("BOOST_DIR",default))
+    boost_dir = context.env.get("boostDir",os.getenv("BOOST_DIR",default))
     boost_is_found = False
     
     for inc_dir in ["", "include"]:

---

From: Johan Hake <[email-masked]>
Date: Mon, 9 Feb 2009 12:41:49 +0100

On Monday 09 February 2009 12:18:26 Johannes Ring wrote:
> >> > > Could you also update the README file, it still says to use
> >>
> >> setup.py.
> >>
> >> > Of course, and I will remove the setup.py as soon as there's no
> >>
> >> problem
> >>
> > mailing list. If it really is a bug Johannes have _another_ workaround
> > for this.
>

Ok, it is in, with changes to README together with a removal of the old 
setup.py.

The manual also needs some attention, w.r.t installation and perhaps also some 
note about compilation of the python extention module?

Johan

---

From: "Johannes Ring" <[email-masked]>
Date: Tue, 10 Feb 2009 09:01:07 +0100 (CET)

Hi,

here is another minor fix for Windows (attached).

Johannes

On Mon, February 9, 2009 12:41, Johan Hake wrote:
>> > and the /superuser/directory is non excisting. Then scons tries to
>> create
>> > that
# HG changeset patch
# User Johannes Ring <[email-masked]>
# Date 1234252549 -3600
# Node ID 34b6aaafb711f04a53536bb3bb555563d171bb14
# Parent  cd85daf5e14b63adcdba6bce0baa480764b0264b
Minor fix (we need double backslashes in pkg-config file on Windows).

diff -r cd85daf5e14b -r 34b6aaafb711 SConstruct
--- a/SConstruct	Mon Feb 09 12:39:37 2009 +0100
+++ b/SConstruct	Tue Feb 10 08:55:49 2009 +0100
@@ -94,7 +94,8 @@
 file.write("Name: UFC\n")
 file.write("Version: %d.%d\n" % (major, minor))
 file.write("Description: Unified Form-assembly Code\n")
-file.write("Cflags: -I%s\n" % normpath(env.subst(env["includeDir"])))
+file.write("Cflags: -I%s\n" % \
+           repr(normpath(env.subst(env["includeDir"])))[1:-1])
 file.close()
 
 # Set up installation targets