Rob Managan avatar Rob Managan committed ac36196

Update path information for OSX.
If one of the tools that use TeX applications is generated
add the paths in /etc/paths and /etc/paths.d
version 10.5 (Leopard)

Comments (0)

Files changed (38)

 
     - Added support for the bibunits package so we call bibtex on all
       the bu*.aux files.
+      
+    - Add support of finding path information on OSX for TeX applications
+      MacPorts and Fink paths need to be added by the user
 
   From Russel Winder:
 

src/engine/SCons/Platform/darwin.py

 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import posix
+import os
 
 def generate(env):
     posix.generate(env)
     env['SHLIBSUFFIX'] = '.dylib'
-    env['ENV']['PATH'] = env['ENV']['PATH'] + ':/sw/bin'
+    # put macports paths at front to override Apple's versions, fink path is after
+    # For now let people who want Macports or Fink tools specify it!
+    # env['ENV']['PATH'] = '/opt/local/bin:/opt/local/sbin:' + env['ENV']['PATH'] + ':/sw/bin'
+    
+    # Store extra system paths in env['ENV']['PATHOSX']
+    
+    filelist = ['/etc/paths',]
+    # make sure this works on Macs with Tiger or earlier
+    try:
+        dirlist = os.listdir('/etc/paths.d')
+    except:
+        dirlist = []
+
+    for file in dirlist:
+        filelist.append('/etc/paths.d/'+file)
+
+    for file in filelist:
+        if os.path.isfile(file):
+            f = open(file, 'r')
+            lines = f.readlines()
+            for line in lines:
+                if line:
+                    env.AppendENVPath('PATHOSX', line.strip('\n'))
+            f.close()
 
 # Local Variables:
 # tab-width:4

src/engine/SCons/Tool/dvipdf.py

     env['PDFCOM']      = ['$DVIPDFCOM']
 
 def exists(env):
+    SCons.Tool.tex.generate_darwin(env)
     return env.Detect('dvipdf')
 
 # Local Variables:

src/engine/SCons/Tool/dvips.py

     env['PSSUFFIX'] = '.ps'
 
 def exists(env):
+    SCons.Tool.tex.generate_darwin(env)
     return env.Detect('dvips')
 
 # Local Variables:

src/engine/SCons/Tool/latex.py

     SCons.Tool.tex.generate_common(env)
 
 def exists(env):
+    SCons.Tool.tex.generate_darwin(env)
     return env.Detect('latex')
 
 # Local Variables:

src/engine/SCons/Tool/pdflatex.py

     SCons.Tool.tex.generate_common(env)
 
 def exists(env):
+    SCons.Tool.tex.generate_darwin(env)
     return env.Detect('pdflatex')
 
 # Local Variables:

src/engine/SCons/Tool/pdftex.py

     SCons.Tool.tex.generate_common(env)
 
 def exists(env):
+    SCons.Tool.tex.generate_darwin(env)
     return env.Detect('pdftex')
 
 # Local Variables:

src/engine/SCons/Tool/tex.py

     bld.add_action('.tex', TeXLaTeXAction)
     bld.add_emitter('.tex', tex_eps_emitter)
 
+def generate_darwin(env):
+    try:
+        environ = env['ENV']
+    except KeyError:
+        environ = {}
+        env['ENV'] = environ
+    
+    if (platform.system() == 'Darwin'):
+        try:
+            ospath = env['ENV']['PATHOSX']
+        except:
+            ospath = None
+        if ospath:
+            env.AppendENVPath('PATH', ospath)
+
 def generate_common(env):
     """Add internal Builders and construction variables for LaTeX to an Environment."""
 
+    # Add OSX system paths so TeX tools can be found
+    # when a list of tools is given the exists() method is not called
+    generate_darwin(env)
+
     # A generic tex file Action, sufficient for all tex files.
     global TeXAction
     if TeXAction is None:
     if MakeAcronymsAction is None:
         MakeAcronymsAction = SCons.Action.Action("$MAKEACRONYMSCOM", "$MAKEACRONYMSCOMSTR")
 
+    try:
+        environ = env['ENV']
+    except KeyError:
+        environ = {}
+        env['ENV'] = environ
+
+    # Some Linux platforms have pdflatex set up in a way
+    # that requires that the HOME environment variable be set.
+    # Add it here if defined.
+    v = os.environ.get('HOME')
+    if v:
+        environ['HOME'] = v
+
     CDCOM = 'cd '
     if platform.system() == 'Windows':
         # allow cd command to change drives on Windows
     env['MAKENCLCOM']   = CDCOM + '${TARGET.dir} && $MAKENCL ${SOURCE.filebase}.nlo $MAKENCLFLAGS -o ${SOURCE.filebase}.nls'
 
 def exists(env):
