Re: Python version of configure script (preview version)

2005-09-19 Thread Lars Gullik Bjønnes
Jose' Matos [EMAIL PROTECTED] writes:

| On Thursday 15 September 2005 20:58, Bo Peng wrote:
|  Dear list,
| 
|  Attached is a Python version of the configure script. I currently do
|  not have access to a windows machine with lyx on so I can not test it
|  on windows. On my linux machine, it produces identical lyxrc.default
|  and doc/LaTeXConfig.lyx but no further testing/proof-read of the code
|  has been done.
| 
|   World is a small place, really. I have seen your contributions around 
| several places lately (R, rpy, ...) :-)
| 
|   What is the minimum required python version for your script?
|   As Angus said we are still aiming to python 1.5.2 compatibility, not 
| something that I like but something necessary to deal with older systems.
| 
|   This is probably archaic as one of the last linux distributions to carry 
| python 1.5.2 was Red Hat 7.3 release released in May 2002.
| 
|   Another option would be to update the requirements of python for lyx 1.4.x 
| for x0.

This script is not for 1.4 anyway.

leave 1.5 as requirement for 1.4 , go for 2.x for 1.5.

-- 
Lgb



Re: Python version of configure script (preview version)

2005-09-19 Thread Jean-Marc Lasgouttes
 Bo == Bo Peng [EMAIL PROTECTED] writes:

 Not if you use start as viewer of any file that is supported by
 windows (the problem is to discover that).

Bo start is a DOS command (as far as I know). In a cmd windows, start
Bo can open a file using its associated application. However, I tried
Bo to use start $$i or cmd /c start $$i for pdf format and did
Bo not get it work. A shell window is started instead.

Mingw comes with a small 'start' script which should be a good
starting point.

 Could you point us to the API? I found ShellExecute, but I did not
 find a way to tell whether a file format is handled.

Bo I am not quite sure. There are ShellExecute, ShellExecuteEx,
Bo WinExec. According to
Bo 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp
Bo , ShellExecute should just work. A 32 return value indicates
Bo failure to open a file, but this is not lyx' fault so we do not
Bo have to worry about it.

So there is no real way to know whether a file type is supported. One
has to provide a real file for the function to work. What would be
nice is an equivalent of the assoc/ftype windows commands.

JMarc


Re: Python version of configure script (preview version)

2005-09-19 Thread chr
On Sun, 18 Sep 2005, Bo Peng wrote:

I know, we have decided to proceed since this code is supposed to be only
  run in windows and there the above argument does not apply. I would guess
  that every new install will have at least python 2.3 installed. :-)
  
 
 This solves the problem by now but what if we want to add some new
 features to configure/configure.py in the future? It does not sound
 like an awfully good idea to maintain two versions of the same thing.
 Finding a redhat 7.3 machine and backport configure.py may be a better
 idea.

I run RH 7.3 on a laptop at home. If you'd like I could test it (just let
me know what to do).

/C

-- 
Christian Ridderström, +46-8-768 39 44   http://www.md.kth.se/~chr




Re: Python version of configure script (preview version)

2005-09-19 Thread Angus Leeming
[EMAIL PROTECTED] wrote:

 On Sun, 18 Sep 2005, Bo Peng wrote:
 
I know, we have decided to proceed since this code is supposed to be
only
  run in windows and there the above argument does not apply. I would
  guess that every new install will have at least python 2.3 installed.
  :-)
  
 
 This solves the problem by now but what if we want to add some new
 features to configure/configure.py in the future? It does not sound
 like an awfully good idea to maintain two versions of the same thing.
 Finding a redhat 7.3 machine and backport configure.py may be a better
 idea.

 I run RH 7.3 on a laptop at home. If you'd like I could test it (just let
 me know what to do).

