#11760: 'sage-location' shouldn't "initialize" .pc (pkg-config) files more than
once
-----------------------+----------------------------------------------------
Reporter: leif | Owner:
Type: defect | Status: needs_review
Priority: blocker | Milestone: sage-4.7.2
Component: scripts | Keywords: pkgconfig libpng Duplicate definition
SAGE_ROOT
Work_issues: | Upstream: N/A
Reviewer: | Author: Leif Leonhardy
Merged: | Dependencies:
-----------------------+----------------------------------------------------
Comment(by leif):
John, would the following make you happy?
{{{
#!diff
diff --git a/sage-location b/sage-location
--- a/sage-location
+++ b/sage-location
@@ -167,6 +167,7 @@
the Sage installation has moved, i.e., paths have changed.
"""
import re
+ pat = re.compile(r"^SAGE_ROOT=.*\n", re.MULTILINE)
LIB = os.path.join(os.path.abspath(SAGE_ROOT), 'local', 'lib')
PKG = os.path.join(LIB, 'pkgconfig')
for name in os.listdir(PKG):
@@ -175,10 +176,23 @@
with open(filename) as file:
config = file.read()
- if re.search("^SAGE_ROOT=", config, re.MULTILINE):
- # There's already a definition of SAGE_ROOT,
- # so skip this file. (Cf. #11760).
- continue
+ first_match = pat.search(config)
+ if first_match:
+ # There are already one or more definitions of SAGE_ROOT,
+ # which also happens if we previously processed the same
+ # file (here) because of [symbolic or hard] links, so
this
+ # isn't necessarily an error. (Cf. #11760).
+ # For simplicity, we just remove any definition, and only
+ # issue a warning if there was more than one, and don't
+ # check whether a previous definition was already
current:
+ config, n = pat.subn("", config)
+ if n>1:
+ sys.stderr.write(
+ "Warning: sage_location:
initialize_pkgconfig_files():\n" +
+ " File \"%s\" already contained %d definitions
of SAGE_ROOT.\n" %
+ (name, n) +
+ " These will get replaced by a single, current
definition.\n")
+ sys.stderr.flush()
new_config = config.replace(os.path.abspath(SAGE_ROOT),
"${SAGE_ROOT}")
new_config = 'SAGE_ROOT=%s\n' % os.path.abspath(SAGE_ROOT) +
new_config
}}}
If so, I'll just attach that patch, to be applied on top of the other one.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11760#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.