summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Grayson <sam@samgrayson.me>2022-12-14 16:03:03 -0700
committerGitHub <noreply@github.com>2022-12-14 16:03:03 -0700
commitcab8f795a7bc4a6c9ed71c99170172552e410f52 (patch)
treeec6702b661024e218b00e8ee8fcb655008b52cf3
parent2db38bfa382203fb9729f701c5ba9f27d91c845a (diff)
downloadspack-cab8f795a7bc4a6c9ed71c99170172552e410f52.tar.gz
spack-cab8f795a7bc4a6c9ed71c99170172552e410f52.tar.bz2
spack-cab8f795a7bc4a6c9ed71c99170172552e410f52.tar.xz
spack-cab8f795a7bc4a6c9ed71c99170172552e410f52.zip
Patch dill._dill._is_builtin_module (#34534)
* Patch dill._dill._is_builtin_module * Fix style * Add test
-rw-r--r--var/spack/repos/builtin/packages/py-dill/fix-is-builtin-module.patch25
-rw-r--r--var/spack/repos/builtin/packages/py-dill/package.py14
2 files changed, 39 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/py-dill/fix-is-builtin-module.patch b/var/spack/repos/builtin/packages/py-dill/fix-is-builtin-module.patch
new file mode 100644
index 0000000000..29ba24d036
--- /dev/null
+++ b/var/spack/repos/builtin/packages/py-dill/fix-is-builtin-module.patch
@@ -0,0 +1,25 @@
+--- a/dill/_dill.py
++++ b/dill/_dill.py
+@@ -1588,10 +1588,18 @@ def _is_builtin_module(module):
+ # If a module file name starts with prefix, it should be a builtin
+ # module, so should always be pickled as a reference.
+ names = ["base_prefix", "base_exec_prefix", "exec_prefix", "prefix", "real_prefix"]
+- return any(os.path.realpath(module.__file__).startswith(os.path.realpath(getattr(sys, name)))
+- for name in names if hasattr(sys, name)) or \
+- module.__file__.endswith(EXTENSION_SUFFIXES) or \
+- 'site-packages' in module.__file__
++ rp = os.path.realpath
++ # See https://github.com/uqfoundation/dill/issues/566
++ return (
++ any(
++ module.__file__.startswith(getattr(sys, name))
++ or rp(module.__file__).startswith(rp(getattr(sys, name)))
++ for name in names
++ if hasattr(sys, name)
++ )
++ or module.__file__.endswith(EXTENSION_SUFFIXES)
++ or 'site-packages' in module.__file__
++ )
+
+ def _is_imported_module(module):
+ return getattr(module, '__loader__', None) is not None or module in sys.modules.values()
diff --git a/var/spack/repos/builtin/packages/py-dill/package.py b/var/spack/repos/builtin/packages/py-dill/package.py
index 3d4bc29f1c..d589ff8d05 100644
--- a/var/spack/repos/builtin/packages/py-dill/package.py
+++ b/var/spack/repos/builtin/packages/py-dill/package.py
@@ -12,6 +12,7 @@ class PyDill(PythonPackage):
homepage = "https://github.com/uqfoundation/dill"
pypi = "dill/dill-0.2.7.tar.gz"
+ version("0.3.6", sha256="e5db55f3687856d8fbdab002ed78544e1c4559a130302693d839dfe8f93f2373")
version("0.3.5.1", sha256="d75e41f3eff1eee599d738e76ba8f4ad98ea229db8b085318aa2b3333a208c86")
version("0.3.4", sha256="9f9734205146b2b353ab3fec9af0070237b6ddae78452af83d2fca84d739e675")
version("0.3.1", sha256="d3ddddf2806a7bc9858b20c02dc174396795545e9d62f243b34481fd26eb3e2c")
@@ -25,6 +26,14 @@ class PyDill(PythonPackage):
version("0.2.1", sha256="a54401bdfae419cfe1c9e0b48e9b290afccaa413d2319d9bb0fdb85c130a7923")
version("0.2", sha256="aba8d4c81c4136310e6ce333bd6f4f3ea2d53bd367e2f69c864428f260c0308c")
+ # This patch addresses [this issue] with Dill and Spack.
+ # The issue was introduced at or before 0.3.5 in [this commit] and is still present in 0.3.6.
+ # We backport a [fixing PR] until it lands in upstream.
+ # [this issue]: https://github.com/uqfoundation/dill/issues/566
+ # [fixing PR]: https://github.com/uqfoundation/dill/pull/567
+ # [this commit]: https://github.com/uqfoundation/dill/commit/23c47455da62d4cb8582d8f98f1de9fc6e0971ad
+ patch("fix-is-builtin-module.patch", when="@0.3.5:")
+
depends_on("python@2.5:2.8,3.1:", type=("build", "run"))
depends_on("python@2.6:2.8,3.1:", when="@0.3.0:", type=("build", "run"))
depends_on("python@2.7:2.8,3.6:", when="@0.3.4:", type=("build", "run"))
@@ -43,3 +52,8 @@ class PyDill(PythonPackage):
url = url.format(version)
return url
+
+ @run_after("install")
+ @on_package_attributes(run_tests=True)
+ def check_install(self):
+ python("-c", "import dill, collections; dill.dumps(collections)")