PYTHONPATH : python patches methods for its extensions

This commit is contained in:
alalazo
2016-03-18 14:40:53 +01:00
parent 82ba0c6c07
commit ec8cc2b528
7 changed files with 53 additions and 27 deletions

View File

@@ -282,9 +282,11 @@ def setup_package(pkg):
for mod in modules:
set_module_variables_for_package(pkg, mod)
# Allow dependencies to set up environment as well.
# Allow dependencies to modify the module
for dependency_spec in pkg.spec.traverse(root=False):
dependency_spec.package.modify_module(pkg.module, dependency_spec, pkg.spec)
# Allow dependencies to set up environment as well
for dependency_spec in pkg.spec.traverse(root=False):
dependency_spec.package.setup_dependent_environment(env, pkg.spec)
# TODO : implement validation
#validate(env)

View File

@@ -79,7 +79,7 @@ def uninstall(parser, args):
try:
# should work if package is known to spack
pkgs.append(s.package)
except spack.repository.UnknownPackageError, e:
except spack.repository.UnknownPackageError as e:
# The package.py file has gone away -- but still
# want to uninstall.
spack.Package(s).do_uninstall(force=True)
@@ -94,11 +94,11 @@ def num_installed_deps(pkg):
for pkg in pkgs:
try:
pkg.do_uninstall(force=args.force)
except PackageStillNeededError, e:
except PackageStillNeededError as e:
tty.error("Will not uninstall %s" % e.spec.format("$_$@$%@$#", color=True))
print
print "The following packages depend on it:"
print()
print("The following packages depend on it:")
display_specs(e.dependents, long=True)
print
print "You can use spack uninstall -f to force this action."
print()
print("You can use spack uninstall -f to force this action.")
sys.exit(1)

View File

@@ -150,7 +150,7 @@ def remove_install_directory(self, spec):
if os.path.exists(path):
try:
shutil.rmtree(path)
except exceptions.OSError, e:
except exceptions.OSError as e:
raise RemoveFailedError(spec, path, e)
path = os.path.dirname(path)

View File

@@ -119,13 +119,13 @@ def __init__(cls, name, bases, dict):
module_types[cls.name] = cls
def __init__(self, spec=None):
self.spec = spec
self.pkg = spec.package # Just stored for convenience
# category in the modules system
# TODO: come up with smarter category names.
self.category = "spack"
self.spec = spec
self.pkg = spec.package # Just stored for convenience
# short description default is just the package + version
# packages can provide this optional attribute
self.short_description = spec.format("$_ $@")
@@ -161,6 +161,12 @@ def write(self):
# Environment modifications guessed by inspecting the installation prefix
env = inspect_path(self.spec.prefix)
# Let the extendee modify their extensions before asking for package-specific modifications
for extendee in self.pkg.extendees:
extendee_spec = self.spec[extendee]
extendee_spec.package.modify_module(self.pkg, extendee_spec, self.spec)
# Package-specific environment modifications
self.spec.package.setup_environment(env)
# TODO : implement site-specific modifications and filters

View File

@@ -1261,16 +1261,6 @@ def rpath_args(self):
"""Get the rpath args as a string, with -Wl,-rpath, for each element."""
return " ".join("-Wl,-rpath,%s" % p for p in self.rpath)
class PythonExtension(Package):
def setup_dependent_environment(self, env, dependent_spec):
pass
def setup_environment(self, env):
site_packages = glob.glob(join_path(self.spec.prefix.lib, "python*/site-packages"))
if site_packages:
env.prepend_path('PYTHONPATH', site_packages[0])
def validate_package_url(url_string):
"""Determine whether spack can handle a particular URL or not."""
url = urlparse(url_string)