+    generate_darwin(env)
     return env.Detect('tex')
 
 # Local Variables:

test/TEX/LATEX2.py

 
     test.write('SConstruct', """
 import os
-ENV = { 'PATH' : os.environ['PATH'],
-        'TEXINPUTS' : [ os.environ.get('TEXINPUTS', '') ] }
-foo = Environment(ENV = ENV)
-foo['TEXINPUTS'] = ['subdir',]
+foo = Environment()
+foo['TEXINPUTS'] = ['subdir',os.environ.get('TEXINPUTS', '')]
 foo.PDF(source = ['foo.ltx','bar.latex','makeindex.tex','latexi.tex'])
 """ % locals())
 

test/TEX/auxiliaries.py

 test.write(['SConstruct'], """\
 import os
 env = Environment(tools = ['pdftex', 'dvipdf', 'dvips', 'tex', 'latex'],
-                  ENV = {'PATH' : os.environ['PATH']},
                   BUILD_DIR = '#build/docs')
 
 # Use 'duplicate=1' because LaTeX toolchain does not work properly for

test/TEX/bibliography.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(tools = ['tex', 'latex', 'dvips'],ENV = {'PATH' : os.environ['PATH']})
+env = Environment(tools = ['tex', 'latex', 'dvips'])
 env.PostScript('simple', 'simple.tex')
 """)
 

test/TEX/bibtex-latex-rerun.py

 
 test.write(['SConstruct'], """\
 import os
-env = Environment(tools=['pdftex', 'tex'],ENV = {'PATH' : os.environ['PATH']})
+env = Environment(tools=['pdftex', 'tex'])
 env.PDF( 'bibtest.tex' )
 """)
 

test/TEX/clean.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(tools = ['tex', 'latex'],
-                  ENV = {'PATH' : os.environ['PATH']})
+env = Environment(tools = ['tex', 'latex'])
 env.DVI( "foo.ltx" )
 """)
 

test/TEX/configure.py

     return is_ok
 
 import os
-ENV = { 'PATH' : os.environ['PATH'] }
-env = Environment(ENV = ENV)
+env = Environment()
 env['TEXINPUTS'] = '.'
 conf = Configure( env, custom_tests={'CheckLModern' : CheckLModern} )
 conf.CheckLModern()

test/TEX/dryrun.py

 
 test.write('SConstruct', """
 import os
-ENV = { 'PATH' : os.environ['PATH'] }
-foo = Environment(ENV = ENV)
+foo = Environment()
 foo.DVI(target = 'foo.dvi', source = 'foo.ltx')
 """ % locals())
 

test/TEX/eps_graphics.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
+env = Environment()
 
 test = env.DVI(source='docs/test.tex')
 """)

test/TEX/eps_graphics2.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
+env = Environment()
 
 env.PDF('docs/Fig1.eps')
 test = env.PDF(source='docs/test.tex')

test/TEX/generated_files.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
+env = Environment()
 
 copy_latex = Builder(action=Copy('$TARGET', '$SOURCE'),
                      suffix='.tex',

test/TEX/glossaries.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(ENV = {'PATH' : os.environ['PATH'],
-                         'HOME' : os.environ['HOME']})
+env = Environment()
 env.PDF('glossaries', 'glossaries.tex')
 """)
 

test/TEX/input_docClass.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
+env = Environment()
 
 test = env.PDF(source='test.tex')
 """)

test/TEX/lstinputlisting.py

 test.write(['SConstruct'], """\
 import os
 
-DefaultEnvironment(ENV={'PATH':os.environ['PATH']})
+DefaultEnvironment()
 
 PDF("test.tex")
 """)

test/TEX/makeindex.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex'],
-                  ENV = {'PATH' : os.environ['PATH']})
+env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex'])
 env.PDF( "no_index.tex" )
 env.PDF( "simple.tex" )
 """)

test/TEX/multi-line_include_options.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
+env = Environment()
 env.DVI('root.tex')
 """)
 

test/TEX/multi-run.py

 
     test.write(['work1', 'SConstruct'], """\
 import os
-env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex'],
-                  ENV = {'PATH' : os.environ['PATH']})
+env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex'])
 env.DVI( "foo.tex" )
 env.PDF( "foo.tex" )
 """)

test/TEX/multiple_include.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
+env = Environment()
 
 env.PDF('Fig1.ps')
 test = env.PDF(source='test.tex')

test/TEX/multiple_include_subdir.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
+env = Environment()
 
 env.PDF('docs/Fig1.eps')
 test = env.PDF(source='docs/test.tex')

test/TEX/nomencl.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(tools = ['pdftex'], ENV = {'PATH' : os.environ['PATH']})
+env = Environment(tools = ['pdftex'])
 env.PDF('nomencl', 'nomencl.tex')
 """)
 

test/TEX/rename_result.py

 
 test.write('SConstruct', """
 import os
-ENV = { 'PATH' : os.environ['PATH'],
-        'TEXINPUTS' : [ 'subdir', os.environ.get('TEXINPUTS', '') ] }
-foo = Environment(ENV = ENV)
+foo = Environment()
+foo['TEXINPUTS'] = [ 'subdir', os.environ.get('TEXINPUTS', '') ]
 foo.DVI(target = 'foobar.dvi', source = 'foo.ltx')
 foo.PDF(target = 'bar.xyz', source = 'bar.ltx')
 """ % locals())

test/TEX/subdir-as-include.py

 test.write('SConstruct', """\
 import os
 
-# I need PATH to allow TeX tools to be found on my desktop Mac
-# and HOME to let them work properly on my work mainframe
-env = Environment(ENV = {'PATH' : '/usr/texbin:/usr/local/bin:/opt/bin:/bin:/usr/bin:/sw/bin',
-                         'HOME' : os.environ['HOME']})
+env = Environment()
 env.DVI('root.tex')
 """)
 

test/TEX/subdir-input.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(TOOLS = ['tex', 'pdftex'], ENV = {'PATH' : os.environ['PATH']})
+env = Environment(TOOLS = ['tex', 'pdftex'])
 env.PDF( 'sub/x.tex' )
 env.DVI( 'sub/x.tex' )
 """)

test/TEX/subdir_variantdir_include.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(TOOLS = ['tex', 'pdftex'],ENV = {'PATH' : os.environ['PATH']})
+env = Environment(TOOLS = ['tex', 'pdftex'])
 
 env.VariantDir('build', 'docs',duplicate=0)
 env.SConscript('build/SConscript', exports = ['env'])

test/TEX/subdir_variantdir_include2.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(TOOLS = ['tex', 'pdftex'],ENV = {'PATH' : os.environ['PATH']})
+env = Environment(TOOLS = ['tex', 'pdftex'])
 
 env.VariantDir('build', 'docs', duplicate=0)
 pdf = env.PDF('build/main.tex')

test/TEX/subdir_variantdir_input.py

 
 test.write('SConstruct', """\
 import os
-env = Environment(TOOLS = ['tex', 'pdftex'],ENV = {'PATH' : os.environ['PATH']})
+env = Environment(TOOLS = ['tex', 'pdftex'])
 
 env.VariantDir('build', 'docs',duplicate=0)
 env.SConscript('build/SConscript', exports = ['env'])

test/TEX/usepackage.py

 
 test.write('SConstruct', """
 import os
-ENV = { 'PATH' : os.environ['PATH'],
-        'TEXINPUTS' : [ 'subdir', os.environ.get('TEXINPUTS', '') ] }
-foo = Environment(ENV = ENV)
+foo = Environment()
+foo['TEXINPUTS'] = [ 'subdir', os.environ.get('TEXINPUTS', '') ]
 foo.DVI(target = 'foo.dvi', source = 'foo.ltx')
 """ % locals())
 

test/TEX/variant_dir.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] },
-                  TOOLS = ['tex', 'latex', 'dvipdf'])
+env = Environment(TOOLS = ['tex', 'latex', 'dvipdf'])
 Export(['env'])
 
 SConscript(os.path.join('docs', 'SConscript'),

test/TEX/variant_dir_bibunit.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
+env = Environment()
 Export(['env'])
 
 env.SConscript(os.path.join('src', 'SConscript'),

test/TEX/variant_dir_dup0.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] },
-                  TOOLS = ['tex', 'latex', 'dvipdf'])
+env = Environment(TOOLS = ['tex', 'latex', 'dvipdf'])
 Export(['env'])
 
 SConscript(os.path.join('docs', 'SConscript'),

test/TEX/variant_dir_style_dup0.py

 test.write(['SConstruct'], """\
 import os
 
-env = Environment(ENV = { 'PATH' : os.environ['PATH'] },
-                  TOOLS = ['tex', 'latex', 'dvipdf'])
+env = Environment(tools = ['tex', 'latex', 'dvipdf'])
 copy_latex = Builder(action=Copy('$TARGET', '$SOURCE'),
                      suffix='.tex',
                      src_suffix='.src')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.