diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-07-22 13:56:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-22 13:56:19 -0700 |
commit | 395c616a484bfb0385ea2304c566798f65a19127 (patch) | |
tree | 32de082c2ad6a407932ab25d1ff3559c6c5433bc /var | |
parent | f5b4664c7c58280776cb66e000d2c37487155ad1 (diff) | |
parent | fa92f58167352efa21c787bf38e878ad471484f8 (diff) | |
download | spack-395c616a484bfb0385ea2304c566798f65a19127.tar.gz spack-395c616a484bfb0385ea2304c566798f65a19127.tar.bz2 spack-395c616a484bfb0385ea2304c566798f65a19127.tar.xz spack-395c616a484bfb0385ea2304c566798f65a19127.zip |
Merge pull request #950 from xjrc/packages/python
Enhancement Proposal: Make Python Spack Installs Ignore User Configuration
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/py-setuptools/package.py | 7 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/python/package.py | 74 |
2 files changed, 43 insertions, 38 deletions
diff --git a/var/spack/repos/builtin/packages/py-setuptools/package.py b/var/spack/repos/builtin/packages/py-setuptools/package.py index 68032cb68d..08d5e5d552 100644 --- a/var/spack/repos/builtin/packages/py-setuptools/package.py +++ b/var/spack/repos/builtin/packages/py-setuptools/package.py @@ -24,8 +24,11 @@ ############################################################################## from spack import * + class PySetuptools(Package): - """Easily download, build, install, upgrade, and uninstall Python packages.""" + """A Python utility that aids in the process of downloading, building, + upgrading, installing, and uninstalling Python packages.""" + homepage = "https://pypi.python.org/pypi/setuptools" url = "https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.tar.gz" @@ -40,4 +43,4 @@ class PySetuptools(Package): extends('python') def install(self, spec, prefix): - python('setup.py', 'install', '--prefix=%s' % prefix) + setup_py('install', '--prefix=%s' % prefix) diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py index bbb1e9c13a..f755527607 100644 --- a/var/spack/repos/builtin/packages/python/package.py +++ b/var/spack/repos/builtin/packages/python/package.py @@ -27,6 +27,7 @@ import re from contextlib import closing import spack +import llnl.util.tty as tty from llnl.util.lang import match_predicate from spack import * from spack.util.environment import * @@ -72,40 +73,41 @@ class Python(Package): depends_on("tk", when="+tk") depends_on("tcl", when="+tk") + @when('@2.7,3.4:') + def patch(self): + # NOTE: Python's default installation procedure makes it possible for a + # user's local configurations to change the Spack installation. In + # order to prevent this behavior for a full installation, we must + # modify the installation script so that it ignores user files. + ff = FileFilter('Makefile.pre.in') + ff.filter( + r'^(.*)setup\.py(.*)((build)|(install))(.*)$', + r'\1setup.py\2 --no-user-cfg \3\6' + ) + def install(self, spec, prefix): + # TODO: The '--no-user-cfg' option for Python installation is only in + # Python v2.7 and v3.4+ (see https://bugs.python.org/issue1180) and + # adding support for ignoring user configuration will require + # significant changes to this package for other Python versions. + if not spec.satisfies('@2.7,3.4:'): + tty.warn(('Python v{0} may not install properly if Python ' + 'user configurations are present.').format(self.version)) + # Need this to allow python build to find the Python installation. - env['PYTHONHOME'] = prefix + env['PYTHONHOME'], env['PYTHONPATH'] = prefix, prefix env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' # Rest of install is pretty standard except setup.py needs to # be able to read the CPPFLAGS and LDFLAGS as it scans for the # library and headers to build - include_dirs = [ - spec['openssl'].prefix.include, spec['bzip2'].prefix.include, - spec['readline'].prefix.include, spec['ncurses'].prefix.include, - spec['sqlite'].prefix.include, spec['zlib'].prefix.include - ] - - library_dirs = [ - spec['openssl'].prefix.lib, spec['bzip2'].prefix.lib, - spec['readline'].prefix.lib, spec['ncurses'].prefix.lib, - spec['sqlite'].prefix.lib, spec['zlib'].prefix.lib - ] - - if '+tk' in spec: - include_dirs.extend([ - spec['tk'].prefix.include, spec['tcl'].prefix.include - ]) - library_dirs.extend([ - spec['tk'].prefix.lib, spec['tcl'].prefix.lib - ]) - + dep_pfxs = [dspec.prefix for dspec in spec.dependencies('link')] config_args = [ - "--prefix={0}".format(prefix), - "--with-threads", - "--enable-shared", - "CPPFLAGS=-I{0}".format(" -I".join(include_dirs)), - "LDFLAGS=-L{0}".format(" -L".join(library_dirs)) + '--prefix={0}'.format(prefix), + '--with-threads', + '--enable-shared', + 'CPPFLAGS=-I{0}'.format(' -I'.join(dp.include for dp in dep_pfxs)), + 'LDFLAGS=-L{0}'.format(' -L'.join(dp.lib for dp in dep_pfxs)), ] if '+ucs4' in spec: @@ -121,9 +123,8 @@ class Python(Package): config_args.append('--without-ensurepip') configure(*config_args) - make() - make("install") + make('install') self.filter_compilers(spec, prefix) @@ -193,6 +194,8 @@ class Python(Package): def setup_dependent_environment(self, spack_env, run_env, extension_spec): """Set PYTHONPATH to include site-packages dir for the extension and any other python extensions it depends on.""" + pythonhome = self.prefix + spack_env.set('PYTHONHOME', pythonhome) python_paths = [] for d in extension_spec.traverse(deptype=nolink, deptype_query='run'): @@ -214,15 +217,14 @@ class Python(Package): In most cases, extensions will only need to have one line:: - python('setup.py', 'install', '--prefix={0}'.format(prefix))""" + setup_py('install', '--prefix={0}'.format(prefix))""" + python_path = join_path( + self.spec.prefix.bin, + 'python{0}'.format('3' if self.spec.satisfies('@3') else '') + ) - # Python extension builds can have a global python executable function - if Version("3.0.0") <= self.version < Version("4.0.0"): - module.python = Executable(join_path(self.spec.prefix.bin, - 'python3')) - else: - module.python = Executable(join_path(self.spec.prefix.bin, - 'python')) + module.python = Executable(python_path) + module.setup_py = Executable(python_path + ' setup.py --no-user-cfg') # Add variables for lib/pythonX.Y and lib/pythonX.Y/site-packages dirs. module.python_lib_dir = join_path(ext_spec.prefix, |