summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/patch.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/spack/spack/patch.py b/lib/spack/spack/patch.py
index 78bb15f41c..c970f4dfdc 100644
--- a/lib/spack/spack/patch.py
+++ b/lib/spack/spack/patch.py
@@ -23,16 +23,28 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import os
+import os.path
+import inspect
import spack
import spack.error
-import spack.stage
import spack.fetch_strategy as fs
-
+import spack.stage
from llnl.util.filesystem import join_path
from spack.util.executable import which
+def absolute_path_for_package(pkg):
+ """Returns the absolute path to the ``package.py`` file implementing
+ the recipe for the package passed as argument.
+
+ Args:
+ pkg: a valid package object
+ """
+ m = inspect.getmodule(pkg)
+ return os.path.abspath(m.__file__)
+
+
class Patch(object):
"""Base class to describe a patch that needs to be applied to some
expanded source code.
@@ -90,7 +102,7 @@ class FilePatch(Patch):
def __init__(self, pkg, path_or_url, level):
super(FilePatch, self).__init__(pkg, path_or_url, level)
- pkg_dir = spack.repo.dirname_for_package_name(pkg.name)
+ pkg_dir = os.path.dirname(absolute_path_for_package(pkg))
self.path = join_path(pkg_dir, path_or_url)
if not os.path.isfile(self.path):
raise NoSuchPatchFileError(pkg.name, self.path)