Re: [Rd] Robust, platform independent method to check for python

2009-06-27 Thread Gabor Grothendieck
If you can assume its on your path then try this:

pth - sapply(strsplit(Sys.getenv(PATH), ;), function(x)
file.path(x, python.exe, fsep = \\))
pth[file.exists(pth)][1]

On Sat, Jun 27, 2009 at 11:44 AM, Carlos J. Gil
Bellostac...@datanalytics.com wrote:
 Hello,

 I have been unsuccessfully struggling for a programmatical method to
 find out whether and where Python is installed.

 The reason is that I am developing a package that depends on python.

 On UNIX/UNIX-like systems I can quite safely assume that python is
 directly callable via system if installed.

 My main problems is Windows, though...

 Has anybody faced this problem before?

 Best regards,

 Carlos J. Gil Bellosta
 http://www.datanalytics.com

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Robust, platform independent method to check for python

2009-06-27 Thread Romain Francois
I actually have the same question, about ant. I assume this would be 
what the SystemRequirements field in a package DESCRIPTION is for, but 
at the moment it seems unused. Is there a plan about this ?


Romain

On 06/27/2009 05:44 PM, Carlos J. Gil Bellosta wrote:

Hello,

I have been unsuccessfully struggling for a programmatical method to
find out whether and where Python is installed.

The reason is that I am developing a package that depends on python.

On UNIX/UNIX-like systems I can quite safely assume that python is
directly callable via system if installed.

My main problems is Windows, though...

Has anybody faced this problem before?

Best regards,

Carlos J. Gil Bellosta
http://www.datanalytics.com
   


--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Robust, platform independent method to check for python

2009-06-27 Thread Steve Weston
You can also try to find Python on Windows machines by
reading the registry using the R readRegistry function (added
sometime around R 2.7.0, I think).  You can't count on the
information being there, but it often is, depending on how
Python was installed.

Using the registry seems to work better than using PATH,
since the standard Python installer doesn't update PATH,
although the ActiveState Python installer does.  But both
approaches can fail, depending on the options that were
specified when Python was installed.

Good luck,

- Steve


On Sat, Jun 27, 2009 at 12:01 PM, Gabor
Grothendieckggrothendi...@gmail.com wrote:
 If you can assume its on your path then try this:

 pth - sapply(strsplit(Sys.getenv(PATH), ;), function(x)
 file.path(x, python.exe, fsep = \\))
 pth[file.exists(pth)][1]

 On Sat, Jun 27, 2009 at 11:44 AM, Carlos J. Gil
 Bellostac...@datanalytics.com wrote:
 Hello,

 I have been unsuccessfully struggling for a programmatical method to
 find out whether and where Python is installed.

 The reason is that I am developing a package that depends on python.

 On UNIX/UNIX-like systems I can quite safely assume that python is
 directly callable via system if installed.

 My main problems is Windows, though...

 Has anybody faced this problem before?

 Best regards,

 Carlos J. Gil Bellosta
 http://www.datanalytics.com

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel




-- 
Steve Weston
REvolution Computing
One Century Tower | 265 Church Street, Suite 1006
New Haven, CT  06510
P: 203-777-7442 x266 | www.revolution-computing.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Robust, platform independent method to check for python

2009-06-27 Thread Gabor Grothendieck
I think that most python installations won't have a
registry key set.  I have python 2.6 and 2.5 on my
machine but searching the registry found no
occurrence of the string python.   At least the path method
has the advantage that if its not set then the user
only has to modify the path whereas if its not
in the registry the user would have to reinstall python
and to make it worse they would have to use
specific distributions that install a key. Furthermore
they would be stuck if they can't access the registry
on their machine.

Also if its on the path then you don't actually need
to find its location as system(python ...) or
shell(python ...) should find it itself.  For
example, if you have python on  your path try
   system(python --help)
from the R command line.

Depending on how much work you are willing to do
you could check the path, the registry and common
locations such as c:\Python26, c:\Python,
c:\Program Files\Python, etc. and provide a
pythonpath= argument to your function so if even
all those don't work the user can supply the path.

