Skip to content

Commit bf6c233

Browse files
author
Release Manager
committed
gh-34995: Support for tachyon >= 0.99.2 Taken from #23712. This is necessary to support tachyon >= 0.99.2, without losing support for older versions of tachyon. In case #23712 gets delayed, it'd be nice to include this so nothing breaks if system tachyon is updated. This is the first commit from the branch there which already had positive review (the actual update of tachyon has an issue mentioned in #23712 (comment).) _From the commit log:_ In tachyon 0.99.2 the keyword `focallength` was changed to `focaldist`. To support it, when running on version >= 0.99.2 we "patch" the model as constructed by class `sage.plot.plot3d.tachyon.Tachyon`. In the future (possibly when tachyon in sage gets upgraded), all the focallength occurences in sage.plot.plot3d.tachyon can be replaced by focaldist for consistency with new tachyon, and the logic here can be reversed (i.e. patch the model when self.version() < '0.99.2') or just drop support for old versions. URL: #34995 Reported by: Gonzalo Tornaría Reviewer(s): Matthias Köppe, Mauricio Collares
2 parents 23ab380 + 2252d38 commit bf6c233

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/sage/interfaces/tachyon.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,14 @@
683683
#*****************************************************************************
684684

685685
import os
686+
import re
686687

687688
from sage.cpython.string import bytes_to_str
688689
from sage.misc.pager import pager
689690
from sage.misc.superseded import deprecation
690691
from sage.misc.temporary_file import tmp_filename
691692
from sage.structure.sage_object import SageObject
693+
from sage.misc.cachefunc import cached_method
692694

693695

694696
class TachyonRT(SageObject):
@@ -799,6 +801,11 @@ def __call__(self, model, outfile='sage.png', verbose=1, extra_opts=''):
799801
Parser failed due to an input file syntax error.
800802
Aborting render.
801803
"""
804+
if self.version() >= '0.99.2':
805+
# this keyword was changed in 0.99.2
806+
model = model.replace(
807+
" focallength ",
808+
" focaldist ")
802809
modelfile = tmp_filename(ext='.dat')
803810
with open(modelfile, 'w') as file:
804811
file.write(model)
@@ -851,6 +858,25 @@ def usage(self, use_pager=True):
851858
else:
852859
print(r)
853860

861+
@cached_method
862+
def version(self):
863+
"""
864+
Returns the version of the Tachyon raytracer being used.
865+
866+
TESTS::
867+
868+
sage: tachyon_rt.version() # random
869+
0.98.9
870+
sage: tachyon_rt.version() >= '0.98.9'
871+
True
872+
"""
873+
with os.popen('tachyon') as f:
874+
r = f.readline()
875+
res = re.search(r"Version ([\d.]*)", r)
876+
# debian patches tachyon so it won't report the version
877+
# we hardcode '0.99' since that's indeed the version they ship
878+
return res[1] if res else '0.99'
879+
854880
def help(self, use_pager=True):
855881
"""
856882
Deprecated: type 'sage.interfaces.tachyon?' for help

0 commit comments

Comments
 (0)