[Scons-users] LaTeX documentation

Carnë Draug carandraug+dev at gmail.com
Fri Feb 1 17:05:53 EST 2013


On 31 January 2013 20:47, Managan, Rob <managan1 at llnl.gov> wrote:

> For your question on partial builds, e.g. only figures, the approach I use

> is to use an alias. That defines a target that forces a list of nodes to

> be built. Nodes are the result of a builder or a specify file. See

> http://www.scons.org/doc/production/HTML/scons-user/c4457.html for more

> details.

>

> MyFig1 = env.PDF(target='myFigure1',source="file1.eps")

> MyFig2 = env.PDF(target='myFigure2',source="file2.eps")

>

>

> Alias('buildFigures', [MyFig1, MyFig2])

>

> Then

> "scons buildFigures" should build both figures.


I am not sure I understand how this works but seems to do so. Is it
possible to use them to actually run a command instead of making a
build?


> As far as configuring packages go this is what I use (this is all pretty

> old so there may be a more modern way to do it):

>

> #----------------

> # 'lmodern' package for LaTeX available?

>

> lmodern_test_text = r"""

> \documentclass{article}

> \usepackage{lmodern}

> \title{Cartesian closed categories and the price of eggs}

> \author{Jane Doe}

> \date{September 1994}

> \begin{document}

> \maketitle

> Hello world!

> \end{document}

> """

>

> def CheckLModern(context):

> context.Message("Checking for lmodern...")

> try:

> b = context.env.DVI

> except AttributeError:

> return False

> is_ok = context.TryBuild(b,lmodern_test_text,'.tex')

> context.Result(is_ok)

> return is_ok

>

> conf = Configure(env, { "CheckLModern":CheckLModern

> },config_dir,config_log)

>

> # Example of how to check for Latex packages

> ret = conf.CheckLModern()

> # modify the environment based on the returned value

>

>

>

> I think you will find that you need to slowly add to your Sconstruct and

> Sconscripts adding one functionality at a time. They may get fairly

> complex over time so go at it slowly and comment everything!


Python's not really my language but using your example, I managed to
write a function that returns tests for a list of package names It
won't test functionalities, only a package presence but it's still
better than nothing. Hopefully will be useful to someone.

def BuildPackageTest(package):
package_test_text =
"\documentclass{article}\n\usepackage{%s}\n\\begin{document}\n\end{document}"
% package
def PackageTest(context):
context.Message("Checking for LaTeX package %s..." % package)
try:
b = context.env.PDF
except AttributeError:
return False
is_ok = context.TryBuild(b, package_test_text, '.tex')
context.Result(is_ok)
return is_ok
return PackageTest

required_packages = ["graphicx", "multirow", "url", "todonotes", "natbib"]
package_tests = dict()
for package in required_packages:
package_tests[package] = BuildPackageTest(package)

conf = Configure(env, package_tests)

for package in required_packages:
if not getattr(conf, package)():
print "Unable to find required LaTeX package %s" % package
Exit(1)

env = conf.Finish()

Thank you very much.


More information about the Scons-users mailing list