Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I ran into the same problem with Sage Version 5.9-OSX-64bit-10.8. Previous versions from a couple of years ago worked fine. Sagetex seems to lose track of the directory of the LaTeX file, so the two files mentioned above are placed in the user's home directory instead of the directory where the LaTeX file is located.

There must be a better solution, but here is a hack that works by replacing three lines in sagetex.py, found in /Applications/Sage-5.9-OSX-64bit-10.8.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py on my Mac.

Near the end of sagetex.py are three lines separated by other code:

   sagef = open(self.filename + '.sagetex.sage', 'r')
   ...
   os.rename(self.filename + '.sagetex.sout.tmp', self.filename + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', self.filename + '.sagetex.scmd')

Replace each of these lines by the corresponding line below:

   sagef = open(traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sage', 'r')
   …
   os.rename(self.filename + '.sagetex.sout.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.scmd')

I use the Python traceback module to identify the full path+filename of the script that calls sagetex.py, and then I strip the extension (".sagetex.sage") from this to provide the base to construct the necessary correct full filenames. This is neither elegant nor necessarily robust, but it solves the problem for me for now.

click to hide/show revision 2
Added extra fix for plot files.

I ran into the same problem with Sage Version 5.9-OSX-64bit-10.8. Previous versions from a couple of years ago worked fine. Sagetex seems to lose track of the directory of the LaTeX file, so the two files mentioned above are placed in the user's home directory instead of the directory where the LaTeX file is located.located. If

There must be a better solution, but here is a hack that works by replacing three lines in sagetex.py, found in /Applications/Sage-5.9-OSX-64bit-10.8.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py on my Mac.

Near the end of sagetex.py are three lines separated by other code:

   sagef = open(self.filename + '.sagetex.sage', 'r')
   ...
   os.rename(self.filename + '.sagetex.sout.tmp', self.filename + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', self.filename + '.sagetex.scmd')

Replace each of these lines by the corresponding line below:

   sagef = open(traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sage', 'r')
   …
   os.rename(self.filename + '.sagetex.sout.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.scmd')

I use the Python traceback module to identify the full path+filename of the script that calls sagetex.py, and then I strip the extension (".sagetex.sage") from this to provide the base to construct the necessary correct full filenames. This is neither elegant nor necessarily robust, but it solves the problem for me for now.

Note that the 'sage-plots-for-…' plot folder is also put in the main user directory. In order to get the plot folder into the current local directory, look in sagetex.py and replace the line

    self.plotdir = age-plots-for-' + jobname + '.tex'

with

    self.plotdir = localdir+'/sage-plots-for-' + jobname + '.tex'

I ran into the same problem with Sage Version 5.9-OSX-64bit-10.8. Previous versions from a couple of years ago worked fine. Sagetex seems to lose track of the directory of the LaTeX file, so the two files mentioned above are placed in the user's home directory instead of the directory where the LaTeX file is located. If

There must be a better solution, but here is a hack that works by replacing three lines in sagetex.py, found in /Applications/Sage-5.9-OSX-64bit-10.8.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py on my Mac.

Near the end of sagetex.py are three lines separated by other code:

   sagef = open(self.filename + '.sagetex.sage', 'r')
   ...
   os.rename(self.filename + '.sagetex.sout.tmp', self.filename + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', self.filename + '.sagetex.scmd')

Replace each of these lines by the corresponding line below:

   sagef = open(traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sage', 'r')
   …
   os.rename(self.filename + '.sagetex.sout.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.scmd')

I use the Python traceback module to identify the full path+filename of the script that calls sagetex.py, and then I strip the extension (".sagetex.sage") from this to provide the base to construct the necessary correct full filenames. This is neither elegant nor necessarily robust, but it solves the problem for me for now.

Note that the 'sage-plots-for-…' plot folder is also put in the main user directory. In order to get the plot folder into the current local directory, look in sagetex.py and replace the line

    self.plotdir = age-plots-for-' + jobname + '.tex'

with

     localdir = "/".join((traceback.extract_stack(limit=2)[0][0][0:-11]).split("/")[:-1])
        self.plotdir = localdir+'/sage-plots-for-' + jobname + '.tex'

I ran into the same problem with Sage Version 5.9-OSX-64bit-10.8. Previous versions from a couple of years ago worked fine. Sagetex seems to lose track of the directory of the LaTeX file, so the two files mentioned above are placed in the user's home directory instead of the directory where the LaTeX file is located. If

There must be a better solution, but here is a hack that works by replacing three lines in sagetex.py, found in /Applications/Sage-5.9-OSX-64bit-10.8.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py on my Mac.

Near the end of sagetex.py are three lines separated by other code:

   sagef = open(self.filename + '.sagetex.sage', 'r')
   ...
   os.rename(self.filename + '.sagetex.sout.tmp', self.filename + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', self.filename + '.sagetex.scmd')

Replace each of these lines by the corresponding line below:

   sagef = open(traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sage', 'r')
   …
   os.rename(self.filename + '.sagetex.sout.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.scmd')

I use the Python traceback module to identify the full path+filename of the script that calls sagetex.py, and then I strip the extension (".sagetex.sage") from this to provide the base to construct the necessary correct full filenames. This is neither elegant nor necessarily robust, but it solves the problem for me for now.

Note that the 'sage-plots-for-…' plot folder is also put in the main user directory. In order to get the plot folder into the current local directory, look in sagetex.py and replace the line

    self.plotdir = age-plots-for-' + jobname + '.tex'

with

  localdir = "/".join((traceback.extract_stack(limit=2)[0][0][0:-11]).split("/")[:-1])
     self.plotdir = localdir+'/sage-plots-for-' + jobname + '.tex'

I ran into the same problem with Sage Version 5.9-OSX-64bit-10.8. Previous versions from a couple of years ago worked fine. Sagetex seems to lose track of the directory of the LaTeX file, so the two files mentioned above are placed in the user's home directory instead of the directory where the LaTeX file is located. If

There must be a better solution, but here is a hack that works by replacing three lines in sagetex.py, found in /Applications/Sage-5.9-OSX-64bit-10.8.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py on my Mac.

Near the end of sagetex.py are three lines separated by other code:

   sagef = open(self.filename + '.sagetex.sage', 'r')
   ...
   os.rename(self.filename + '.sagetex.sout.tmp', self.filename + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', self.filename + '.sagetex.scmd')

Replace each of these lines by the corresponding line below:

   sagef = open(traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sage', 'r')
   …
   os.rename(self.filename + '.sagetex.sout.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.scmd')

I use the Python traceback module to identify the full path+filename of the script that calls sagetex.py, and then I strip the extension (".sagetex.sage") from this to provide the base to construct the necessary correct full filenames. This is neither elegant nor necessarily robust, but it solves the problem for me for now.now. You made need to modify the solution depending on the file structure and notation of your system.

Note that the 'sage-plots-for-…' plot folder is also put in the main user directory. In order to get the plot folder into the current local directory, look in sagetex.py and replace the line

    self.plotdir = age-plots-for-' + jobname + '.tex'

with

    localdir = "/".join((traceback.extract_stack(limit=2)[0][0][0:-11]).split("/")[:-1])
    self.plotdir = localdir+'/sage-plots-for-' + jobname + '.tex'

I ran into the same problem with Sage Version 5.9-OSX-64bit-10.8. Previous versions from a couple of years ago worked fine. Sagetex seems to lose track of the directory of the LaTeX file, so the two files mentioned above are placed in the user's home directory instead of the directory where the LaTeX file is located. If

There must be a better solution, but here is a hack that works by replacing three lines in sagetex.py, found in /Applications/Sage-5.9-OSX-64bit-10.8.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py on my Mac.

Near the end of sagetex.py are three lines separated by other code:

   sagef = open(self.filename + '.sagetex.sage', 'r')
   ...
   os.rename(self.filename + '.sagetex.sout.tmp', self.filename + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', self.filename + '.sagetex.scmd')

Replace each of these lines by the corresponding line below:

   sagef = open(traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sage', 'r')
   …
   os.rename(self.filename + '.sagetex.sout.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.scmd')

I use the Python traceback module to identify the full path+filename of the script that calls sagetex.py, and then I strip the extension (".sagetex.sage") from this to provide the base to construct the necessary correct full filenames. This is neither elegant nor necessarily robust, but it solves the problem for me for now. You made need to modify the solution depending on the file structure and notation of your system.

Note that the 'sage-plots-for-…' plot folder is also put in the main user directory. In order to get the plot folder into the current local directory, look in sagetex.py and replace the line

    self.plotdir = age-plots-for-' 'sage-plots-for-' + jobname + '.tex'

with

    localdir = "/".join((traceback.extract_stack(limit=2)[0][0][0:-11]).split("/")[:-1])
    self.plotdir = localdir+'/sage-plots-for-' + jobname + '.tex'