LYXLIB=$HOME/lyx/devel/lib
LYXBUILDLIB=$HOME/lyx/devel/build/lib
mkdir bopeng  cd bopeng
cp $LYXLIB/configure.py .
cp $LYXLIB/chkconfig.ltx .
mkdir -p doc
cp $LYXLIB/doc/*Config.lyx.in doc
python ./configure.py
sed 's/TAB/ /g;s/ \{1,\}/ /g' $LYXBUILDLIB/lyxrc.defaults | \
   sort  lyxrc_orig_sorted
sed 's/TAB/ /g;s/ \{1,\}/ /g' lyxrc.defaults | \
   sort lyxrc_bopeng_sorted
diff -u lyxrc_orig_sorted lyxrc_bopeng_sorted | cat -e

You'll need to replace TAB in the sed expressions with a literal tab
character, Cntl-VCntl-I. You'll also need to adjust the LYXLIB and
LYXBUILDLIB variables of course.

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-19 Thread Bo Peng
 I run RH 7.3 on a laptop at home. If you'd like I could test it (just let
 me know what to do).
 

You first need to replace all A += B to A = A + B, and replace any
str.count(), str.replace() with something equivalent in 1.5.2. (I do
not know what they are since I never used them.) Since you do not have
to touch the cygwin/tmpfile part, the rest of the code seem to be
pretty back-compatible.

Besides lyxrc.default, you would better also compare doc/Config.lyx .

Thank you for your help.
Bo


Re: Python version of configure script (preview version)

2005-09-19 Thread chr
On Mon, 19 Sep 2005, Bo Peng wrote:

  I run RH 7.3 on a laptop at home. If you'd like I could test it (just let
  me know what to do).
 
 You first need to replace all A += B to A = A + B, and replace any
 str.count(), str.replace() with something equivalent in 1.5.2. (I do
 not know what they are since I never used them.) Since you do not have
 to touch the cygwin/tmpfile part, the rest of the code seem to be
 pretty back-compatible.
 
 Besides lyxrc.default, you would better also compare doc/Config.lyx .
 
 Thank you for your help.

Um.. I think the info I need is a bit more basic than so... For instance,
can I just run the script with some arguments?  Where can I get the
script (can I use the CVS browser)?

/Christian

-- 
Christian Ridderström, +46-8-768 39 44   http://www.md.kth.se/~chr



Re: Python version of configure script (preview version)

2005-09-19 Thread Bo Peng
 Um.. I think the info I need is a bit more basic than so... For instance,
 can I just run the script with some arguments?  Where can I get the
 script (can I use the CVS browser)?

You need to get the latest cvs. configure.py is under the lib
directory. You can run it without any argument.

If you only need the file, it is at
http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/lib/configure.py.

Bo


Re: Python version of configure script (preview version)

2005-09-19 Thread Lars Gullik Bjønnes
Bo Peng [EMAIL PROTECTED] writes:

|  Um.. I think the info I need is a bit more basic than so... For instance,
|  can I just run the script with some arguments?  Where can I get the
|  script (can I use the CVS browser)?
| 
| You need to get the latest cvs. configure.py is under the lib
| directory. You can run it without any argument.

and it is not supported.

Please please do not put to much effort into this before 1.4.

-- 
Lgb



Re: Python version of configure script (preview version)

2005-09-19 Thread Jean-Marc Lasgouttes
 Lars == Lars Gullik Bjønnes [EMAIL PROTECTED] writes:

Lars This script is not for 1.4 anyway.

Lars leave 1.5 as requirement for 1.4 , go for 2.x for 1.5.

Note that we may want to go to the python version for some 1.4.x (x0)
version, especially since it will help packaging on windows.

We'll see.

JMarc


Re: Python version of configure script (preview version)

2005-09-19 Thread chr
On Mon, 19 Sep 2005, Jean-Marc Lasgouttes wrote:

  Lars == Lars Gullik Bjønnes [EMAIL PROTECTED] writes:
 
 Lars This script is not for 1.4 anyway.
 
 Lars leave 1.5 as requirement for 1.4 , go for 2.x for 1.5.
 
 Note that we may want to go to the python version for some 1.4.x (x0)
 version, especially since it will help packaging on windows.
 
 We'll see.

I'm not sure if this is true for general RH 7.3 installations, but mine 
has these versions of python installed:

-rwxr-xr-x2 root root   411244 Apr  4  2002 /usr/bin/python*
-rwxr-xr-x2 root root   411244 Apr  4  2002 /usr/bin/python1.5*
-rwxr-xr-x2 root root   875272 Apr 12  2002 /usr/bin/python2*
-rwxr-xr-x2 root root   875272 Apr 12  2002 /usr/bin/python2.2*

Is it still necessary to test with 1.5 then? (why not just require any
RH7.3 users to install python 2.2??)

/Christian


-- 
Christian Ridderström, +46-8-768 39 44   http://www.md.kth.se/~chr




Re: Python version of configure script (preview version)

2005-09-19 Thread Georg Baum
[EMAIL PROTECTED] wrote:

 On Mon, 19 Sep 2005, Jean-Marc Lasgouttes wrote:
 
  Lars == Lars Gullik Bjønnes
  [EMAIL PROTECTED] writes:
 
 Lars This script is not for 1.4 anyway.
 
 Lars leave 1.5 as requirement for 1.4 , go for 2.x for 1.5.
 
 Note that we may want to go to the python version for some 1.4.x (x0)
 version, especially since it will help packaging on windows.
 
 We'll see.
 
 I'm not sure if this is true for general RH 7.3 installations, but mine
 has these versions of python installed:
 
 -rwxr-xr-x2 root root   411244 Apr  4  2002 /usr/bin/python*
 -rwxr-xr-x2 root root   411244 Apr  4  2002
 /usr/bin/python1.5*
 -rwxr-xr-x2 root root   875272 Apr 12  2002 /usr/bin/python2*
 -rwxr-xr-x2 root root   875272 Apr 12  2002
 /usr/bin/python2.2*
 
 Is it still necessary to test with 1.5 then? (why not just require any
 RH7.3 users to install python 2.2??)

No, it is not (see the comments by Lars and Jean-Marc above). We'll have the
requirement of python 2.x anyway when configure.py finally replaces
configure.m4.


Georg




Re: Python version of configure script (preview version)

2005-09-19 Thread Jose' Matos
On Monday 19 September 2005 16:46, Georg Baum wrote:
 No, it is not (see the comments by Lars and Jean-Marc above). We'll have
 the requirement of python 2.x anyway when configure.py finally replaces
 configure.m4.

  Since we call python trough lyx we could easily have a defined variable to 
say which python to use. Naturally this choice would be off by default, if 
the system python is OK, there should be nothing to do.

  This could in preferences, or any other place... I am not sure if this 
worth...

 Georg

-- 
José Abílio


Re: Python version of configure script (preview version)

2005-09-19 Thread chr
On Mon, 19 Sep 2005, Georg Baum wrote:

 No, it is not (see the comments by Lars and Jean-Marc above). We'll have
 the requirement of python 2.x anyway when configure.py finally replaces
 configure.m4.

Ok, I'll leave it then. 

/C

-- 
Christian Ridderström, +46-8-768 39 44   http://www.md.kth.se/~chr




Re: Python version of configure script (preview version)

2005-09-19 Thread Lars Gullik Bjønnes
"Jose' Matos" <[EMAIL PROTECTED]> writes:

| On Thursday 15 September 2005 20:58, Bo Peng wrote:
| > Dear list,
| >
| > Attached is a Python version of the configure script. I currently do
| > not have access to a windows machine with lyx on so I can not test it
| > on windows. On my linux machine, it produces identical lyxrc.default
| > and doc/LaTeXConfig.lyx but no further testing/proof-read of the code
| > has been done.
| 
|   World is a small place, really. I have seen your contributions around 
| several places lately (R, rpy, ...) :-)
| 
|   What is the minimum required python version for your script?
|   As Angus said we are still aiming to python 1.5.2 compatibility, not 
| something that I like but something necessary to deal with older systems.
| 
|   This is probably archaic as one of the last linux distributions to carry 
| python 1.5.2 was Red Hat 7.3 release released in May 2002.
| 
|   Another option would be to update the requirements of python for lyx 1.4.x 
| for x>0.

This script is not for 1.4 anyway.

leave 1.5 as requirement for 1.4 , go for 2.x for 1.5.

-- 
Lgb



Re: Python version of configure script (preview version)

2005-09-19 Thread Jean-Marc Lasgouttes
> "Bo" == Bo Peng <[EMAIL PROTECTED]> writes:

>> Not if you use "start" as viewer of any file that is supported by
>> windows (the problem is to discover that).

Bo> start is a DOS command (as far as I know). In a cmd windows, start
Bo> can open a file using its associated application. However, I tried
Bo> to use "start $$i" or "cmd /c start $$i" for pdf format and did
Bo> not get it work. A shell window is started instead.

Mingw comes with a small 'start' script which should be a good
starting point.

>> Could you point us to the API? I found ShellExecute, but I did not
>> find a way to tell whether a file format is handled.

Bo> I am not quite sure. There are ShellExecute, ShellExecuteEx,
Bo> WinExec. According to
Bo> 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp
Bo> , ShellExecute should just work. A <32 return value indicates
Bo> failure to open a file, but this is not lyx' fault so we do not
Bo> have to worry about it.

So there is no real way to know whether a file type is supported. One
has to provide a real file for the function to work. What would be
nice is an equivalent of the assoc/ftype windows commands.

JMarc


Re: Python version of configure script (preview version)

2005-09-19 Thread chr
On Sun, 18 Sep 2005, Bo Peng wrote:

> >   I know, we have decided to proceed since this code is supposed to be only
> > run in windows and there the above argument does not apply. I would guess
> > that every new install will have at least python 2.3 installed. :-)
> > 
> 
> This solves the problem by now but what if we want to add some new
> features to configure/configure.py in the future? It does not sound
> like an awfully good idea to maintain two versions of the same thing.
> Finding a redhat 7.3 machine and backport configure.py may be a better
> idea.

I run RH 7.3 on a laptop at home. If you'd like I could test it (just let
me know what to do).

/C

-- 
Christian Ridderström, +46-8-768 39 44   http://www.md.kth.se/~chr




Re: Python version of configure script (preview version)

2005-09-19 Thread Angus Leeming
[EMAIL PROTECTED] wrote:

> On Sun, 18 Sep 2005, Bo Peng wrote:
> 
>> >   I know, we have decided to proceed since this code is supposed to be
>> >   only
>> > run in windows and there the above argument does not apply. I would
>> > guess that every new install will have at least python 2.3 installed.
>> > :-)
>> > 
>> 
>> This solves the problem by now but what if we want to add some new
>> features to configure/configure.py in the future? It does not sound
>> like an awfully good idea to maintain two versions of the same thing.
>> Finding a redhat 7.3 machine and backport configure.py may be a better
>> idea.

> I run RH 7.3 on a laptop at home. If you'd like I could test it (just let
> me know what to do).

LYXLIB=$HOME/lyx/devel/lib
LYXBUILDLIB=$HOME/lyx/devel/build/lib
mkdir bopeng && cd bopeng
cp $LYXLIB/configure.py .
cp $LYXLIB/chkconfig.ltx .
mkdir -p doc
cp $LYXLIB/doc/*Config.lyx.in doc
python ./configure.py
sed 's/TAB/ /g;s/ \{1,\}/ /g' $LYXBUILDLIB/lyxrc.defaults | \
   sort > lyxrc_orig_sorted
sed 's/TAB/ /g;s/ \{1,\}/ /g' lyxrc.defaults | \
   sort lyxrc_bopeng_sorted
diff -u lyxrc_orig_sorted lyxrc_bopeng_sorted | cat -e

You'll need to replace TAB in the sed expressions with a literal tab
character, Cntl-VCntl-I. You'll also need to adjust the LYXLIB and
LYXBUILDLIB variables of course.

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-19 Thread Bo Peng
> I run RH 7.3 on a laptop at home. If you'd like I could test it (just let
> me know what to do).
> 

You first need to replace all A += B to A = A + B, and replace any
str.count(), str.replace() with something equivalent in 1.5.2. (I do
not know what they are since I never used them.) Since you do not have
to touch the cygwin/tmpfile part, the rest of the code seem to be
pretty back-compatible.

Besides lyxrc.default, you would better also compare doc/Config.lyx .

Thank you for your help.
Bo


Re: Python version of configure script (preview version)

2005-09-19 Thread chr
On Mon, 19 Sep 2005, Bo Peng wrote:

> > I run RH 7.3 on a laptop at home. If you'd like I could test it (just let
> > me know what to do).
> 
> You first need to replace all A += B to A = A + B, and replace any
> str.count(), str.replace() with something equivalent in 1.5.2. (I do
> not know what they are since I never used them.) Since you do not have
> to touch the cygwin/tmpfile part, the rest of the code seem to be
> pretty back-compatible.
> 
> Besides lyxrc.default, you would better also compare doc/Config.lyx .
> 
> Thank you for your help.

Um.. I think the info I need is a bit more basic than so... For instance,
can I just run the script with some arguments?  Where can I get the
script (can I use the CVS browser)?

/Christian

-- 
Christian Ridderström, +46-8-768 39 44   http://www.md.kth.se/~chr



Re: Python version of configure script (preview version)

2005-09-19 Thread Bo Peng
> Um.. I think the info I need is a bit more basic than so... For instance,
> can I just run the script with some arguments?  Where can I get the
> script (can I use the CVS browser)?

You need to get the latest cvs. configure.py is under the lib
directory. You can run it without any argument.

If you only need the file, it is at
http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/lib/configure.py.

Bo


Re: Python version of configure script (preview version)

2005-09-19 Thread Lars Gullik Bjønnes
Bo Peng <[EMAIL PROTECTED]> writes:

| > Um.. I think the info I need is a bit more basic than so... For instance,
| > can I just run the script with some arguments?  Where can I get the
| > script (can I use the CVS browser)?
| 
| You need to get the latest cvs. configure.py is under the lib
| directory. You can run it without any argument.

and it is not supported.

Please please do not put to much effort into this before 1.4.

-- 
Lgb



Re: Python version of configure script (preview version)

2005-09-19 Thread Jean-Marc Lasgouttes
> "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:

Lars> This script is not for 1.4 anyway.

Lars> leave 1.5 as requirement for 1.4 , go for 2.x for 1.5.

Note that we may want to go to the python version for some 1.4.x (x>0)
version, especially since it will help packaging on windows.

We'll see.

JMarc


Re: Python version of configure script (preview version)

2005-09-19 Thread chr
On Mon, 19 Sep 2005, Jean-Marc Lasgouttes wrote:

> > "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
> 
> Lars> This script is not for 1.4 anyway.
> 
> Lars> leave 1.5 as requirement for 1.4 , go for 2.x for 1.5.
> 
> Note that we may want to go to the python version for some 1.4.x (x>0)
> version, especially since it will help packaging on windows.
> 
> We'll see.

I'm not sure if this is true for general RH 7.3 installations, but mine 
has these versions of python installed:

-rwxr-xr-x2 root root   411244 Apr  4  2002 /usr/bin/python*
-rwxr-xr-x2 root root   411244 Apr  4  2002 /usr/bin/python1.5*
-rwxr-xr-x2 root root   875272 Apr 12  2002 /usr/bin/python2*
-rwxr-xr-x2 root root   875272 Apr 12  2002 /usr/bin/python2.2*

Is it still necessary to test with 1.5 then? (why not just require any
RH7.3 users to install python 2.2??)

/Christian


-- 
Christian Ridderström, +46-8-768 39 44   http://www.md.kth.se/~chr




Re: Python version of configure script (preview version)

2005-09-19 Thread Georg Baum
[EMAIL PROTECTED] wrote:

> On Mon, 19 Sep 2005, Jean-Marc Lasgouttes wrote:
> 
>> > "Lars" == Lars Gullik Bjønnes
>> > <[EMAIL PROTECTED]> writes:
>> 
>> Lars> This script is not for 1.4 anyway.
>> 
>> Lars> leave 1.5 as requirement for 1.4 , go for 2.x for 1.5.
>> 
>> Note that we may want to go to the python version for some 1.4.x (x>0)
>> version, especially since it will help packaging on windows.
>> 
>> We'll see.
> 
> I'm not sure if this is true for general RH 7.3 installations, but mine
> has these versions of python installed:
> 
> -rwxr-xr-x2 root root   411244 Apr  4  2002 /usr/bin/python*
> -rwxr-xr-x2 root root   411244 Apr  4  2002
> /usr/bin/python1.5*
> -rwxr-xr-x2 root root   875272 Apr 12  2002 /usr/bin/python2*
> -rwxr-xr-x2 root root   875272 Apr 12  2002
> /usr/bin/python2.2*
> 
> Is it still necessary to test with 1.5 then? (why not just require any
> RH7.3 users to install python 2.2??)

No, it is not (see the comments by Lars and Jean-Marc above). We'll have the
requirement of python 2.x anyway when configure.py finally replaces
configure.m4.


Georg




Re: Python version of configure script (preview version)

2005-09-19 Thread Jose' Matos
On Monday 19 September 2005 16:46, Georg Baum wrote:
> No, it is not (see the comments by Lars and Jean-Marc above). We'll have
> the requirement of python 2.x anyway when configure.py finally replaces
> configure.m4.

  Since we call python trough lyx we could easily have a defined variable to 
say which python to use. Naturally this choice would be off by default, if 
the system python is OK, there should be nothing to do.

  This could in preferences, or any other place... I am not sure if this 
worth...

> Georg

-- 
José Abílio


Re: Python version of configure script (preview version)

2005-09-19 Thread chr
On Mon, 19 Sep 2005, Georg Baum wrote:

> No, it is not (see the comments by Lars and Jean-Marc above). We'll have
> the requirement of python 2.x anyway when configure.py finally replaces
> configure.m4.

Ok, I'll leave it then. 

/C

-- 
Christian Ridderström, +46-8-768 39 44   http://www.md.kth.se/~chr




Re: Python version of configure script (preview version)

2005-09-18 Thread Angus Leeming
Bo Peng wrote:

 Hi, Augus,

That's Angus ;-)

 Thank you for the patch. I have merged it to my version, plus some
 cosmetic changes.

Great! I took the plunge and added it to the repository.

Temp files: I wonder if it makes sense to use a wrapper to Python's
tempfile module. Ie, use the tempfile module unless the --keep-temps
option is specified.

First, however, we should find out from José whether we still need to
support really ancient Pythons in LyX 1.5 --- see José's class TempFile
in lib/scripts/lyxpreview_tools.py for something that will work with older
versions too.

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-18 Thread Bo Peng
 First, however, we should find out from José whether we still need to
 support really ancient Pythons in LyX 1.5 

I have already used the tmpfile module in the cygwin/pathname part of
the script.

Bo


Re: Python version of configure script (preview version)

2005-09-18 Thread Jose' Matos
On Thursday 15 September 2005 20:58, Bo Peng wrote:
 Dear list,

 Attached is a Python version of the configure script. I currently do
 not have access to a windows machine with lyx on so I can not test it
 on windows. On my linux machine, it produces identical lyxrc.default
 and doc/LaTeXConfig.lyx but no further testing/proof-read of the code
 has been done.

  World is a small place, really. I have seen your contributions around 
several places lately (R, rpy, ...) :-)

  What is the minimum required python version for your script?
  As Angus said we are still aiming to python 1.5.2 compatibility, not 
something that I like but something necessary to deal with older systems.

  This is probably archaic as one of the last linux distributions to carry 
python 1.5.2 was Red Hat 7.3 release released in May 2002.

  Another option would be to update the requirements of python for lyx 1.4.x 
for x0.

-- 
José Abílio


Re: Python version of configure script (preview version)

2005-09-18 Thread Bo Peng
   World is a small place, really. I have seen your contributions around
 several places lately (R, rpy, ...) :-)

Well, I make a living on python, r, rpy and lyx. I make contributions
only to make my own life easier. :-)

   What is the minimum required python version for your script?
   As Angus said we are still aiming to python 1.5.2 compatibility, not
 something that I like but something necessary to deal with older systems.

mkstemp is used for the cygwin path detection, which is new to python
2.3. popen is used but it is not stable under windows prior to python
2.0. mkstemp can be easily replaced by using explicit temp file name
but someone has to run the script with python 1.5.2 to tell the
compatibility of other parts.

Cheers,
Bo


Re: Python version of configure script (preview version)

2005-09-18 Thread Jose' Matos
On Sunday 18 September 2005 19:51, Bo Peng wrote:
World is a small place, really. I have seen your contributions around
  several places lately (R, rpy, ...) :-)

 Well, I make a living on python, r, rpy and lyx. I make contributions
 only to make my own life easier. :-)

  I have packaged rpy to Fedora Extras, and I would like to thank you for your 
work there. It helped the packaging a lot. :-)

What is the minimum required python version for your script?
As Angus said we are still aiming to python 1.5.2 compatibility, not
  something that I like but something necessary to deal with older systems.

 mkstemp is used for the cygwin path detection, which is new to python
 2.3. popen is used but it is not stable under windows prior to python
 2.0. mkstemp can be easily replaced by using explicit temp file name
 but someone has to run the script with python 1.5.2 to tell the
 compatibility of other parts.

  I know, we have decided to proceed since this code is supposed to be only 
run in windows and there the above argument does not apply. I would guess 
that every new install will have at least python 2.3 installed. :-)

 Cheers,
 Bo

-- 
José Abílio


Re: Python version of configure script (preview version)

2005-09-18 Thread Angus Leeming
Jose' Matos wrote:
 mkstemp is used for the cygwin path detection, which is new to python
 2.3. popen is used but it is not stable under windows prior to python
 2.0. mkstemp can be easily replaced by using explicit temp file name
 but someone has to run the script with python 1.5.2 to tell the
 compatibility of other parts.
 
  I know, we have decided to proceed since this code is supposed to be
  only run in windows and there the above argument does not apply. I
  would guess that every new install will have at least python 2.3
  installed. :-) 

Then please add something like:

def get_version_info():
version_re = re.compile(([0-9])\.([0-9]))

match = version_re.match(sys.version)
if match == None:
error(Unable to extract version info from 'sys.version')

return int(match.group(1)), int(match.group(2))

major, minor = get_version_info()
if os.name == 'nt' and (major  2 or minor  3):
error(This script requires Python 2.3 or newer.)

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-18 Thread Jose' Matos
On Sunday 18 September 2005 21:52, Angus Leeming wrote:

 def get_version_info():
 version_re = re.compile(([0-9])\.([0-9]))

 match = version_re.match(sys.version)
 if match == None:
 error(Unable to extract version info from 'sys.version')

 return int(match.group(1)), int(match.group(2))

 major, minor = get_version_info()
 if os.name == 'nt' and (major  2 or minor  3):
 error(This script requires Python 2.3 or newer.)

  I like this version more:

import sys

def get_version_info():
try:
version = sys.version_info[:3]
except:
# sys.version_info was introduced with 2.0.0
# just consider it 1.5.2, as it enough for this function purposes
version = (1,5,2)

return version

if os.name == nt and get_version_info()  (2,3,0):
error(This script requires Python 2.3 or newer.)

  I have used exceptions as they are pretty fast in python by design. No need 
to use strings unless needed, it is possible to compare tuples (the 
lexicographical order applies here), and sometimes when requiring a given 
version we need to go to the micro level.

  For this function to be completely accurate I could use the string 
comparisons that you have used, also there is no need to test for the failure 
of the match because if this fails we have bigger problems. :-)

-- 
José Abílio


Re: Python version of configure script (preview version)

2005-09-18 Thread Bo Peng
   I know, we have decided to proceed since this code is supposed to be only
 run in windows and there the above argument does not apply. I would guess
 that every new install will have at least python 2.3 installed. :-)
 

This solves the problem by now but what if we want to add some new
features to configure/configure.py in the future? It does not sound
like an awfully good idea to maintain two versions of the same thing.
Finding a redhat 7.3 machine and backport configure.py may be a better
idea.

Bo


Re: Python version of configure script (preview version)

2005-09-18 Thread Angus Leeming
Bo Peng wrote:

> Hi, Augus,

That's "Angus" ;-)

> Thank you for the patch. I have merged it to my version, plus some
> cosmetic changes.

Great! I took the plunge and added it to the repository.

Temp files: I wonder if it makes sense to use a wrapper to Python's
tempfile module. Ie, use the tempfile module unless the --keep-temps
option is specified.

First, however, we should find out from José whether we still need to
support really ancient Pythons in LyX 1.5 --- see José's "class TempFile"
in lib/scripts/lyxpreview_tools.py for something that will work with older
versions too.

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-18 Thread Bo Peng
> First, however, we should find out from José whether we still need to
> support really ancient Pythons in LyX 1.5 

I have already used the tmpfile module in the cygwin/pathname part of
the script.

Bo


Re: Python version of configure script (preview version)

2005-09-18 Thread Jose' Matos
On Thursday 15 September 2005 20:58, Bo Peng wrote:
> Dear list,
>
> Attached is a Python version of the configure script. I currently do
> not have access to a windows machine with lyx on so I can not test it
> on windows. On my linux machine, it produces identical lyxrc.default
> and doc/LaTeXConfig.lyx but no further testing/proof-read of the code
> has been done.

  World is a small place, really. I have seen your contributions around 
several places lately (R, rpy, ...) :-)

  What is the minimum required python version for your script?
  As Angus said we are still aiming to python 1.5.2 compatibility, not 
something that I like but something necessary to deal with older systems.

  This is probably archaic as one of the last linux distributions to carry 
python 1.5.2 was Red Hat 7.3 release released in May 2002.

  Another option would be to update the requirements of python for lyx 1.4.x 
for x>0.

-- 
José Abílio


Re: Python version of configure script (preview version)

2005-09-18 Thread Bo Peng
>   World is a small place, really. I have seen your contributions around
> several places lately (R, rpy, ...) :-)

Well, I make a living on python, r, rpy and lyx. I make contributions
only to make my own life easier. :-)

>   What is the minimum required python version for your script?
>   As Angus said we are still aiming to python 1.5.2 compatibility, not
> something that I like but something necessary to deal with older systems.

mkstemp is used for the cygwin path detection, which is new to python
2.3. popen is used but "it is not stable under windows prior to python
2.0". mkstemp can be easily replaced by using explicit temp file name
but someone has to run the script with python 1.5.2 to tell the
compatibility of other parts.

Cheers,
Bo


Re: Python version of configure script (preview version)

2005-09-18 Thread Jose' Matos
On Sunday 18 September 2005 19:51, Bo Peng wrote:
> >   World is a small place, really. I have seen your contributions around
> > several places lately (R, rpy, ...) :-)
>
> Well, I make a living on python, r, rpy and lyx. I make contributions
> only to make my own life easier. :-)

  I have packaged rpy to Fedora Extras, and I would like to thank you for your 
work there. It helped the packaging a lot. :-)

> >   What is the minimum required python version for your script?
> >   As Angus said we are still aiming to python 1.5.2 compatibility, not
> > something that I like but something necessary to deal with older systems.
>
> mkstemp is used for the cygwin path detection, which is new to python
> 2.3. popen is used but "it is not stable under windows prior to python
> 2.0". mkstemp can be easily replaced by using explicit temp file name
> but someone has to run the script with python 1.5.2 to tell the
> compatibility of other parts.

  I know, we have decided to proceed since this code is supposed to be only 
run in windows and there the above argument does not apply. I would guess 
that every new install will have at least python 2.3 installed. :-)

> Cheers,
> Bo

-- 
José Abílio


Re: Python version of configure script (preview version)

2005-09-18 Thread Angus Leeming
Jose' Matos wrote:
>> mkstemp is used for the cygwin path detection, which is new to python
>> 2.3. popen is used but "it is not stable under windows prior to python
>> 2.0". mkstemp can be easily replaced by using explicit temp file name
>> but someone has to run the script with python 1.5.2 to tell the
>> compatibility of other parts.
> 
>  I know, we have decided to proceed since this code is supposed to be
>  only run in windows and there the above argument does not apply. I
>  would guess that every new install will have at least python 2.3
>  installed. :-) 

Then please add something like:

def get_version_info():
version_re = re.compile("([0-9])\.([0-9])")

match = version_re.match(sys.version)
if match == None:
error("Unable to extract version info from 'sys.version'")

return int(match.group(1)), int(match.group(2))

major, minor = get_version_info()
if os.name == 'nt' and (major < 2 or minor < 3):
error("This script requires Python 2.3 or newer.")

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-18 Thread Jose' Matos
On Sunday 18 September 2005 21:52, Angus Leeming wrote:
>
> def get_version_info():
> version_re = re.compile("([0-9])\.([0-9])")
>
> match = version_re.match(sys.version)
> if match == None:
> error("Unable to extract version info from 'sys.version'")
>
> return int(match.group(1)), int(match.group(2))
>
> major, minor = get_version_info()
> if os.name == 'nt' and (major < 2 or minor < 3):
> error("This script requires Python 2.3 or newer.")

  I like this version more:

import sys

def get_version_info():
try:
version = sys.version_info[:3]
except:
# sys.version_info was introduced with 2.0.0
# just consider it 1.5.2, as it enough for this function purposes
version = (1,5,2)

return version

if os.name == "nt" and get_version_info() < (2,3,0):
error("This script requires Python 2.3 or newer.")

  I have used exceptions as they are pretty fast in python by design. No need 
to use strings unless needed, it is possible to compare tuples (the 
lexicographical order applies here), and sometimes when requiring a given 
version we need to go to the micro level.

  For this function to be completely accurate I could use the string 
comparisons that you have used, also there is no need to test for the failure 
of the match because if this fails we have bigger problems. :-)

-- 
José Abílio


Re: Python version of configure script (preview version)

2005-09-18 Thread Bo Peng
>   I know, we have decided to proceed since this code is supposed to be only
> run in windows and there the above argument does not apply. I would guess
> that every new install will have at least python 2.3 installed. :-)
> 

This solves the problem by now but what if we want to add some new
features to configure/configure.py in the future? It does not sound
like an awfully good idea to maintain two versions of the same thing.
Finding a redhat 7.3 machine and backport configure.py may be a better
idea.

Bo


Re: Python version of configure script (preview version)

2005-09-17 Thread Bo Peng
 Well, you can always use

Always? devel.lyx.org died. wiki pointed me to
:ext:[EMAIL PROTECTED]:/usr/local/lyx/cvsroot
(http://wiki.lyx.org/DevelTips/UsingCVS), the old devel site said
pserver:[EMAIL PROTECTED]:/lyx/cvs , Augus said
pserver:anoncvs AT anoncvs.us.lyx.org:/var/cvs.

None of them worked.

 CVSROOT=:pserver:[EMAIL PROTECTED]:/var/cvs/lyx

Finally, this one works.

 Failing that, you can always browse ftp://ftp.sylvan.com/pub/lyx/devel
 and grab the latest CVS snapshot tar.bz2 file.

This site is not official, isn't it? Why snapshot is not under the
snapshot directory of ftp.lyx.org ?

Bo


Re: Python version of configure script (preview version)

2005-09-17 Thread Bo Peng
Dear list,

Finally, I get the latest cvs. My configure.py generates identical
lyxrc.defaults (subject to sort) and doc/Latexconfig.lyx as the bsh
version, after changing the case of four characters. Anyway, the
updated version is attached.

This is under my linux box. No testing has been done under mac, win, win/cygwin.

Bo
#!/usr/bin/env python 
#
# Python version of the configure script
#
# Bo Peng ([EMAIL PROTECTED])
# Sep, 2005
#
import sys, os, re, shutil, glob

outfile = 'lyxrc.defaults'
rc_entries = ''
lyx_check_config = True
lyx_keep_temps = False
srcdir = ''
version_suffix = ''

def writeToFile(filename, lines, append = False):
   utility function: write or append lines to filename 
  if append:
file = open(filename, 'a')
  else:
file = open(filename, 'w')
  file.write(lines)
  file.close()

def addToRC(lines):
  ''' utility function: shortcut for appending lines to outfile
add newline at the end of lines. 
  '''  
  if lines.strip() != '':
writeToFile(outfile, lines + '\n', append = True)

def removeFiles(filenames):
  '''utility function: 'rm -f'
ignore erroes when file does not exist, or is a directory.
  '''
  for file in filenames:
try:
  os.remove(file)
except:
  pass

def cmdOutput(cmd, line=-1):
  '''utility function: run a command and get its output
cmd: command to run
line: return the 'line' line. (with boundary checking)
if line==-1 (default), return all lines.
  '''  
  fout = os.popen(cmd)
  output = fout.readlines()
  fout.close()
  if line  0:
return output
  elif line = len(output):
print Output of command, cmd, has less than, line+1, lines
sys.exit(4)
  return output[line]

## Parse the command line
for op in sys.argv[1:]:   # default shell/for list is $*, the options
  if op in [ '-help', '--help', '-h' ]:
print '''Usage: configure [options]
Options:
  --help   show this help lines
  --keep-temps keep temporary files (for debug. purposes)
  --without-latex-config   do not run LaTeX to determine configuration
  --with-version-suffix=suffix suffix of binary installed files
'''
sys.exit(0)
  elif op == '--without-latex-config':
lyx_check_config = False
  elif op == '--keep-temps':
lyx_keep_temps = True
  elif op[0:22] == '--with-version-suffix=':  # never mind if op is not long 
enough  
version_suffix = op[23:]
  else:
print Unknown option, op
sys.exit(1)

## Checking for some echo oddities (ignored)
## The original script defines ac_n, ac_t and ac_c for 
## tab, newline etc, I just use python's print output. 

## I do not really know why this is useful, but we might as well keep it.
### NLS nuisances.
### Only set these to C if already set.  These must not be set unconditionally
### because not all systems understand e.g. LANG=C (notably SCO).
### Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
### Non-C LC_CTYPE values break the ctype check.
## 
os.environ['LANG'] = os.getenv('LANG', 'C')
os.environ['LC'] = os.getenv('LC_ALL', 'C')
os.environ['LC_MESSAGE'] = os.getenv('LC_MESSAGE', 'C')
os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')

## Guess the directory in which configure is located.
ac_prog = sys.argv[0]
srcdir = os.path.dirname(ac_prog)
if srcdir == '':  
  srcdir = '.'
if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
  print configure: error: cannot find chkconfig.ltx script
  sys.exit(1)

## Adjust PATH for Win32 (Cygwin)
#
use_cygwin_path_fix = ''
if sys.platform == 'cygwin':
  from tempfile import mkstemp
  fd, tmpfname = mkstemp(suffix='.ltx')
  os.write(fd, r'''
\documentstyle{article} 
\begin{document}\end{document} 
''')
  os.close(fd) 
  inpname = cmdOutput('cygpath -w ' + tmpfname, 0).replace('\\', '/').strip()
  # a wrapper file
  wfd, wtmpfname = mkstemp(suffix='.ltx')
  os.write(wfd, r'\input{' + inpname + '}' )
  os.close(wfd)
  check_err = False
  # grep Error
  for line in cmdOutput('latex ' + wtmpfname):
if line.count('Error') != 0:
  check_err = True
  break
  removeFiles( [ tmpfname, wtmpfname ])
  if check_err:
print configure: cygwin detected; path correction
srcdir = cmdOutput('cygpath -w ' + srcdir, 0).replace(r'\\', '').strip()
print srcdir = , srcdir
use_cygwin_path_fix = 'true'
  else:
print configure: cygwin detected; path correction is not needed
use_cygwin_path_fix = 'false'

 Create the build directories if necessary
for dir in ['bind', 'clipart', 'doc', 'examples', 'images', 'kbd', \
  'layouts', 'scripts', 'templates', 'ui' ]:
  if not os.path.isdir( dir ):
try:
  os.mkdir( dir)
except:
  print Failed to create directory , dir
  sys.exit(1)

## Write the first part of outfile
writeToFile(outfile, '''# This file has been automatically generated by LyX' 
lib/configure
# script. It contains default settings that have been determined by
# examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
# want to customize 

Re: Python version of configure script (preview version)

2005-09-17 Thread Kayvan A. Sylvan
On Fri, Sep 16, 2005 at 11:23:21PM -0700, Bo Peng wrote:
 
  Failing that, you can always browse ftp://ftp.sylvan.com/pub/lyx/devel
  and grab the latest CVS snapshot tar.bz2 file.
 
 This site is not official, isn't it? Why snapshot is not under the
 snapshot directory of ftp.lyx.org ?

It's pretty official. I do daily builds (under Redhat Fedora Core 4)
of both xforms and qt versions of lyx. The snapshot is updated
twice a day.

Anyways, anoncvs.us.lyx.org is a pointer to cvs.sylvan.com

---Kayvan
-- 
Kayvan A. Sylvan  | Proud husband of   | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | crown of her husband | Robin Gregory (2/28/92)


Re: Python version of configure script (preview version)

2005-09-17 Thread Angus Leeming
Bo Peng wrote:
 Attached is a python version of lib/configure for 1.4.0 cvs. It is
 written according to the m4 file at
 http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/lib/configure.m4 .
 Since I do not have access to lyx/cvs, I can only test it against
 1.4.0pre1 from ftp.lyx.org.

 Please test this script and report any problem here. Note that you
 should diff sorted lyxrc.default files since configure.py does not
 keep the original entry order.

I can confirm that the output is identical to that of the configure shell
script on this linux box.

 Angus, could you add this file to the repository?

I'm perfectly happy to, but will wait on Jean-Marc's or Lars' say so.
(Guys, I'm not proposing that the script be used or even distributed with
LyX 1.4.0.)

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-17 Thread Kayvan A. Sylvan
On Sat, Sep 17, 2005 at 06:00:50PM +0100, Angus Leeming wrote:
  Angus, could you add this file to the repository?
 
 I'm perfectly happy to, but will wait on Jean-Marc's or Lars' say so.
 (Guys, I'm not proposing that the script be used or even distributed with
 LyX 1.4.0.)

I don't think there's any harm in adding it to CVS. Without an explicit
change in the Makefile.am's, it wont't be included in the make dist
tarball.

-- 
Kayvan A. Sylvan  | Proud husband of   | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | crown of her husband | Robin Gregory (2/28/92)


Re: Python version of configure script (preview version)

2005-09-17 Thread Bo Peng
 (Guys, I'm not proposing that the script be used or even distributed with
 LyX 1.4.0.)

I agree. It does not add (if not break) anything under linux. The
reason for the conversion is to avoid using mingw under windows (so
not even useful for lyx/cygwin) to simplify installation.

The real benefit is that configure.py is cleaner and more maintainable
than configure.m4, so we can add new features (like the conversion of
old layout files, searching windows registry) easily.

Cheers,
Bo


Re: Python version of configure script (preview version)

2005-09-17 Thread Angus Leeming

Bo Peng wrote:

Dear list,

Attached is a python version of lib/configure for 1.4.0 cvs. It is
written according to the m4 file at
http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/lib/configure.m4 .
Since I do not have access to lyx/cvs, I can only test it against
1.4.0pre1 from ftp.lyx.org.

Please test this script and report any problem here. Note that you
should diff sorted lyxrc.default files since configure.py does not
keep the original entry order.


Hi, Bo.

I've made some changes to configure.py in order to get it working well on 
Windows. See attached. The changes will need cleaning up but they allow me 
to run configure.py from a cmd console:


set 
PATH=J:\MinSYS\bin;C:\Python24;C:\MiKTeX\Main\miktex\bin;C:\PROGRA~1\Perl\bin;c:\program 
files\Ghostscript 8.33\gs8.33\bin;C:\Program 
Files\Ghostgum\gsview;C:\Program Files\ImageMagick-6.2.3-Q16;%PATH%


python configure.py

To compare the generated lyxrc.defaults to that produced by the existing 
configure script when run by LyX, I've manipulated the generated 
lyxrc.defaults from a a MinSYS terminal, so:


$ sed 's/TAB/ /g;s/ \{1,\}/ /g' $HOME/lyx/devel/build/lib/lyxrc.defaults | \
  sort  lyxrc_orig_sorted
$ sed 's/TAB/ /g;s/ \{1,\}/ /g' lyxrc.defaults  lyxrc_bopeng.defaults | \
  sort lyxrc_bopeng_sorted
$ diff -u lyxrc_orig_sorted lyxrc_bopeng_sorted | cat -e  lyxrc_changes
$ cat lyxrc_changes
@@ -84,8 +81,7 @@$
 \copier fig sh $$s/scripts/fig_copy.sh $$i $$o$
 \copier pdftex python $$s/scripts/tex_copy.py $$i $$o $$l$
 \copier pstex python $$s/scripts/tex_copy.py $$i $$o $$l$
-\font_encoding T1$
 \print_spool_command lpr$
 \print_spool_printerprefix -P$
 \spell_command none$
-\tex_allows_spaces true$
+\tex_allows_spaces false$

Note that I had to comment out the font_encoding command because 
chk_fontenc was not defined.


Please strip trailing whitespace from your script with
$ sed 's/ \{1,\}$//' configure.py
It changes the output in places, but I haven't attached the resulting diff 
because it makes it impossible to see what the substantive changes that 
I've made are.


Angus
--- configure_orig.py   Sat Sep 17 17:54:44 2005
+++ configure.pySat Sep 17 20:14:52 2005
@@ -184,8 +184,16 @@
 ac_prog = progs[idx]
 ac_word = ac_prog.split(' ')[0]
 print '+checking for ' + ac_word + '... ', 
-for ac_dir in os.environ['PATH'].split(':') + path:
+
+path = os.environ[PATH].split(os.pathsep) + path
+for ac_dir in path:
+  success = False
   if os.path.isfile( os.path.join(ac_dir, ac_word) ):
+success = True
+  if not success and \
+ os.path.isfile( os.path.join(ac_dir, ac_word + .exe) ):
+success = True
+  if success == True:
 print ' yes'
 # write rc entries for this command
 if len(rc_entry) == 1:
@@ -238,7 +246,7 @@
   rc_entry = [ r'\Format figfig FIG %% 
%%'] )
 
 checkProg('a Grace viewer and editor', ['xmgrace'], 
-  rc_entry = [  r'\Format agr agr GRACE   %% %%' ] )
+  rc_entry = [  r'\Format agr agr Grace   %% %%' ] )
 
 checkProg('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'],
   rc_entry = [ r'\Format fenfen FEN %% 
%%' ])
@@ -262,7 +270,7 @@
   rc_entry = [
 r'''\Format asciichess ascPlain text (chess output)  %%
 \Format asciiimage ascPlain text (image) %%
-\Format asciixfig  ascPlain text (xfig output)   %%
+\Format asciixfig  ascPlain text (Xfig output)   %%
 \Format dateouttmpdate (output)  %%
 \Format docbooksgmlDocBookB  %%
 \Format docbook-xml xml   Docbook (XML)  %%
@@ -342,7 +350,7 @@
   rc_entry = [
 r'\ascii_roff_command groff -t -Tlatin1 $$FName', 
 r'\ascii_roff_command tbl $$FName | nroff', 
-'' ])
+r'\ascii_roff_command none' ])
 
 checkProg('ChkTeX', ['chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38'],
   rc_entry = [
@@ -351,7 +359,8 @@
 
 checkProg('a spellchecker', ['ispell'],
   rc_entry = [
-r'\spell_command ispell', '' ] )
+r'\spell_command ispell',
+r'\spell_command none' ])
 
 ## FIXME: OCTAVE is not used anywhere
 path, OCTAVE = checkProg('Octave', ['octave'])
@@ -373,6 +382,7 @@
 \converter linuxdocdvi none 
 \converter linuxdochtml none  ''' ])
 
+linuxdoc_cmd = ''
 if LINUXDOC != 'none':
   chk_linuxdoc = 'yes'
   bool_linuxdoc = 'true'
@@ -390,6 +400,7 @@
 r'''\converter docbookdvinone 
 \converter docbookhtml   none '''])
 
+docbook_cmd = ''
 if DOCBOOK != 'none':
   chk_docbook = 'yes'
   bool_docbook = 'true'
@@ -402,7 +413,7 @@
   rc_entry = [
 r'''\print_spool_printerprefix -d 
 \print_spool_command lp''',
-r'''\print_spool_printerprefix -P',
+r'''\print_spool_printerprefix -P
 \print_spool_command lpr''',
 ''])
 
@@ -592,9 +603,8 @@
 
 ### Let's check whether spaces are allowed in TeX file names
 print Checking whether TeX allows spaces 

Re: Python version of configure script (preview version)

2005-09-17 Thread Bo Peng
 Not if you use start as viewer of any file that is supported by
 windows (the problem is to discover that).

start is a DOS command (as far as I know). In a cmd windows, start can
open a file using its associated application. However, I tried to use
start $$i or cmd /c start $$i for pdf format and did not get it
work. A shell window is started instead.

 Could you point us to the API? I found ShellExecute, but I did not
 find a way to tell whether a file format is handled.

I am not quite sure. There are ShellExecute, ShellExecuteEx, WinExec.
According to 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp
, ShellExecute should just work. A 32 return value indicates failure
to open a file, but this is not lyx' fault so we do not have to worry
about it.

Bo


Re: Python version of configure script (preview version)

2005-09-17 Thread Bo Peng
> Well, you can always use

Always? devel.lyx.org died. wiki pointed me to
:ext:[EMAIL PROTECTED]:/usr/local/lyx/cvsroot
(http://wiki.lyx.org/DevelTips/UsingCVS), the old devel site said
pserver:[EMAIL PROTECTED]:/lyx/cvs , Augus said
pserver:anoncvs AT anoncvs.us.lyx.org:/var/cvs.

None of them worked.

> CVSROOT=:pserver:[EMAIL PROTECTED]:/var/cvs/lyx

Finally, this one works.

> Failing that, you can always browse ftp://ftp.sylvan.com/pub/lyx/devel
> and grab the latest CVS snapshot tar.bz2 file.

This site is not official, isn't it? Why snapshot is not under the
snapshot directory of ftp.lyx.org ?

Bo


Re: Python version of configure script (preview version)

2005-09-17 Thread Bo Peng
Dear list,

Finally, I get the latest cvs. My configure.py generates identical
lyxrc.defaults (subject to sort) and doc/Latexconfig.lyx as the bsh
version, after changing the case of four characters. Anyway, the
updated version is attached.

This is under my linux box. No testing has been done under mac, win, win/cygwin.

Bo
#!/usr/bin/env python 
#
# Python version of the configure script
#
# Bo Peng ([EMAIL PROTECTED])
# Sep, 2005
#
import sys, os, re, shutil, glob

outfile = 'lyxrc.defaults'
rc_entries = ''
lyx_check_config = True
lyx_keep_temps = False
srcdir = ''
version_suffix = ''

def writeToFile(filename, lines, append = False):
  " utility function: write or append lines to filename "
  if append:
file = open(filename, 'a')
  else:
file = open(filename, 'w')
  file.write(lines)
  file.close()

def addToRC(lines):
  ''' utility function: shortcut for appending lines to outfile
add newline at the end of lines. 
  '''  
  if lines.strip() != '':
writeToFile(outfile, lines + '\n', append = True)

def removeFiles(filenames):
  '''utility function: 'rm -f'
ignore erroes when file does not exist, or is a directory.
  '''
  for file in filenames:
try:
  os.remove(file)
except:
  pass

def cmdOutput(cmd, line=-1):
  '''utility function: run a command and get its output
cmd: command to run
line: return the 'line' line. (with boundary checking)
if line==-1 (default), return all lines.
  '''  
  fout = os.popen(cmd)
  output = fout.readlines()
  fout.close()
  if line < 0:
return output
  elif line >= len(output):
print "Output of command", cmd, "has less than", line+1, "lines"
sys.exit(4)
  return output[line]

## Parse the command line
for op in sys.argv[1:]:   # default shell/for list is $*, the options
  if op in [ '-help', '--help', '-h' ]:
print '''Usage: configure [options]
Options:
  --help   show this help lines
  --keep-temps keep temporary files (for debug. purposes)
  --without-latex-config   do not run LaTeX to determine configuration
  --with-version-suffix=suffix suffix of binary installed files
'''
sys.exit(0)
  elif op == '--without-latex-config':
lyx_check_config = False
  elif op == '--keep-temps':
lyx_keep_temps = True
  elif op[0:22] == '--with-version-suffix=':  # never mind if op is not long 
enough  
version_suffix = op[23:]
  else:
print "Unknown option", op
sys.exit(1)

## Checking for some echo oddities (ignored)
## The original script defines ac_n, ac_t and ac_c for 
## tab, newline etc, I just use python's print output. 

## I do not really know why this is useful, but we might as well keep it.
### NLS nuisances.
### Only set these to C if already set.  These must not be set unconditionally
### because not all systems understand e.g. LANG=C (notably SCO).
### Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
### Non-C LC_CTYPE values break the ctype check.
## 
os.environ['LANG'] = os.getenv('LANG', 'C')
os.environ['LC'] = os.getenv('LC_ALL', 'C')
os.environ['LC_MESSAGE'] = os.getenv('LC_MESSAGE', 'C')
os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')

## Guess the directory in which configure is located.
ac_prog = sys.argv[0]
srcdir = os.path.dirname(ac_prog)
if srcdir == '':  
  srcdir = '.'
if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
  print "configure: error: cannot find chkconfig.ltx script"
  sys.exit(1)

## Adjust PATH for Win32 (Cygwin)
#
use_cygwin_path_fix = ''
if sys.platform == 'cygwin':
  from tempfile import mkstemp
  fd, tmpfname = mkstemp(suffix='.ltx')
  os.write(fd, r'''
\documentstyle{article} 
\begin{document}\end{document} 
''')
  os.close(fd) 
  inpname = cmdOutput('cygpath -w ' + tmpfname, 0).replace('\\', '/').strip()
  # a wrapper file
  wfd, wtmpfname = mkstemp(suffix='.ltx')
  os.write(wfd, r'\input{' + inpname + '}' )
  os.close(wfd)
  check_err = False
  # grep Error
  for line in cmdOutput('latex ' + wtmpfname):
if line.count('Error') != 0:
  check_err = True
  break
  removeFiles( [ tmpfname, wtmpfname ])
  if check_err:
print "configure: cygwin detected; path correction"
srcdir = cmdOutput('cygpath -w ' + srcdir, 0).replace(r'\\', '').strip()
print "srcdir = ", srcdir
use_cygwin_path_fix = 'true'
  else:
print "configure: cygwin detected; path correction is not needed"
use_cygwin_path_fix = 'false'

 Create the build directories if necessary
for dir in ['bind', 'clipart', 'doc', 'examples', 'images', 'kbd', \
  'layouts', 'scripts', 'templates', 'ui' ]:
  if not os.path.isdir( dir ):
try:
  os.mkdir( dir)
except:
  print "Failed to create directory ", dir
  sys.exit(1)

## Write the first part of outfile
writeToFile(outfile, '''# This file has been automatically generated by LyX' 
lib/configure
# script. It contains default settings that have been determined by
# examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you

Re: Python version of configure script (preview version)

2005-09-17 Thread Kayvan A. Sylvan
On Fri, Sep 16, 2005 at 11:23:21PM -0700, Bo Peng wrote:
> 
> > Failing that, you can always browse ftp://ftp.sylvan.com/pub/lyx/devel
> > and grab the latest CVS snapshot tar.bz2 file.
> 
> This site is not official, isn't it? Why snapshot is not under the
> snapshot directory of ftp.lyx.org ?

It's pretty official. I do daily builds (under Redhat Fedora Core 4)
of both xforms and qt versions of lyx. The snapshot is updated
twice a day.

Anyways, anoncvs.us.lyx.org is a pointer to cvs.sylvan.com

---Kayvan
-- 
Kayvan A. Sylvan  | Proud husband of   | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | "crown of her husband" | Robin Gregory (2/28/92)


Re: Python version of configure script (preview version)

2005-09-17 Thread Angus Leeming
Bo Peng wrote:
> Attached is a python version of lib/configure for 1.4.0 cvs. It is
> written according to the m4 file at
> http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/lib/configure.m4 .
> Since I do not have access to lyx/cvs, I can only test it against
> 1.4.0pre1 from ftp.lyx.org.

> Please test this script and report any problem here. Note that you
> should diff sorted lyxrc.default files since configure.py does not
> keep the original entry order.

I can confirm that the output is identical to that of the configure shell
script on this linux box.

> Angus, could you add this file to the repository?

I'm perfectly happy to, but will wait on Jean-Marc's or Lars' say so.
(Guys, I'm not proposing that the script be used or even distributed with
LyX 1.4.0.)

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-17 Thread Kayvan A. Sylvan
On Sat, Sep 17, 2005 at 06:00:50PM +0100, Angus Leeming wrote:
> > Angus, could you add this file to the repository?
> 
> I'm perfectly happy to, but will wait on Jean-Marc's or Lars' say so.
> (Guys, I'm not proposing that the script be used or even distributed with
> LyX 1.4.0.)

I don't think there's any harm in adding it to CVS. Without an explicit
change in the Makefile.am's, it wont't be included in the "make dist"
tarball.

-- 
Kayvan A. Sylvan  | Proud husband of   | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | "crown of her husband" | Robin Gregory (2/28/92)


Re: Python version of configure script (preview version)

2005-09-17 Thread Bo Peng
> (Guys, I'm not proposing that the script be used or even distributed with
> LyX 1.4.0.)

I agree. It does not add (if not break) anything under linux. The
reason for the conversion is to avoid using mingw under windows (so
not even useful for lyx/cygwin) to simplify installation.

The real benefit is that configure.py is cleaner and more maintainable
than configure.m4, so we can add new features (like the conversion of
old layout files, searching windows registry) easily.

Cheers,
Bo


Re: Python version of configure script (preview version)

2005-09-17 Thread Angus Leeming

Bo Peng wrote:

Dear list,

Attached is a python version of lib/configure for 1.4.0 cvs. It is
written according to the m4 file at
http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/lib/configure.m4 .
Since I do not have access to lyx/cvs, I can only test it against
1.4.0pre1 from ftp.lyx.org.

Please test this script and report any problem here. Note that you
should diff sorted lyxrc.default files since configure.py does not
keep the original entry order.


Hi, Bo.

I've made some changes to configure.py in order to get it working well on 
Windows. See attached. The changes will need cleaning up but they allow me 
to run configure.py from a cmd console:


set 
PATH=J:\MinSYS\bin;C:\Python24;C:\MiKTeX\Main\miktex\bin;C:\PROGRA~1\Perl\bin;c:\program 
files\Ghostscript 8.33\gs8.33\bin;C:\Program 
Files\Ghostgum\gsview;C:\Program Files\ImageMagick-6.2.3-Q16;%PATH%


python configure.py

To compare the generated lyxrc.defaults to that produced by the existing 
configure script when run by LyX, I've manipulated the generated 
lyxrc.defaults from a a MinSYS terminal, so:


$ sed 's/TAB/ /g;s/ \{1,\}/ /g' $HOME/lyx/devel/build/lib/lyxrc.defaults | \
  sort > lyxrc_orig_sorted
$ sed 's/TAB/ /g;s/ \{1,\}/ /g' lyxrc.defaults > lyxrc_bopeng.defaults | \
  sort lyxrc_bopeng_sorted
$ diff -u lyxrc_orig_sorted lyxrc_bopeng_sorted | cat -e > lyxrc_changes
$ cat lyxrc_changes
@@ -84,8 +81,7 @@$
 \copier fig "sh $$s/scripts/fig_copy.sh $$i $$o"$
 \copier pdftex "python $$s/scripts/tex_copy.py $$i $$o $$l"$
 \copier pstex "python $$s/scripts/tex_copy.py $$i $$o $$l"$
-\font_encoding "T1"$
 \print_spool_command "lpr"$
 \print_spool_printerprefix "-P"$
 \spell_command "none"$
-\tex_allows_spaces true$
+\tex_allows_spaces false$

Note that I had to comment out the font_encoding command because 
chk_fontenc was not defined.


Please strip trailing whitespace from your script with
$ sed 's/ \{1,\}$//' configure.py
It changes the output in places, but I haven't attached the resulting diff 
because it makes it impossible to see what the substantive changes that 
I've made are.


Angus
--- configure_orig.py   Sat Sep 17 17:54:44 2005
+++ configure.pySat Sep 17 20:14:52 2005
@@ -184,8 +184,16 @@
 ac_prog = progs[idx]
 ac_word = ac_prog.split(' ')[0]
 print '+checking for "' + ac_word + '"... ', 
-for ac_dir in os.environ['PATH'].split(':') + path:
+
+path = os.environ["PATH"].split(os.pathsep) + path
+for ac_dir in path:
+  success = False
   if os.path.isfile( os.path.join(ac_dir, ac_word) ):
+success = True
+  if not success and \
+ os.path.isfile( os.path.join(ac_dir, ac_word + ".exe") ):
+success = True
+  if success == True:
 print ' yes'
 # write rc entries for this command
 if len(rc_entry) == 1:
@@ -238,7 +246,7 @@
   rc_entry = [ r'\Format figfig FIG"" "%%" 
"%%"'] )
 
 checkProg('a Grace viewer and editor', ['xmgrace'], 
-  rc_entry = [  r'\Format agr agr GRACE  "" "%%" "%%"' ] )
+  rc_entry = [  r'\Format agr agr Grace  "" "%%" "%%"' ] )
 
 checkProg('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'],
   rc_entry = [ r'\Format fenfen FEN"" "%%" 
"%%"' ])
@@ -262,7 +270,7 @@
   rc_entry = [
 r'''\Format asciichess asc"Plain text (chess output)"  "" ""   "%%"
 \Format asciiimage asc"Plain text (image)" "" ""   "%%"
-\Format asciixfig  asc"Plain text (xfig output)"   "" ""   "%%"
+\Format asciixfig  asc"Plain text (Xfig output)"   "" ""   "%%"
 \Format dateouttmp"date (output)" "" """%%"
 \Format docbooksgmlDocBookB  """%%"
 \Format docbook-xml xml   "Docbook (XML)" "" """%%"
@@ -342,7 +350,7 @@
   rc_entry = [
 r'\ascii_roff_command "groff -t -Tlatin1 $$FName"', 
 r'\ascii_roff_command "tbl $$FName | nroff"', 
-'' ])
+r'\ascii_roff_command "none"' ])
 
 checkProg('ChkTeX', ['chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38'],
   rc_entry = [
@@ -351,7 +359,8 @@
 
 checkProg('a spellchecker', ['ispell'],
   rc_entry = [
-r'\spell_command "ispell"', '' ] )
+r'\spell_command "ispell"',
+r'\spell_command "none"' ])
 
 ## FIXME: OCTAVE is not used anywhere
 path, OCTAVE = checkProg('Octave', ['octave'])
@@ -373,6 +382,7 @@
 \converter linuxdocdvi "none" ""
 \converter linuxdochtml "none" "" ''' ])
 
+linuxdoc_cmd = ''
 if LINUXDOC != 'none':
   chk_linuxdoc = 'yes'
   bool_linuxdoc = 'true'
@@ -390,6 +400,7 @@
 r'''\converter docbookdvi"none" ""
 \converter docbookhtml   "none" ""'''])
 
+docbook_cmd = ''
 if DOCBOOK != 'none':
   chk_docbook = 'yes'
   bool_docbook = 'true'
@@ -402,7 +413,7 @@
   rc_entry = [
 r'''\print_spool_printerprefix "-d "
 \print_spool_command "lp"''',
-r'''\print_spool_printerprefix "-P"',
+r'''\print_spool_printerprefix "-P"
 \print_spool_command "lpr"''',
   

Re: Python version of configure script (preview version)

2005-09-17 Thread Bo Peng
> Not if you use "start" as viewer of any file that is supported by
> windows (the problem is to discover that).

start is a DOS command (as far as I know). In a cmd windows, start can
open a file using its associated application. However, I tried to use
"start $$i" or "cmd /c start $$i" for pdf format and did not get it
work. A shell window is started instead.

> Could you point us to the API? I found ShellExecute, but I did not
> find a way to tell whether a file format is handled.

I am not quite sure. There are ShellExecute, ShellExecuteEx, WinExec.
According to 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp
, ShellExecute should just work. A <32 return value indicates failure
to open a file, but this is not lyx' fault so we do not have to worry
about it.

Bo


Re: Python version of configure script (preview version)

2005-09-16 Thread Angus Leeming
Bo Peng wrote:

 Here's the output from my linux box together with a small fix.
 
 $ diff -u -Bbw ../build/lib/lyxrc.defaults .  lyxrc.diff
 $ diff -u configure_orig.py configure.py  configure.diff
 
 How do you like the attached new version? checkProg() now
 handles rc file and all info about checked program is now
 complete at one function call.

It's looking good, but it occurs to me that you're trying to replace the
LyX 1.3.6 version of configure. You should really be looking to the
1.4.0CVS 
version...

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-16 Thread Jean-Marc Lasgouttes
 Angus == Angus Leeming [EMAIL PROTECTED] writes:

Angus Bo Peng wrote:
 Here's the output from my linux box together with a small fix.
 
 $ diff -u -Bbw ../build/lib/lyxrc.defaults .  lyxrc.diff $ diff
 -u configure_orig.py configure.py  configure.diff
  How do you like the attached new version? checkProg() now handles
 rc file and all info about checked program is now complete at one
 function call.

Angus It's looking good, but it occurs to me that you're trying to
Angus replace the LyX 1.3.6 version of configure. You should really
Angus be looking to the 1.4.0CVS version...

I agree to both remarks.

Concerning Bo's remark that a lot of win32/mac specific code is going
to be added, we should think a bit about that before actually doing
it.

One solution would be to add code at LyX level to use OS-provided
hooks for opening documents. Then we could decide that these
OS-provided hooks override what LyX wants to do.

The other solution is to do it in the python script. However, I do not
know what abilities python has to discover these things. I do not like
much the code that searches the registry in windows.

JMarc


Re: Python version of configure script (preview version)

2005-09-16 Thread Angus Leeming
Jean-Marc Lasgouttes wrote:
 Concerning Bo's remark that a lot of win32/mac specific code is
 going to be added, we should think a bit about that before actually
 doing it.
 
 One solution would be to add code at LyX level to use OS-provided
 hooks for opening documents. Then we could decide that these
 OS-provided hooks override what LyX wants to do.
 
 The other solution is to do it in the python script. However, I do
 not know what abilities python has to discover these things. I do
 not like much the code that searches the registry in windows.

I think that we should have all this stuff outside of LyX itself. All
LyX needs is to be able to find an executable and to know how to
invoke it. LyXRC::path_prefix and the converters provide us with
everything we need, no?

I agree that the registry stuff is ugly. Individual apps store stuf in
the registry in different ways, so there wouldn't appear to be a
generic way to extract these data.

As for python's abilities in this regard, googling on python search
registry turns up lots of stuff. Eg

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/174627
http://www.oreillynet.com/pub/wlg/2608
http://www.microsoft.com/technet/scriptcenter/scripts/python/os/registry/default.mspx

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-16 Thread Angus Leeming
Angus Leeming wrote:
 As for python's abilities in this regard, googling on python search
 registry turns up lots of stuff. Eg
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/174627

Also
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146305

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-16 Thread Bo Peng
One problem with the rc approach is that re-configuration is required 
whenever users change a filetype association. Also, opening a file 
with its associated application is quite easy under windows. (There are APIs.)

Bo


Re: Python version of configure script (preview version)

2005-09-16 Thread Jean-Marc Lasgouttes
 Bo == Bo Peng [EMAIL PROTECTED] writes:

Bo One problem with the rc approach is that re-configuration is
Bo required whenever users change a filetype association. 

Not if you use start as viewer of any file that is supported by
windows (the problem is to discover that).

Bo Also, opening a file with its associated application is quite easy
Bo under windows. (There are APIs.)

Could you point us to the API? I found ShellExecute, but I did not
find a way to tell whether a file format is handled.

JMarc


Re: Python version of configure script (preview version)

2005-09-16 Thread Mike Meyer
In [EMAIL PROTECTED], Bo Peng [EMAIL PROTECTED] typed:
 One problem with the rc approach is that re-configuration is required 
 whenever users change a filetype association. Also, opening a file 
 with its associated application is quite easy under windows. (There are APIs.)

Since Bo Peng didn't provide context, I groveled it out by chasing
down the message-id he's replying to. He is replying to a message
pointing out how to dig information out of the windows registry. From
what he says, I presume said information would be the type-viewer
map, and that reconfig should store the appropriate viewer in the LyX
preferences file.

A reconfig isn't required. Until that's done, LyX will just use the
old viewer. Who knows - that may even be the one the User wants? I
know I don't want LyX to use my default web browser for ViewHTML.

On OS X, the solution is easy - you look for the viewer
/usr/bin/open. If you find it, you use it. I've got an open for Unix
that I've been using in LyX for the last week. I hope to have a
version with enough features that it's useful for end users done this
weekend. According to Jean-Marc Lasgouttes, you should use start on
Windows. Is that an external application? If so, then LyX just needs
to know how to launch external command line applications, so no
changes are needed. configure will need to be taught to check for
open/start, and use those for the viewer for everything if it finds
them.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.


Re: Python version of configure script (preview version)

2005-09-16 Thread Bo Peng
Dear list,

Attached is a python version of lib/configure for 1.4.0 cvs. It is
written according to the m4 file at
http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/lib/configure.m4 .
Since I do not have access to lyx/cvs, I can only test it against
1.4.0pre1 from ftp.lyx.org.

Please test this script and report any problem here. Note that you
should diff sorted lyxrc.default files since configure.py does not
keep the original entry order.

Angus, could you add this file to the repository? 

Thanks.
Bo
#!/usr/bin/env python 
#
# Python version of the configure script
#
# Bo Peng ([EMAIL PROTECTED])
# Sep, 2005
#
import sys, os, re, shutil, glob

outfile = 'lyxrc.defaults'
rc_entries = ''
lyx_check_config = True
lyx_keep_temps = False
srcdir = ''
version_suffix = ''

def writeToFile(filename, lines, append = False):
   utility function: write or append lines to filename 
  if append:
file = open(filename, 'a')
  else:
file = open(filename, 'w')
  file.write(lines)
  file.close()

def addToRC(lines):
  ''' utility function: shortcut for appending lines to outfile
add newline at the end of lines. 
  '''  
  if lines.strip() != '':
writeToFile(outfile, lines + '\n', append = True)

def removeFiles(filenames):
  '''utility function: 'rm -f'
ignore erroes when file does not exist, or is a directory.
  '''
  for file in filenames:
try:
  os.remove(file)
except:
  pass

def cmdOutput(cmd, line=-1):
  '''utility function: run a command and get its output
cmd: command to run
line: return the 'line' line. (with boundary checking)
  if line==-1 (default), return all lines.
  '''  
  fout = os.popen(cmd)
  output = fout.readlines()
  fout.close()
  if line  0:
return output
  elif line = len(output):
print Output of command, cmd, has less than, line+1, lines
sys.exit(4)
  return output[line]

## Parse the command line
for op in sys.argv[1:]:   # default shell/for list is $*, the options
  if op in [ '-help', '--help', '-h' ]:
print '''Usage: configure [options]
Options:
  --help   show this help lines
  --keep-temps keep temporary files (for debug. purposes)
  --without-latex-config   do not run LaTeX to determine configuration
  --with-version-suffix=suffix suffix of binary installed files
'''
sys.exit(0)
  elif op == '--without-latex-config':
lyx_check_config = False
  elif op == '--keep-temps':
lyx_keep_temps = True
  elif op[0:22] == '--with-version-suffix=':  # never mind if op is not long 
enough  
version_suffix = op[23:]
  else:
print Unknown option, op
sys.exit(1)

## Checking for some echo oddities (ignored)
## The original script defines ac_n, ac_t and ac_c for 
## tab, newline etc, I just use python's print output. 

## I do not really know why this is useful, but we might as well keep it.
### NLS nuisances.
### Only set these to C if already set.  These must not be set unconditionally
### because not all systems understand e.g. LANG=C (notably SCO).
### Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
### Non-C LC_CTYPE values break the ctype check.
## 
os.environ['LANG'] = os.getenv('LANG', 'C')
os.environ['LC'] = os.getenv('LC_ALL', 'C')
os.environ['LC_MESSAGE'] = os.getenv('LC_MESSAGE', 'C')
os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')

## Guess the directory in which configure is located.
ac_prog = sys.argv[0]
srcdir = os.path.dirname(ac_prog)
if srcdir == '':  
  srcdir = '.'
if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
  print configure: error: cannot find chkconfig.ltx script
  sys.exit(1)

## Adjust PATH for Win32 (Cygwin)
#
use_cygwin_path_fix = ''
if sys.platform == 'cygwin':
  from tempfile import mkstemp
  fd, tmpfname = mkstemp(suffix='.ltx')
  os.write(fd, r'''
\documentstyle{article} 
\begin{document}\end{document} 
''')
  os.close(fd) 
  inpname = cmdOutput('cygpath -w ' + tmpfname, 0).replace('\\', '/').strip()
  # a wrapper file
  wfd, wtmpfname = mkstemp(suffix='.ltx')
  os.write(wfd, r'\input{' + inpname + '}' )
  os.close(wfd)
  check_err = False
  # grep Error
  for line in cmdOutput('latex ' + wtmpfname):
if line.count('Error') != 0:
  check_err = True
  break
  removeFiles( [ tmpfname, wtmpfname ])
  if check_err:
print configure: cygwin detected; path correction
srcdir = cmdOutput('cygpath -w ' + srcdir, 0).replace(r'\\', '').strip()
print srcdir = , srcdir
use_cygwin_path_fix = 'true'
  else:
print configure: cygwin detected; path correction is not needed
use_cygwin_path_fix = 'false'

 Create the build directories if necessary
for dir in ['bind', 'clipart', 'doc', 'examples', 'images', 'kbd', \
  'layouts', 'scripts', 'templates', 'ui' ]:
  if not os.path.isdir( dir ):
try:
  os.mkdir( dir)
except:
  print Failed to create directory , dir
  sys.exit(1)

## Write the first part of outfile
writeToFile(outfile, '''# This file has been automatically 

Re: Python version of configure script (preview version)

2005-09-16 Thread Kayvan A. Sylvan
On Fri, Sep 16, 2005 at 09:12:20PM -0700, Bo Peng wrote:
 Since I do not have access to lyx/cvs, I can only test it against
 1.4.0pre1 from ftp.lyx.org.

Well, you can always use

CVSROOT=:pserver:[EMAIL PROTECTED]:/var/cvs/lyx

Then cvs login (password is lyx)

Failing that, you can always browse ftp://ftp.sylvan.com/pub/lyx/devel
and grab the latest CVS snapshot tar.bz2 file.

---Kayvan
-- 
Kayvan A. Sylvan  | Proud husband of   | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | crown of her husband | Robin Gregory (2/28/92)


Re: Python version of configure script (preview version)

2005-09-16 Thread Angus Leeming
Bo Peng wrote:

>> Here's the output from my linux box together with a small fix.
>> 
>> $ diff -u -Bbw ../build/lib/lyxrc.defaults . > lyxrc.diff
>> $ diff -u configure_orig.py configure.py > configure.diff
> 
> How do you like the attached new version? checkProg() now
> handles rc file and all info about checked program is now
> complete at one function call.

It's looking good, but it occurs to me that you're trying to replace the
LyX 1.3.6 version of configure. You should really be looking to the
1.4.0CVS 
version...

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-16 Thread Jean-Marc Lasgouttes
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:

Angus> Bo Peng wrote:
>>> Here's the output from my linux box together with a small fix.
>>> 
>>> $ diff -u -Bbw ../build/lib/lyxrc.defaults . > lyxrc.diff $ diff
>>> -u configure_orig.py configure.py > configure.diff
>>  How do you like the attached new version? checkProg() now handles
>> rc file and all info about checked program is now complete at one
>> function call.

Angus> It's looking good, but it occurs to me that you're trying to
Angus> replace the LyX 1.3.6 version of configure. You should really
Angus> be looking to the 1.4.0CVS version...

I agree to both remarks.

Concerning Bo's remark that a lot of win32/mac specific code is going
to be added, we should think a bit about that before actually doing
it.

One solution would be to add code at LyX level to use OS-provided
hooks for opening documents. Then we could decide that these
OS-provided hooks override what LyX wants to do.

The other solution is to do it in the python script. However, I do not
know what abilities python has to discover these things. I do not like
much the code that searches the registry in windows.

JMarc


Re: Python version of configure script (preview version)

2005-09-16 Thread Angus Leeming
Jean-Marc Lasgouttes wrote:
> Concerning Bo's remark that a lot of win32/mac specific code is
> going to be added, we should think a bit about that before actually
> doing it.
> 
> One solution would be to add code at LyX level to use OS-provided
> hooks for opening documents. Then we could decide that these
> OS-provided hooks override what LyX wants to do.
> 
> The other solution is to do it in the python script. However, I do
> not know what abilities python has to discover these things. I do
> not like much the code that searches the registry in windows.

I think that we should have all this stuff outside of LyX itself. All
LyX needs is to be able to find an executable and to know how to
invoke it. LyXRC::path_prefix and the converters provide us with
everything we need, no?

I agree that the registry stuff is ugly. Individual apps store stuf in
the registry in different ways, so there wouldn't appear to be a
generic way to extract these data.

As for python's abilities in this regard, googling on "python search
registry" turns up lots of stuff. Eg

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/174627
http://www.oreillynet.com/pub/wlg/2608
http://www.microsoft.com/technet/scriptcenter/scripts/python/os/registry/default.mspx

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-16 Thread Angus Leeming
Angus Leeming wrote:
> As for python's abilities in this regard, googling on "python search
> registry" turns up lots of stuff. Eg
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/174627

Also
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146305

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-16 Thread Bo Peng
One problem with the rc approach is that re-configuration is required 
whenever users change a filetype association. Also, opening a file 
with its associated application is quite easy under windows. (There are APIs.)

Bo


Re: Python version of configure script (preview version)

2005-09-16 Thread Jean-Marc Lasgouttes
> "Bo" == Bo Peng <[EMAIL PROTECTED]> writes:

Bo> One problem with the rc approach is that re-configuration is
Bo> required whenever users change a filetype association. 

Not if you use "start" as viewer of any file that is supported by
windows (the problem is to discover that).

Bo> Also, opening a file with its associated application is quite easy
Bo> under windows. (There are APIs.)

Could you point us to the API? I found ShellExecute, but I did not
find a way to tell whether a file format is handled.

JMarc


Re: Python version of configure script (preview version)

2005-09-16 Thread Mike Meyer
In <[EMAIL PROTECTED]>, Bo Peng <[EMAIL PROTECTED]> typed:
> One problem with the rc approach is that re-configuration is required 
> whenever users change a filetype association. Also, opening a file 
> with its associated application is quite easy under windows. (There are APIs.)

Since Bo Peng didn't provide context, I groveled it out by chasing
down the message-id he's replying to. He is replying to a message
pointing out how to dig information out of the windows registry. From
what he says, I presume said information would be the type->viewer
map, and that reconfig should store the appropriate viewer in the LyX
preferences file.

A reconfig isn't required. Until that's done, LyX will just use the
"old" viewer. Who knows - that may even be the one the User wants? I
know I don't want LyX to use my default web browser for View>HTML.

On OS X, the solution is easy - you look for the "viewer"
/usr/bin/open. If you find it, you use it. I've got an "open" for Unix
that I've been using in LyX for the last week. I hope to have a
version with enough features that it's useful for end users done this
weekend. According to Jean-Marc Lasgouttes, you should use "start" on
Windows. Is that an external application? If so, then LyX just needs
to know how to launch external command line applications, so no
changes are needed. configure will need to be taught to check for
open/start, and use those for the viewer for everything if it finds
them.

  http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.


Re: Python version of configure script (preview version)

2005-09-16 Thread Bo Peng
Dear list,

Attached is a python version of lib/configure for 1.4.0 cvs. It is
written according to the m4 file at
http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/lib/configure.m4 .
Since I do not have access to lyx/cvs, I can only test it against
1.4.0pre1 from ftp.lyx.org.

Please test this script and report any problem here. Note that you
should diff sorted lyxrc.default files since configure.py does not
keep the original entry order.

Angus, could you add this file to the repository? 

Thanks.
Bo
#!/usr/bin/env python 
#
# Python version of the configure script
#
# Bo Peng ([EMAIL PROTECTED])
# Sep, 2005
#
import sys, os, re, shutil, glob

outfile = 'lyxrc.defaults'
rc_entries = ''
lyx_check_config = True
lyx_keep_temps = False
srcdir = ''
version_suffix = ''

def writeToFile(filename, lines, append = False):
  " utility function: write or append lines to filename "
  if append:
file = open(filename, 'a')
  else:
file = open(filename, 'w')
  file.write(lines)
  file.close()

def addToRC(lines):
  ''' utility function: shortcut for appending lines to outfile
add newline at the end of lines. 
  '''  
  if lines.strip() != '':
writeToFile(outfile, lines + '\n', append = True)

def removeFiles(filenames):
  '''utility function: 'rm -f'
ignore erroes when file does not exist, or is a directory.
  '''
  for file in filenames:
try:
  os.remove(file)
except:
  pass

def cmdOutput(cmd, line=-1):
  '''utility function: run a command and get its output
cmd: command to run
line: return the 'line' line. (with boundary checking)
  if line==-1 (default), return all lines.
  '''  
  fout = os.popen(cmd)
  output = fout.readlines()
  fout.close()
  if line < 0:
return output
  elif line >= len(output):
print "Output of command", cmd, "has less than", line+1, "lines"
sys.exit(4)
  return output[line]

## Parse the command line
for op in sys.argv[1:]:   # default shell/for list is $*, the options
  if op in [ '-help', '--help', '-h' ]:
print '''Usage: configure [options]
Options:
  --help   show this help lines
  --keep-temps keep temporary files (for debug. purposes)
  --without-latex-config   do not run LaTeX to determine configuration
  --with-version-suffix=suffix suffix of binary installed files
'''
sys.exit(0)
  elif op == '--without-latex-config':
lyx_check_config = False
  elif op == '--keep-temps':
lyx_keep_temps = True
  elif op[0:22] == '--with-version-suffix=':  # never mind if op is not long 
enough  
version_suffix = op[23:]
  else:
print "Unknown option", op
sys.exit(1)

## Checking for some echo oddities (ignored)
## The original script defines ac_n, ac_t and ac_c for 
## tab, newline etc, I just use python's print output. 

## I do not really know why this is useful, but we might as well keep it.
### NLS nuisances.
### Only set these to C if already set.  These must not be set unconditionally
### because not all systems understand e.g. LANG=C (notably SCO).
### Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
### Non-C LC_CTYPE values break the ctype check.
## 
os.environ['LANG'] = os.getenv('LANG', 'C')
os.environ['LC'] = os.getenv('LC_ALL', 'C')
os.environ['LC_MESSAGE'] = os.getenv('LC_MESSAGE', 'C')
os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')

## Guess the directory in which configure is located.
ac_prog = sys.argv[0]
srcdir = os.path.dirname(ac_prog)
if srcdir == '':  
  srcdir = '.'
if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
  print "configure: error: cannot find chkconfig.ltx script"
  sys.exit(1)

## Adjust PATH for Win32 (Cygwin)
#
use_cygwin_path_fix = ''
if sys.platform == 'cygwin':
  from tempfile import mkstemp
  fd, tmpfname = mkstemp(suffix='.ltx')
  os.write(fd, r'''
\documentstyle{article} 
\begin{document}\end{document} 
''')
  os.close(fd) 
  inpname = cmdOutput('cygpath -w ' + tmpfname, 0).replace('\\', '/').strip()
  # a wrapper file
  wfd, wtmpfname = mkstemp(suffix='.ltx')
  os.write(wfd, r'\input{' + inpname + '}' )
  os.close(wfd)
  check_err = False
  # grep Error
  for line in cmdOutput('latex ' + wtmpfname):
if line.count('Error') != 0:
  check_err = True
  break
  removeFiles( [ tmpfname, wtmpfname ])
  if check_err:
print "configure: cygwin detected; path correction"
srcdir = cmdOutput('cygpath -w ' + srcdir, 0).replace(r'\\', '').strip()
print "srcdir = ", srcdir
use_cygwin_path_fix = 'true'
  else:
print "configure: cygwin detected; path correction is not needed"
use_cygwin_path_fix = 'false'

 Create the build directories if necessary
for dir in ['bind', 'clipart', 'doc', 'examples', 'images', 'kbd', \
  'layouts', 'scripts', 'templates', 'ui' ]:
  if not os.path.isdir( dir ):
try:
  os.mkdir( dir)
except:
  print "Failed to create directory ", dir
  sys.exit(1)

## Write the first part of outfile
writeToFile(outfile, '''# This file has been 

Re: Python version of configure script (preview version)

2005-09-16 Thread Kayvan A. Sylvan
On Fri, Sep 16, 2005 at 09:12:20PM -0700, Bo Peng wrote:
> Since I do not have access to lyx/cvs, I can only test it against
> 1.4.0pre1 from ftp.lyx.org.

Well, you can always use

CVSROOT=:pserver:[EMAIL PROTECTED]:/var/cvs/lyx

Then "cvs login" (password is "lyx")

Failing that, you can always browse ftp://ftp.sylvan.com/pub/lyx/devel
and grab the latest CVS snapshot tar.bz2 file.

---Kayvan
-- 
Kayvan A. Sylvan  | Proud husband of   | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | "crown of her husband" | Robin Gregory (2/28/92)


Re: Python version of configure script (preview version)

2005-09-15 Thread Angus Leeming
Bo Peng wrote:

 Dear list,
 
 Attached is a Python version of the configure script. I currently do
 not have access to a windows machine with lyx on so I can not test it
 on windows. On my linux machine, it produces identical lyxrc.default
 and doc/LaTeXConfig.lyx but no further testing/proof-read of the code
 has been done.

Hi, Bo. Fantastic!

In anticipation of this being rolled into the LyX repository, can I get you
to drop an email to this list (replying to this mail would be perfect) in
which you state explicitly that you agree to licence your contributions
under the terms of the Gnu General Public Licence version 2 or later.

I'll then roll you into lib/generate_contributions.py.


Typically, our files contain blurb of the form:

# file configure.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.

# author Bo Peng
# Full author contact details are available in file CREDITS.

which makes it trivial to keep files in sync with licence and contact info.

==

Looking at the file...

 Adjust PATH for Win32 (Cygwin)
# i.e., change /cygdrive/c to c:
#
# FIXME: necessary? I assume that lyx/win does not like cygwin.

There's LyX/Win but there's also LyX/Cygwin. 


checkProg: the name of the executable will be latex.exe. See find_exe
in lib/scripts/lyxpreview_tools.py. In fact, I'd imagine that this file
could be renamed as scripts/tools.py and used by configure.py.


Rather than that enormous 
writeToFile(outfile, '''
# This file has been automatically generated by LyX' lib/configure
# script. It contains default settings that have been determined by
...
\\converter latex dvi %s latex
...
''' % (latex_to_dvi, latex_to_pdf, latex_to_html_command, 

I think it would maintenance easier to output each converter separately:

writeToFile(outfile, '\\converter latex dvi %s latex' % latex_to_dvi)

It's going to be very easy to get out of sync with the code as it is now.

Well done!
Regards,
-- 
Angus



Re: Python version of configure script (preview version)

2005-09-15 Thread Bo Peng
 In anticipation of this being rolled into the LyX repository, can I get you
 to drop an email to this list (replying to this mail would be perfect) in
 which you state explicitly that you agree to licence your contributions
 under the terms of the Gnu General Public Licence version 2 or later.

I agree to distribute this file (configure.py) and any further
contributions to the lyx project under  the terms of the Gnu General
Public Licence version 2 or later.

Bo Peng


Re: Python version of configure script (preview version)

2005-09-15 Thread Bo Peng
 I'll then roll you into lib/generate_contributions.py.

I guess further testing and optimization is needed first?

  Adjust PATH for Win32 (Cygwin)
 # i.e., change /cygdrive/c to c:
 #
 # FIXME: necessary? I assume that lyx/win does not like cygwin.
 There's LyX/Win but there's also LyX/Cygwin.

I will add this later.

 checkProg: the name of the executable will be latex.exe. See find_exe
 in lib/scripts/lyxpreview_tools.py. In fact, I'd imagine that this file
 could be renamed as scripts/tools.py and used by configure.py.

There are many platform-dependent things like this. I expect many
if os.platform == 'win32': to be added soon.

 Rather than that enormous ..
 I think it would maintenance easier to output each converter separately:
 
 writeToFile(outfile, '\\converter latex dvi %s latex' % latex_to_dvi)

You mean after each program is found? Actually, this can be put into
checkProg() as well.

 It's going to be very easy to get out of sync with the code as it is now.

Let us first see if this script is generating the right files under
linux, solaris, mac etc.

Cheers, 
Bo


Re: Python version of configure script (preview version)

2005-09-15 Thread Angus Leeming
Bo Peng wrote:

 In anticipation of this being rolled into the LyX repository, can I get
 you to drop an email to this list (replying to this mail would be
 perfect) in which you state explicitly that you agree to licence your
 contributions under the terms of the Gnu General Public Licence version
 2 or later.

 I agree to distribute this file (configure.py) and any further
 contributions to the lyx project under  the terms of the Gnu General
 Public Licence version 2 or later.

Thanks, Bo.

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-15 Thread Angus Leeming
Bo Peng wrote:

 I'll then roll you into lib/generate_contributions.py.
 I guess further testing and optimization is needed first?

We're in feature freeze for LyX 1.4 right now, so configure.py won't get
added to the distribution till that is out. That said, I can't see why it
couldn't be added to the repository right now. Would make it easier to get
people to test it and for you to have a back up.

Let's see what others think.

Meanwhile, I've added you to generate_contributions.py anyway.
-- 
Angus




Re: Python version of configure script (preview version)

2005-09-15 Thread Bo Peng
 That said, I can't see why it couldn't be added to the repository right now. 
 Would make it easier to get people to test it and for you to have a back up.

Not a big deal. It is just that this version is a 'direct translation' of the
bsh version and there will be big changes once we know it is working
as expected. Anyway, let us add this to the repository and plan for 
the changes.

BTW, I am glad to know 1.4 is coming out. It's been a long time since
version 1.3.

Bo


Re: Python version of configure script (preview version)

2005-09-15 Thread Angus Leeming
Bo Peng wrote:

 Dear list,
 
 Attached is a Python version of the configure script. I currently do
 not have access to a windows machine with lyx on so I can not test it
 on windows. On my linux machine, it produces identical lyxrc.default
 and doc/LaTeXConfig.lyx but no further testing/proof-read of the code
 has been done.

Here's the output from my linux box together with a small fix.

$ diff -u -Bbw ../build/lib/lyxrc.defaults .  lyxrc.diff
$ diff -u configure_orig.py configure.py  configure.diff

-- 
Angus--- configure_orig.py	2005-09-15 23:13:54.0 +0100
+++ configure.py	2005-09-15 23:14:05.0 +0100
@@ -207,7 +207,7 @@
 if GHOSTVIEW in [ 'gv', 'ghostview']:
   PS_VIEWER = GHOSTVIEW + ' -swap'
 else:
-  PS_VIEWER = GHISTVIEW
+  PS_VIEWER = GHOSTVIEW
 
 EPS_VIEWER = GHOSTVIEW
 
--- ../build/lib/lyxrc.defaults	2005-09-09 18:09:47.0 +0100
+++ ./lyxrc.defaults	2005-09-15 23:14:59.0 +0100
@@ -4,94 +5,80 @@
 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
 # override the values given here.
-\Format asciichess ascPlain text (chess output)   	kedit
-\Format asciiimage ascPlain text (image)  	kedit
-\Format asciixfig  ascPlain text (Xfig output)	kedit
-\Format agragr Grace   none	none
-\Format bmpbmp BMP kview	gimp
-\Format datedate command   	
-\Format dateouttmpdate (output)  	kedit
-\Format docbooksgmlDocBookB  	kedit
-\Format docbook-xml xml   Docbook (XML)  	kedit
-\Format dvidvi DVID  xdvi	
-\Format epseps EPS kghostview	
-\Format fax  Fax 	
-\Format fenfen FEN none	none
-\Format figfig FIG xfig	xfig
-\Format gifgif GIF kview	gimp
-\Format html   htmlHTML   H  none	
-\Format jpgjpg JPEGkview	gimp
-\Format latex  tex LaTeX  L  	kedit
-\Format linuxdoc   sgmlLinuxDoc   x  	kedit
-\Format lyxlyx LyX lyx	lyx
-\Format lyxpreview lyxpreview LyX Preview	
-\Format literate   nw  NoWeb  N  	kedit
-\Format pbmpbm PBM kview	gimp
-\Format pdfpdfPDF (ps2pdf)  P  acroread	
-\Format pdf2   pdfPDF (pdflatex)F  acroread	
-\Format pdf3   pdfPDF (dvipdfm) m  acroread	
-\Format pdftex pdftex_t PDFTEX 	
-\Format pgmpgm PGM kview	gimp
-\Format pngpng PNG kview	gimp
-\Format ppmppm PPM kview	gimp
-\Format program  Program 	
-\Format ps ps  Postscript t  kghostview	
-\Format pstex  pstex_t PSTEX   	
-\Format tgif   obj Tgiftgif	tgif
-\Format sxwsxwOpenOffice.Org Writer O  	
-\Format text   txtPlain texta  	kedit
-\Format textparagraph txt Plain text (paragraphs) 	kedit
-\Format tiff   tif TIFFkview	gimp
-\Format word   docMS Word   W  	
-\Format wordhtml   html   MS Word (HTML) 
-\Format xbmxbm XBM kview	gimp
-\Format xpmxpm XPM kview	gimp
+\Format text	  txt	ASCII		A
+\Format textparagraph txt ASCII(paragraphs)	
+\Format docbook  sgml	DocBook		B
+\Format bmp  bmp	BMP		
+\Format dvi	  dvi	DVI		D
+\Format eps	  eps	EPS		
+\Format fax	  	Fax		
+\Format fig	  fig	XFig		
+\Format agr  agr	GRACE		
+\Format html	  html	HTML		H
+\Format gif	  gif	GIF		
+\Format jpg	  jpg	JPG		
+\Format latex	  tex	LaTeX		L
+\Format linuxdoc sgml	LinuxDoc	x
+\Format lyx  lyx	LyX		
+\Format literate nw	NoWeb		N
+\Format pdf	  pdf	PDF		P
+\Format pdf2	  pdf  PDF (pdflatex)	F
+\Format pdf3	  pdf  PDF (dvipdfm)	m
+\Format png	  png	PNG		
+\Format ppm	  ppm	PPM		
+\Format pgm	  pgm	PGM		
+\Format pbm	  pbm	PBM		
+\Format ps	  ps	Postscript	t
+\Format program  	Program		
+\Format tgif obj	TGIF		
+\Format tiff tif	TIFF		
+\Format word	  doc	Word		W
+\Format xbm	  xbm	XBM		
+\Format xpm	  xpm	XPM		
+\Format lyxpreview	lyxpreview	LyX Preview		
 
-\converter date   dateoutdate +%d-%m-%Y  $$o	
-\converter docbookdocbook-xml cp $$i $$o xml
-\converter docbookdvidb2dvi $$i	
-\converter docbookhtml   db2html $$i	
-\converter dvipdf3   dvipdfm $$i	
-\converter dvips dvips -o $$o $$i	
-\converter fenasciichess python $$s/scripts/fen2ascii.py $$i $$o	
-\converter figpdftex sh $$s/scripts/fig2pdftex.sh $$i $$o	

Re: Python version of configure script (preview version)

2005-09-15 Thread Bo Peng
 Here's the output from my linux box together with a small fix.
 
 $ diff -u -Bbw ../build/lib/lyxrc.defaults .  lyxrc.diff
 $ diff -u configure_orig.py configure.py  configure.diff

How do you like the attached new version? checkProg() now
handles rc file and all info about checked program is now
complete at one function call.

The speed problem has been resolved. configure.py runs
at least as fast as the bsh version now.

Bo
#!/usr/bin/env python 
#
# The original script is a hand-made configure script written in bsh. 
# It contains a lot of code stolen from GNU autoconf. The author removed 
# all the code that was not useful for configuring a LyX installation.
#
# This is a python translation of the original bsh configure script
# It is supposed to be cleaner, quicker and can avoid the use of
# mingw on windows system. This will make the installation
# process less painful under windows.
#
# Bo Peng ([EMAIL PROTECTED])
# Last Modified: Sep, 2005
# 
# Implementation:
#   -- almost line to line translation, almost all variables
#  have the same name and meaning as before.
#   -- Use functions to clean up the (original ugly) code
#   -- use python::re module to replace sed
#   -- use os.system for system call.
#
# Known Bugs:
#   -- none
#

import sys, os, re, shutil

outfile = 'lyxrc.defaults'
rc_entries = ''
lyx_check_config = True
lyx_keep_temps = False
srcdir = ''
version_suffix = ''

# utility function.
# save a few lines.
def writeToFile(filename, lines, append = False):
  if append:
file = open(filename, 'a')
  else:
file = open(filename, 'w')
  file.write(lines)
  file.close()

# utility function, 'rm -f'
def removeFiles(filenames):
  for file in filenames:
try:
  os.remove(file)
except:
  pass

 Parse the command line
for op in sys.argv[1:]:   # default shell/for list is $*, the options
  if op in [ '-help', '--help', '-h' ]:
print '''Usage: configure [options]
Options:
  --help   show this help lines
  --keep-temps keep temporary files (for debug. purposes)
  --without-latex-config   do not run LaTeX to determine configuration
  --with-version-suffix=suffix suffix of binary installed files
'''
sys.exit(0)
  elif op == '--without-latex-config':
lyx_check_config = False
  elif op == '--keep-temps':
lyx_keep_temps = True
  elif op[0:22] == '--with-version-suffix=':  # never mind if op is not long 
enough  
version_suffix = op[23:]
  else:
print Unknown option, op
sys.exit(1)

 Checking for some echo oddities (ignored)
## The original script defines ac_n, ac_t and ac_c for 
## tab, newline etc, I just use python's print output. 

 I do not really know why this is useful, but we might as well keep it.
### NLS nuisances.
### Only set these to C if already set.  These must not be set unconditionally
### because not all systems understand e.g. LANG=C (notably SCO).
### Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
### Non-C LC_CTYPE values break the ctype check.
## 
os.environ['LANG'] = os.getenv('LANG', 'C')
os.environ['LC'] = os.getenv('LC_ALL', 'C')
os.environ['LC_MESSAGE'] = os.getenv('LC_MESSAGE', 'C')
os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')

 Guess the directory in which configure is located.
ac_prog = sys.argv[0]
srcdir = os.path.dirname(ac_prog)
if srcdir == '':  
  srcdir = '.'
if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
  print configure: error: cannot find chkconfig.ltx script
  sys.exit(1)

 Adjust PATH for Win32 (Cygwin)
# i.e., change /cygdrive/c to c:
#
# FIXME: necessary? I assume that lyx/win does not like cygwin.

## Create the build directories if necessary
for dir in ['bind', 'clipart', 'doc', 'examples', 'help', \
  'images', 'kbd', 'layouts', 'reLyX' , 'scripts', 'templates', \
  'ui', 'xfonts']:
  if not os.path.isdir( dir ):
try:
  os.mkdir( dir)
except:
  print Failed to create directory , dir
  sys.exit(1)

##
## Write the first part of outfile
writeToFile(outfile, '''
# This file has been automatically generated by LyX' lib/configure
# script. It contains default settings that have been determined by
# examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
# want to customize LyX, make a copy of the file LYXDIR/lyxrc as
# ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
# override the values given here.
\\Format text txt   ASCII   A
\\Format textparagraph txt ASCII(paragraphs)
\\Format docbook  sgml  DocBook B
\\Format bmp  bmp   BMP 
\\Format dvi  dvi   DVI D
\\Format eps  eps   EPS 
\\Format fax  Fax 
\\Format fig  fig   XFig
\\Format agr  agr   GRACE   
\\Format html html  HTMLH
\\Format gif  gif   GIF 
\\Format jpg  jpg   JPG 
\\Format latextex   LaTeX   L
\\Format linuxdoc sgml  

Re: Python version of configure script (preview version)

2005-09-15 Thread Angus Leeming
Bo Peng wrote:

> Dear list,
> 
> Attached is a Python version of the configure script. I currently do
> not have access to a windows machine with lyx on so I can not test it
> on windows. On my linux machine, it produces identical lyxrc.default
> and doc/LaTeXConfig.lyx but no further testing/proof-read of the code
> has been done.

Hi, Bo. Fantastic!

In anticipation of this being rolled into the LyX repository, can I get you
to drop an email to this list (replying to this mail would be perfect) in
which you state explicitly that you agree to licence your contributions
under the terms of the Gnu General Public Licence version 2 or later.

I'll then roll you into lib/generate_contributions.py.


Typically, our files contain blurb of the form:

# file configure.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.

# author Bo Peng
# Full author contact details are available in file CREDITS.

which makes it trivial to keep files in sync with licence and contact info.

==

Looking at the file...

 Adjust PATH for Win32 (Cygwin)
# i.e., change /cygdrive/c to c:
#
# FIXME: necessary? I assume that lyx/win does not like cygwin.

There's LyX/Win but there's also LyX/Cygwin. 


checkProg: the name of the executable will be "latex.exe". See "find_exe"
in lib/scripts/lyxpreview_tools.py. In fact, I'd imagine that this file
could be renamed as scripts/tools.py and used by configure.py.


Rather than that enormous 
writeToFile(outfile, '''
# This file has been automatically generated by LyX' lib/configure
# script. It contains default settings that have been determined by
...
\\converter latex dvi "%s" "latex"
...
''' % (latex_to_dvi, latex_to_pdf, latex_to_html_command, 

I think it would maintenance easier to output each converter separately:

writeToFile(outfile, '\\converter latex dvi "%s" "latex"' % latex_to_dvi)

It's going to be very easy to get out of sync with the code as it is now.

Well done!
Regards,
-- 
Angus



Re: Python version of configure script (preview version)

2005-09-15 Thread Bo Peng
> In anticipation of this being rolled into the LyX repository, can I get you
> to drop an email to this list (replying to this mail would be perfect) in
> which you state explicitly that you agree to licence your contributions
> under the terms of the Gnu General Public Licence version 2 or later.

I agree to distribute this file (configure.py) and any further
contributions to the lyx project under  the terms of the Gnu General
Public Licence version 2 or later.

Bo Peng


Re: Python version of configure script (preview version)

2005-09-15 Thread Bo Peng
> I'll then roll you into lib/generate_contributions.py.

I guess further testing and optimization is needed first?

>  Adjust PATH for Win32 (Cygwin)
> # i.e., change /cygdrive/c to c:
> #
> # FIXME: necessary? I assume that lyx/win does not like cygwin.
> There's LyX/Win but there's also LyX/Cygwin.

I will add this later.

> checkProg: the name of the executable will be "latex.exe". See "find_exe"
> in lib/scripts/lyxpreview_tools.py. In fact, I'd imagine that this file
> could be renamed as scripts/tools.py and used by configure.py.

There are many platform-dependent things like this. I expect many
"if os.platform == 'win32':" to be added soon.

> Rather than that enormous ..
> I think it would maintenance easier to output each converter separately:
> 
> writeToFile(outfile, '\\converter latex dvi "%s" "latex"' % latex_to_dvi)

You mean after each program is found? Actually, this can be put into
checkProg() as well.

> It's going to be very easy to get out of sync with the code as it is now.

Let us first see if this script is generating the right files under
linux, solaris, mac etc.

Cheers, 
Bo


Re: Python version of configure script (preview version)

2005-09-15 Thread Angus Leeming
Bo Peng wrote:

>> In anticipation of this being rolled into the LyX repository, can I get
>> you to drop an email to this list (replying to this mail would be
>> perfect) in which you state explicitly that you agree to licence your
>> contributions under the terms of the Gnu General Public Licence version
>> 2 or later.

> I agree to distribute this file (configure.py) and any further
> contributions to the lyx project under  the terms of the Gnu General
> Public Licence version 2 or later.

Thanks, Bo.

-- 
Angus



Re: Python version of configure script (preview version)

2005-09-15 Thread Angus Leeming
Bo Peng wrote:

>> I'll then roll you into lib/generate_contributions.py.
> I guess further testing and optimization is needed first?

We're in feature freeze for LyX 1.4 right now, so configure.py won't get
added to the distribution till that is out. That said, I can't see why it
couldn't be added to the repository right now. Would make it easier to get
people to test it and for you to have a back up.

Let's see what others think.

Meanwhile, I've added you to generate_contributions.py anyway.
-- 
Angus




Re: Python version of configure script (preview version)

2005-09-15 Thread Bo Peng
> That said, I can't see why it couldn't be added to the repository right now. 
> Would make it easier to get people to test it and for you to have a back up.

Not a big deal. It is just that this version is a 'direct translation' of the
bsh version and there will be big changes once we know it is working
as expected. Anyway, let us add this to the repository and plan for 
the changes.

BTW, I am glad to know 1.4 is coming out. It's been a long time since
version 1.3.

Bo


Re: Python version of configure script (preview version)

2005-09-15 Thread Angus Leeming
Bo Peng wrote:

> Dear list,
> 
> Attached is a Python version of the configure script. I currently do
> not have access to a windows machine with lyx on so I can not test it
> on windows. On my linux machine, it produces identical lyxrc.default
> and doc/LaTeXConfig.lyx but no further testing/proof-read of the code
> has been done.

Here's the output from my linux box together with a small fix.

$ diff -u -Bbw ../build/lib/lyxrc.defaults . > lyxrc.diff
$ diff -u configure_orig.py configure.py > configure.diff

-- 
Angus--- configure_orig.py	2005-09-15 23:13:54.0 +0100
+++ configure.py	2005-09-15 23:14:05.0 +0100
@@ -207,7 +207,7 @@
 if GHOSTVIEW in [ 'gv', 'ghostview']:
   PS_VIEWER = GHOSTVIEW + ' -swap'
 else:
-  PS_VIEWER = GHISTVIEW
+  PS_VIEWER = GHOSTVIEW
 
 EPS_VIEWER = GHOSTVIEW
 
--- ../build/lib/lyxrc.defaults	2005-09-09 18:09:47.0 +0100
+++ ./lyxrc.defaults	2005-09-15 23:14:59.0 +0100
@@ -4,94 +5,80 @@
 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
 # override the values given here.
-\Format asciichess asc"Plain text (chess output)"  "" ""	"kedit"
-\Format asciiimage asc"Plain text (image)" "" ""	"kedit"
-\Format asciixfig  asc"Plain text (Xfig output)"   "" ""	"kedit"
-\Format agragr Grace  "" "none"	"none"
-\Format bmpbmp BMP"" "kview"	"gimp"
-\Format date   "" "date command"  "" ""	""
-\Format dateouttmp"date (output)" "" ""	"kedit"
-\Format docbooksgmlDocBookB  ""	"kedit"
-\Format docbook-xml xml   "Docbook (XML)" "" ""	"kedit"
-\Format dvidvi DVID  "xdvi"	""
-\Format epseps EPS"" "kghostview"	""
-\Format fax""  Fax"" ""	""
-\Format fenfen FEN"" "none"	"none"
-\Format figfig FIG"" "xfig"	"xfig"
-\Format gifgif GIF"" "kview"	"gimp"
-\Format html   htmlHTML   H  "none"	""
-\Format jpgjpg JPEG   "" "kview"	"gimp"
-\Format latex  tex LaTeX  L  ""	"kedit"
-\Format linuxdoc   sgmlLinuxDoc   x  ""	"kedit"
-\Format lyxlyx LyX"" "lyx"	"lyx"
-\Format lyxpreview lyxpreview "LyX Preview"   "" ""	""
-\Format literate   nw  NoWeb  N  ""	"kedit"
-\Format pbmpbm PBM"" "kview"	"gimp"
-\Format pdfpdf"PDF (ps2pdf)"  P  "acroread"	""
-\Format pdf2   pdf"PDF (pdflatex)"F  "acroread"	""
-\Format pdf3   pdf"PDF (dvipdfm)" m  "acroread"	""
-\Format pdftex pdftex_t PDFTEX"" ""	""
-\Format pgmpgm PGM"" "kview"	"gimp"
-\Format pngpng PNG"" "kview"	"gimp"
-\Format ppmppm PPM"" "kview"	"gimp"
-\Format program""  Program"" ""	""
-\Format ps ps  Postscript t  "kghostview"	""
-\Format pstex  pstex_t PSTEX  "" ""	""
-\Format tgif   obj Tgif   "" "tgif"	"tgif"
-\Format sxwsxw"OpenOffice.Org Writer" O  ""	""
-\Format text   txt"Plain text"a  ""	"kedit"
-\Format textparagraph txt "Plain text (paragraphs)""" ""	"kedit"
-\Format tiff   tif TIFF   "" "kview"	"gimp"
-\Format word   doc"MS Word"   W  ""	""
-\Format wordhtml   html   "MS Word (HTML)""" """"
-\Format xbmxbm XBM"" "kview"	"gimp"
-\Format xpmxpm XPM"" "kview"	"gimp"
+\Format text	  txt	ASCII		A
+\Format textparagraph txt ASCII(paragraphs)	""
+\Format docbook  sgml	DocBook		B
+\Format bmp  bmp	BMP		""
+\Format dvi	  dvi	DVI		D
+\Format eps	  eps	EPS		""
+\Format fax	  ""	Fax		""
+\Format fig	  fig	XFig		""
+\Format agr  agr	GRACE		""
+\Format html	  html	HTML		H
+\Format gif	  gif	GIF		""
+\Format jpg	  jpg	JPG		""
+\Format latex	  tex	LaTeX		L
+\Format linuxdoc sgml	LinuxDoc	x
+\Format lyx  lyx	LyX		""
+\Format literate nw	NoWeb		N
+\Format pdf	  pdf	PDF		P
+\Format pdf2	  pdf  "PDF (pdflatex)"	F
+\Format pdf3	  pdf  "PDF (dvipdfm)"	m
+\Format png	  png	PNG		""
+\Format ppm	  ppm	PPM		""
+\Format pgm	  pgm	PGM		""
+\Format pbm	  pbm	PBM		""
+\Format ps	  ps	Postscript	t
+\Format program  ""	Program		""
+\Format tgif obj	TGIF		""
+\Format tiff tif	TIFF		""
+\Format word	  doc	Word		W
+\Format xbm	  xbm	XBM		""
+\Format xpm	  xpm	XPM		""
+\Format lyxpreview	lyxpreview	"LyX Preview"		""
 
-\converter date   dateout"date +%d-%m-%Y > $$o"	""
-\converter docbookdocbook-xml "cp $$i $$o" "xml"
-\converter 

Re: Python version of configure script (preview version)

2005-09-15 Thread Bo Peng
> Here's the output from my linux box together with a small fix.
> 
> $ diff -u -Bbw ../build/lib/lyxrc.defaults . > lyxrc.diff
> $ diff -u configure_orig.py configure.py > configure.diff

How do you like the attached new version? checkProg() now
handles rc file and all info about checked program is now
complete at one function call.

The speed problem has been resolved. configure.py runs
at least as fast as the bsh version now.

Bo
#!/usr/bin/env python 
#
# The original script is a hand-made configure script written in bsh. 
# It contains a lot of code stolen from GNU autoconf. The author removed 
# all the code that was not useful for configuring a LyX installation.
#
# This is a python translation of the original bsh configure script
# It is supposed to be cleaner, quicker and can avoid the use of
# mingw on windows system. This will make the installation
# process less painful under windows.
#
# Bo Peng ([EMAIL PROTECTED])
# Last Modified: Sep, 2005
# 
# Implementation:
#   -- almost line to line translation, almost all variables
#  have the same name and meaning as before.
#   -- Use functions to clean up the (original ugly) code
#   -- use python::re module to replace sed
#   -- use os.system for system call.
#
# Known Bugs:
#   -- none
#

import sys, os, re, shutil

outfile = 'lyxrc.defaults'
rc_entries = ''
lyx_check_config = True
lyx_keep_temps = False
srcdir = ''
version_suffix = ''

# utility function.
# save a few lines.
def writeToFile(filename, lines, append = False):
  if append:
file = open(filename, 'a')
  else:
file = open(filename, 'w')
  file.write(lines)
  file.close()

# utility function, 'rm -f'
def removeFiles(filenames):
  for file in filenames:
try:
  os.remove(file)
except:
  pass

 Parse the command line
for op in sys.argv[1:]:   # default shell/for list is $*, the options
  if op in [ '-help', '--help', '-h' ]:
print '''Usage: configure [options]
Options:
  --help   show this help lines
  --keep-temps keep temporary files (for debug. purposes)
  --without-latex-config   do not run LaTeX to determine configuration
  --with-version-suffix=suffix suffix of binary installed files
'''
sys.exit(0)
  elif op == '--without-latex-config':
lyx_check_config = False
  elif op == '--keep-temps':
lyx_keep_temps = True
  elif op[0:22] == '--with-version-suffix=':  # never mind if op is not long 
enough  
version_suffix = op[23:]
  else:
print "Unknown option", op
sys.exit(1)

 Checking for some echo oddities (ignored)
## The original script defines ac_n, ac_t and ac_c for 
## tab, newline etc, I just use python's print output. 

 I do not really know why this is useful, but we might as well keep it.
### NLS nuisances.
### Only set these to C if already set.  These must not be set unconditionally
### because not all systems understand e.g. LANG=C (notably SCO).
### Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
### Non-C LC_CTYPE values break the ctype check.
## 
os.environ['LANG'] = os.getenv('LANG', 'C')
os.environ['LC'] = os.getenv('LC_ALL', 'C')
os.environ['LC_MESSAGE'] = os.getenv('LC_MESSAGE', 'C')
os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')

 Guess the directory in which configure is located.
ac_prog = sys.argv[0]
srcdir = os.path.dirname(ac_prog)
if srcdir == '':  
  srcdir = '.'
if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
  print "configure: error: cannot find chkconfig.ltx script"
  sys.exit(1)

 Adjust PATH for Win32 (Cygwin)
# i.e., change /cygdrive/c to c:
#
# FIXME: necessary? I assume that lyx/win does not like cygwin.

## Create the build directories if necessary
for dir in ['bind', 'clipart', 'doc', 'examples', 'help', \
  'images', 'kbd', 'layouts', 'reLyX' , 'scripts', 'templates', \
  'ui', 'xfonts']:
  if not os.path.isdir( dir ):
try:
  os.mkdir( dir)
except:
  print "Failed to create directory ", dir
  sys.exit(1)

##
## Write the first part of outfile
writeToFile(outfile, '''
# This file has been automatically generated by LyX' lib/configure
# script. It contains default settings that have been determined by
# examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
# want to customize LyX, make a copy of the file LYXDIR/lyxrc as
# ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
# override the values given here.
\\Format text txt   ASCII   A
\\Format textparagraph txt ASCII(paragraphs)""
\\Format docbook  sgml  DocBook B
\\Format bmp  bmp   BMP ""
\\Format dvi  dvi   DVI D
\\Format eps  eps   EPS ""
\\Format fax  ""Fax ""
\\Format fig  fig   XFig""
\\Format agr  agr   GRACE   ""
\\Format html html  HTMLH
\\Format gif  gif   GIF ""
\\Format jpg  jpg   JPG ""
\\Format latextex   LaTeX