summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-01-10 19:37:01 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2015-02-02 11:19:53 -0800
commitbcccf020204a556e382c0af2897ad9126bb24984 (patch)
treeec2fa5aa4ad95998e5ba88b6c49eca6febf6a230 /var
parent82946d29147bbe63855f94b9c2ebd4a21cd0a3d6 (diff)
downloadspack-bcccf020204a556e382c0af2897ad9126bb24984.tar.gz
spack-bcccf020204a556e382c0af2897ad9126bb24984.tar.bz2
spack-bcccf020204a556e382c0af2897ad9126bb24984.tar.xz
spack-bcccf020204a556e382c0af2897ad9126bb24984.zip
Add setup_extension_environment() method.
- lets packages do some setup before their extensions run install()
Diffstat (limited to 'var')
-rw-r--r--var/spack/packages/py-setuptools/package.py6
-rw-r--r--var/spack/packages/python/package.py23
2 files changed, 22 insertions, 7 deletions
diff --git a/var/spack/packages/py-setuptools/package.py b/var/spack/packages/py-setuptools/package.py
index e2c4e1a0be..755288d55c 100644
--- a/var/spack/packages/py-setuptools/package.py
+++ b/var/spack/packages/py-setuptools/package.py
@@ -10,10 +10,4 @@ class PySetuptools(Package):
extends('python')
def install(self, spec, prefix):
- site_packages_dir = "%s/lib/python2.7/site-packages" % prefix
- mkdirp(site_packages_dir)
-
- env['PYTHONPATH'] = site_packages_dir
-
- python = which('python')
python('setup.py', 'install', '--prefix=%s' % prefix)
diff --git a/var/spack/packages/python/package.py b/var/spack/packages/python/package.py
index 953be69cc2..9700179ab8 100644
--- a/var/spack/packages/python/package.py
+++ b/var/spack/packages/python/package.py
@@ -1,5 +1,5 @@
from spack import *
-
+import os
class Python(Package):
"""The Python programming language."""
@@ -26,3 +26,24 @@ class Python(Package):
"--enable-shared")
make()
make("install")
+
+
+ def setup_extension_environment(self, module, spec, ext_spec):
+ """Called before python modules' install() methods.
+
+ In most cases, extensions will only need to have one line::
+
+ python('setup.py', 'install', '--prefix=%s' % prefix)
+ """
+ # Python extension builds can have a global python executable function
+ module.python = Executable(join_path(spec.prefix.bin, 'python'))
+
+ # Add variables for lib/pythonX.Y and lib/pythonX.Y/site-packages dirs.
+ module.python_lib_dir = join_path(ext_spec.prefix.lib, 'python%d.%d' % self.version[:2])
+ module.site_packages_dir = join_path(module.python_lib_dir, 'site-packages')
+
+ # Add site packages directory to the PYTHONPATH
+ os.environ['PYTHONPATH'] = module.site_packages_dir
+
+ # Make the site packages directory if it does not exist already.
+ mkdirp(module.site_packages_dir)