# HG changeset patch
# User J. H. Palmieri <palmieri@math.washington.edu>
# Date 1350591395 25200
# Node ID fc5fa5999059ba418cbd64ab4759a6b61c8153fa
# Parent 1a559058a620acd6eb42ca92f06fc515eb0b4c9c
Docstring rewordings in lazy_string.py, fix for defn of SPYX_TMP
and usage of SAGE_TMP_INTERFACE
diff --git a/sage/interfaces/expect.py b/sage/interfaces/expect.py
a
|
b
|
BAD_SESSION = -2 |
72 | 72 | |
73 | 73 | failed_to_start = [] |
74 | 74 | |
75 | | #tmp_expect_interface_local='%s/tmp'%SAGE_TMP_INTERFACE |
76 | | |
77 | | #def tmp_expect_interface_local(): |
78 | | # return '%s/tmp'%SAGE_TMP_INTERFACE + str(os.getpid()) |
79 | | |
80 | | ## On some platforms, e.g., windows, this can easily take 10 seconds!?! Terrible. And |
81 | | ## it should not be necessary or used anyways. |
82 | | ## def _absolute(cmd): |
83 | | ## c = cmd.split() |
84 | | ## s = c[0] |
85 | | ## t = os.popen('which %s'%s).read().strip() |
86 | | ## if len(t) == 0: |
87 | | ## raise RuntimeError |
88 | | ## return ' '.join([t] + c[1:]) |
89 | | |
90 | 75 | # The subprocess is a shared resource. In a multi-threaded |
91 | 76 | # environment, there would have to be a lock to control access to the |
92 | 77 | # subprocess. Fortunately, Sage does not use Python threads. |
… |
… |
If this all works, you can then make cal |
587 | 572 | - Simon King (2010-09): Making the tmp-file unique for the interface instance |
588 | 573 | |
589 | 574 | """ |
590 | | #return '%s/tmp'%SAGE_TMP_INTERFACE + str(self.pid()) |
591 | 575 | try: |
592 | 576 | return self.__local_tmpfile |
593 | 577 | except AttributeError: |
594 | | self.__local_tmpfile = '%s/tmp'%SAGE_TMP_INTERFACE + str(self.pid()) |
| 578 | self.__local_tmpfile = os.path.join(SAGE_TMP_INTERFACE, 'tmp' + str(self.pid())) |
595 | 579 | return self.__local_tmpfile |
596 | 580 | |
597 | 581 | def _remote_tmpdir(self): |
diff --git a/sage/misc/cython.py b/sage/misc/cython.py
a
|
b
|
def cython(filename, verbose=False, comp |
373 | 373 | # This is the *temporary* directory where we build the pyx file. |
374 | 374 | # This is deleted when sage exits, which means pyx files must be |
375 | 375 | # rebuilt every time Sage is restarted at present. |
376 | | build_dir = '%s/%s'%(SPYX_TMP, base) |
| 376 | build_dir = os.path.join(SPYX_TMP, base) |
377 | 377 | |
378 | 378 | if os.path.exists(build_dir): |
379 | 379 | # There is already a module here. Maybe we do not have to rebuild? |
diff --git a/sage/misc/lazy_string.py b/sage/misc/lazy_string.py
a
|
b
|
Based on speaklater: https://github.com/ |
6 | 6 | |
7 | 7 | A lazy string is an object that behaves almost exactly like a string |
8 | 8 | but where the value is not computed until needed. To define a lazy |
9 | | you specify a function that produces a string together with the |
| 9 | string you specify a function that produces a string together with the |
10 | 10 | appropriate arguments for that function. Sage uses lazy strings in |
11 | 11 | :mod:`sage.misc.misc` so that the filenames for SAGE_TMP (which |
12 | | depends on the pid of the process running Sage) is not computed when |
| 12 | depends on the pid of the process running Sage) are not computed when |
13 | 13 | importing the Sage library. This means that when the doctesting code |
14 | 14 | imports the Sage library and then forks, the variable SAGE_TMP depends |
15 | 15 | on the new pid rather than the old one. |
diff --git a/sage/misc/misc.py b/sage/misc/misc.py
a
|
b
|
def SAGE_TMP(): |
152 | 152 | sage_makedirs(d) |
153 | 153 | return d |
154 | 154 | |
155 | | SPYX_TMP = os.path.join(SAGE_TMP, 'spyx/') |
156 | 155 | @lazy_string |
157 | 156 | def SPYX_TMP(): |
158 | 157 | """ |
… |
… |
def SPYX_TMP(): |
160 | 159 | |
161 | 160 | sage: from sage.misc.misc import SPYX_TMP |
162 | 161 | sage: SPYX_TMP |
163 | | l'.../temp/.../spyx/' |
| 162 | l'.../temp/.../spyx' |
164 | 163 | """ |
165 | | return os.path.join(SAGE_TMP, 'spyx', os.sep) |
| 164 | return os.path.join(SAGE_TMP, 'spyx') |
166 | 165 | |
167 | 166 | @lazy_string |
168 | 167 | def SAGE_TMP_INTERFACE(): |