Repository: spack/spack

Issue:
Octave pcre2
Explicit dependency on PCRE2 only when desired and if so specifying the correct spack-installed location, to avoid inadvertently pulling in the system-installed version which leads to bug #39090 


Discussion:
@samcmill Any issues or concerns with merging this PR?
> @samcmill Any issues or concerns with merging this PR?

This PR does not touch anything I watch, so no opinion.
> > @samcmill Any issues or concerns with merging this PR?
> 
> This PR does not touch anything I watch, so no opinion.

My apologies.  I was simultaneously reviewing two PRs and changed focus to the wrong one when I added that note.
@mtmiller Any issues or concerns with merging this PR?
@davidedelvento Can you solve the conflict?
Looks like github does not have a nice way to go line-by-line and just mark the description as the appropriate way to solve the conflict, so I need to go into my file and edit that. Will do, but sorry for the wait
I added the commits https://github.com/spack/spack/pull/39126/commits/857587a3afa28a644a9f6316916d91142bfccef1 and 
https://github.com/spack/spack/pull/39126/commits/f191194e0985e4c327493ed138cc2dbc21dab560 (as it is shown in this description right above this comment) but the [diff tab](https://github.com/spack/spack/pull/39126/files) in this PR hasn't updated accordingly yet at time of writing. Not sure if GH will eventually update it or if anybody (I??) need to do anything to trigger that
And by the way, I actually dislike this way of setting the description, which does not add any information and feels very error-prone and just a typo waiting to happen. Couldn't the variant call automatically create a description by querying the relevant package for its preferred name and prefix that by "Use " instead? That would have been more robust, in my humble opinion. Even if there is not a "preferred name" yet in packages (in such a case the string of the package name could be used as a backup) adding that would have been just a single line for each package. This way is all dependencies for each package which feels like a nightmare. But, as it usually happen, I digress... and should have done so in a different context, not here, sorry about that.
> I added the commits [857587a](https://github.com/spack/spack/commit/857587a3afa28a644a9f6316916d91142bfccef1) and
> [f191194](https://github.com/spack/spack/commit/f191194e0985e4c327493ed138cc2dbc21dab560) (as it is shown in this description right above this comment) but the [diff tab](https://github.com/spack/spack/pull/39126/files) in this PR hasn't updated accordingly yet at time of writing. Not sure if GH will eventually update it or if anybody (I??) need to do anything to trigger that

When I get frustrated with the delay I'll click the refresh icon.  Usually that works for me.
Thanks @tldahlgren if you mean the browser refresh button, I've tried that several times to no avail. If you mean a github button, I can't find it. Perhaps it is waiting for the various checks and prechecks to complete before updating the conflict section and hence diffs? Given that [commits](https://github.com/spack/spack/pull/39126/commits) are updated I don't think there is anything else I can do at this point (other than getting dinner :rofl:)
> Thanks @tldahlgren if you mean the browser refresh button, I've tried that several times to no avail.

Yes, that's what I meant. 

I didn't realize your issue was with the reported conflicting files not disappearing. 

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/octave/package.py b/var/spack/repos/builtin/packages/octave/package.py
--- a/var/spack/repos/builtin/packages/octave/package.py
+++ b/var/spack/repos/builtin/packages/octave/package.py
@@ -70,6 +70,7 @@ class Octave(AutotoolsPackage, GNUMirrorPackage):
     variant("jdk", default=False, description="Use JDK")
     variant("llvm", default=False, description="Use LLVM")
     variant("opengl", default=False, description="Use OpenGL")
+    variant("pcre2", default=True, when="@8:", description="Use PCRE2 instead of PCRE")
     variant("qhull", default=False, description="Use qhull")
     variant("qrupdate", default=False, description="Use qrupdate")
     variant("qscintilla", default=False, description="Use QScintill")
@@ -82,7 +83,9 @@ class Octave(AutotoolsPackage, GNUMirrorPackage):
     depends_on("lapack")
     # Octave does not configure with sed from darwin:
     depends_on("sed", when=sys.platform == "darwin", type="build")
-    depends_on("pcre")
+    depends_on("pcre", when="@:7")
+    depends_on("pcre", when="~pcre2")
+    depends_on("pcre2", when="+pcre2")
     depends_on("pkgconfig", type="build")
     depends_on("texinfo", type="build")
 
@@ -348,6 +351,8 @@ def configure_args(self):
         else:
             config_args.append("--without-z")
 
+        if spec.satisfies("~pcre2"):
+            config_args.append("--without-pcre2")
         # If 64-bit BLAS is used:
         if (
             spec.satisfies("^openblas+ilp64")


Test patch: