Subject: [UFC-dev] [Bug 430869] [NEW] python-module-location

From: Garth Wells <[email-masked]>
Date: Wed, 16 Sep 2009 17:09:18 -0000

Public bug reported:

Under Ubuntu 9.04 and 9.10, the UFC Python modules are installed in
/usr/local/lib/python2.6/site-packages. The default location should be
'dist-packages' and not 'site-packages'. This may be a Python bug.

Also see https://bugs.launchpad.net/ubuntu/+source/python2.6/+bug/362570

** Affects: ufc
     Importance: Medium
     Assignee: Johannes Ring (johannr)
         Status: Confirmed

** Affects: ufc/trunk
     Importance: Medium
     Assignee: Johannes Ring (johannr)
         Status: Confirmed

** Description changed:

  Under Ubuntu 9.04 and 9.10, the UFC Python modules are installed in
  /usr/local/lib/python2.6/site-packages. The default location should be
  'dist-packages' and not 'site-packages'. This may be a Python bug.
+ 
+ Also see https://bugs.launchpad.net/ubuntu/+source/python2.6/+bug/362570

** Changed in: ufc
       Status: New => Confirmed

** Changed in: ufc
   Importance: Undecided => Medium

** Changed in: ufc
     Assignee: (unassigned) => Johannes Ring (johannr)

** Also affects: ufc/trunk
   Importance: Medium
     Assignee: Johannes Ring (johannr)
       Status: Confirmed

** Changed in: ufc/trunk
    Milestone: None => 1.2

-- 
python-module-location
https://bugs.launchpad.net/bugs/430869
You received this bug notification because you are subscribed to UFC.

Status in Unified Form-assembly Code: Confirmed
Status in UFC trunk series: Confirmed

Bug description:
Under Ubuntu 9.04 and 9.10, the UFC Python modules are installed in /usr/local/lib/python2.6/site-packages. The default location should be 'dist-packages' and not 'site-packages'. This may be a Python bug.

Also see https://bugs.launchpad.net/ubuntu/+source/python2.6/+bug/362570

---

From: Garth Wells <[email-masked]>
Date: Wed, 16 Sep 2009 17:55:32 -0000

Could we use distutils in the same we we use it for other FEniCS
packages to install the Python modules?

Bug description:

---

From: Johan Hake <[email-masked]>
Date: Wed, 16 Sep 2009 18:31:48 -0000

> packages to install the Python modules?

We did this before we extended the ufc.h with a python module. This was done 
because we do quite a lot of configuration, SWIG and boost check. I "felt" 
SCons was more appropriate for such tasks.

Isn't there an easy fix? It works in PyDOLFIN, which also use SCons.

Johan

Bug description:

---

From: Garth Wells <[email-masked]>
Date: Wed, 16 Sep 2009 18:52:05 -0000

> SCons was more appropriate for such tasks.

I'm thinking to use distutils from with SConstruct.

> Isn't there an easy fix? It works in PyDOLFIN, which also use SCons.

I guess that it won't work if one installs PyDOLFIN system-wide. I 
always install it locally and dolfin.conf takes care of the path.

I know a few people that had trouble building DOLFIN because the UFC 
Python modules were not in their default PYTHONPATH.

Garth

Bug description:

---

From: [email-masked]
Date: Thu, 17 Sep 2009 08:31:12 +0200

> Python modules were not in their default PYTHONPATH.

It shouldn't be to hard to make a setup.py file that executes a set of
scons commands, e.g. with a prefix, if  that solves your problem ?
But it wouldn't be easy to map all distutils flags to appropriate flags in
scons.

Kent

---

From: Johannes Ring <[email-masked]>
Date: Thu, 17 Sep 2009 07:24:12 -0000

I'm suggesting the following patch:

diff -r c2ab1cfdea7f SConstruct
--- a/SConstruct	Wed Sep 16 17:43:59 2009 +0200
+++ b/SConstruct	Thu Sep 17 09:10:16 2009 +0200
@@ -27,7 +27,7 @@
 elif env["PLATFORM"] == "darwin":
     default_python_dir = os.path.join("$prefix", "lib", "python" + sysconfig.get_python_version(),"site-packages")
 else:
-    default_python_dir = sysconfig.get_python_lib(prefix="$prefix",plat_specific=True)
+    default_python_dir = sysconfig.get_python_lib(plat_specific=True).replace(sys.prefix, '$prefix')
 
 options = [
     # configurable options for installation:

If you think it looks okay, please go ahead an apply it.

Bug description:

---

From: Johan Hake <[email-masked]>
Date: Thu, 17 Sep 2009 07:36:15 -0000

On Thursday 17 September 2009 09:24:12 Johannes Ring wrote:
>      default_python_dir = os.path.join("$prefix", "lib", "python" +
>  sysconfig.get_python_version(),"site-packages") else:
> -    default_python_dir =
>  sysconfig.get_python_lib(prefix="$prefix",plat_specific=True) +   
>  default_python_dir =
>  sysconfig.get_python_lib(plat_specific=True).replace(sys.prefix,
>  '$prefix')
> 
>  options = [

The problem with this fix is that when we use another prefix than the default 
one, we should use site-packages, and not dist-packages.

I do not think this fix will do that.

Johan

Bug description:

---

From: Johannes Ring <[email-masked]>
Date: Thu, 17 Sep 2009 10:28:28 -0000

True. I then propose the following fix:

diff -r c2ab1cfdea7f SConstruct
--- a/SConstruct	Wed Sep 16 17:43:59 2009 +0200
+++ b/SConstruct	Thu Sep 17 12:25:45 2009 +0200
@@ -65,8 +65,6 @@
     if DESTDIR:
         env["DESTDIR"] = DESTDIR
 
-env.Help(opts.GenerateHelpText(env))
-
 # Start building the message presented at the end of a simulation
 end_message = "\n"
 
@@ -113,6 +111,16 @@
     tgts_dir = ["includeDir", "pythonModuleDir", "pythonExtDir", "pkgConfDir"]
     for tgt_dir in tgts_dir:
         env[tgt_dir] = env[tgt_dir].replace("$prefix", install_prefix)
+
+# If necessary, replace site-packages with dist-packages when prefix is
+# either /usr or /usr/local (hack for Python 2.6 on Debian/Ubuntu)
+if env.subst("$prefix").rstrip("/") in ("/usr", "/usr/local") and \
+       "dist-packages" in sysconfig.get_python_lib():
+    for tgt_dir in ["pythonModuleDir", "pythonExtDir"]:
+        env[tgt_dir] = env[tgt_dir].replace("site-packages", "dist-packages")
+               
+# Now generate the help text
+env.Help(opts.GenerateHelpText(env))
 
 # Set up installation targets
 ufc_basename = join("src", "ufc", "ufc")

Any objections?

Bug description:

---

From: Johannes Ring <[email-masked]>
Date: Thu, 17 Sep 2009 15:17:13 -0000

** Changed in: ufc/trunk
       Status: Confirmed => Fix Committed

Status in Unified Form-assembly Code: Fix Committed
Status in UFC trunk series: Fix Committed

Bug description: