[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[eLyXer-users] Re: Loading eLyXer as a module

From: Uwe Stöhr
Subject: [eLyXer-users] Re: Loading eLyXer as a module
Date: Thu, 05 Nov 2009 02:57:38 +0100
User-agent: Thunderbird (Windows/20090812)

Alex Fernandez schrieb:

Ugh. So this solution is not nice. Let us try a different one: install
elyxer.py to your desired location, the scripts directory:
and then add the scripts directory to the python runtime path:
This should add the elyxer.py file to the installed Python modules.

OK, doing this adds this path to the pythonpath. Note the setting the PYTHONPATH definitely requires admin permissions because the path is written to the HKLM section in the registry.
But this call still fails:
python elyxer.py
Gives: no such file 'elyxer.py'
So PYTHONPATH is no solution.

Now I installed eLyXer as module. But when I call
python elyxer.py
I get the same error.
When I call
python -m elyxer
It works. I found out that adding a module is possible without admin permissions, but this won't work with my stripped-down python. But it sees that I only install it as module when Python is completely installed.
But please give me more time to verify this on my other test systems.

So the module solution seem to be possible!

As additional test I now added the path to the elyxer.py file to the global 
PATH variable. But
python elyxer.py
still fails.

When I only call
it works, when the elyxer.py is not in a path with spaces, otherwise it fails. The -tt option is really needed although I don't know why.

This is the case on WinXP and also on WinXP 64-bit (aka Windows 2003).


Concerning your patch for configure.py: I get the error that the variable or command "logger" is not defined. But it works when I comment out the two lines containing logger.

Attached is my patch for the current configure.py file that works for me.

regards Uwe
Index: configure.py
--- configure.py        (revision 31852)
+++ configure.py        (working copy)
@@ -247,6 +247,16 @@
     return ''
+def checkModule(module):
+    ''' Check for a Python module, return the status '''
+    msg = 'checking for "' + module + ' module"... '
+    try:
+      __import__(module)
+      return True
+    except ImportError:
+      return False
 def checkFormatEntries(dtl_tools):  
     ''' Check all formats (\Format entries) '''
     checkViewer('a Tgif viewer and editor', ['tgif'],
@@ -388,10 +398,17 @@
     checkProg('an MS Word -> LaTeX converter', ['wvCleanLatex $$i $$o'],
         rc_entry = [ r'\converter word       latex      "%%"   ""' ])
-    #
-    path, elyxer = checkProg('a LyX -> HTML converter', ['elyxer.py', 
-      rc_entry = [ r'\converter lyx      html       "python -tt 
$$s/scripts/elyxer.py --directory $$r $$i $$o" ""' ])
-    if elyxer.find('elyxer') >= 0:
+    # eLyXer: search as a Python module and then as an executable (elyxer.py, 
+    elyxerfound = checkModule('elyxer')
+    if elyxerfound:
+      addToRC(r'''\converter lyx      html       "python -m elyxer --directory 
$$r $$i $$o"    ""''')
+    else:
+      path, elyxer = checkProg('a LyX -> HTML converter', ['elyxer.py', 
+        rc_entry = [ r'\converter lyx      html       "python -tt elyxer.py 
--directory $$r $$i $$o"   ""' ])
+      if elyxer.find('elyxer') >= 0:
+        elyxerfound = True
+    if elyxerfound:
       addToRC(r'''\copier    html       "python -tt $$s/scripts/ext_copy.py -e 
html,png,jpg,jpeg,css $$i $$o"''')
       # On SuSE the scripts have a .sh suffix, and on debian they are in 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]