Here is how two other packages handle this

1. read.xls in the gdata package uses perl and the way
it works is to assume that perl is on the path and if
not there is an argument to the function so that the
user can specify its location.

2. The rSymPy package uses python via jython (python
running on java) and actually includes the entire jython
in the package itself to eliminate external dependencies.
If your python code is pure python it should run on jython
in which case you could simply add rSymPy as a dependency
and then use jython from it.  That would work cross platform
and the only dependency eternal to R would be java itself
but that is nearly universal -- much more prevalent than pytyhon.

One thing that would be convenient would be if R had a
package for each of the common scripting languages
such as perl, python and ruby that included the respective
language processor.  This would be help even if
there were no sophisticated interface (as in the case with
tcl) simply so that other packages that provide interfaces to
code in those languages could know where the
scripting language processor is located.

On Sat, Jun 27, 2009 at 1:51 PM, Steve
Westonst...@revolution-computing.com wrote:
 You can also try to find Python on Windows machines by
 reading the registry using the R readRegistry function (added
 sometime around R 2.7.0, I think).  You can't count on the
 information being there, but it often is, depending on how
 Python was installed.

 Using the registry seems to work better than using PATH,
 since the standard Python installer doesn't update PATH,
 although the ActiveState Python installer does.  But both
 approaches can fail, depending on the options that were
 specified when Python was installed.

 Good luck,

 - Steve


 On Sat, Jun 27, 2009 at 12:01 PM, Gabor
 Grothendieckggrothendi...@gmail.com wrote:
 If you can assume its on your path then try this:

 pth - sapply(strsplit(Sys.getenv(PATH), ;), function(x)
 file.path(x, python.exe, fsep = \\))
 pth[file.exists(pth)][1]

 On Sat, Jun 27, 2009 at 11:44 AM, Carlos J. Gil
 Bellostac...@datanalytics.com wrote:
 Hello,

 I have been unsuccessfully struggling for a programmatical method to
 find out whether and where Python is installed.

 The reason is that I am developing a package that depends on python.

 On UNIX/UNIX-like systems I can quite safely assume that python is
 directly callable via system if installed.

 My main problems is Windows, though...

 Has anybody faced this problem before?

 Best regards,

 Carlos J. Gil Bellosta
 http://www.datanalytics.com

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel




 --
 Steve Weston
 REvolution Computing
 One Century Tower | 265 Church Street, Suite 1006
 New Haven, CT  06510
 P: 203-777-7442 x266 | www.revolution-computing.com

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Robust, platform independent method to check for python

2009-06-27 Thread Steve Weston
On Sat, Jun 27, 2009 at 4:04 PM, Gabor
Grothendieckggrothendi...@gmail.com wrote:
 I think that most python installations won't have a
 registry key set.  I have python 2.6 and 2.5 on my
 machine but searching the registry found no
 occurrence of the string python.   At least the path method

The Python 2.5 installer from python.org used to
use the registry key Software\Python\PythonCore,
at least on Windows XP and 2000.  But I don't believe
it ever sets PATH.  I was simply suggesting that if
you want the greatest likelihood of finding python.exe,
you may want to try both methods.  It all depends on
how bullet-proof you want your installation procedure
to be.

 has the advantage that if its not set then the user
 only has to modify the path whereas if its not
 in the registry the user would have to reinstall python
 and to make it worse they would have to use
 specific distributions that install a key. Furthermore
 they would be stuck if they can't access the registry
 on their machine.

If I was to use only one of the two methods, I would
use PATH because it's fairly easy to set PATH, and
it's a more portable solution.  But many of our
Windows users don't know about PATH, so it may
be worth checking in the registry if python.exe isn't
in PATH, rather than requiring the user to do some
manual reconfiguration.

But Vista seems to have changed the registry in
some confusing ways.  It may not be worth the
trouble.

-- 
Steve Weston
REvolution Computing
One Century Tower | 265 Church Street, Suite 1006
New Haven, CT  06510
P: 203-777-7442 x266 | www.revolution-computing.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel