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 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


Re: [Rd] Qs: The list of arguments, wrapping functions...

2009-05-19 Thread Steve Weston
On Tue, May 19, 2009 at 4:22 PM, Kynn Jones kyn...@gmail.com wrote:

 2. I have a package in which most of the functions have the form:

 the.function - function(some, list, of, params) {
    return( some.other.function(the.list.of.params.to.this.function));
 }

 Is there a way that I can use a loop to define all these functions?

How about something like this:

funnames - c('f1', 'f2', 'f3')

funfactory - function(n) {
  f - function(...) NULL
  body(f) - substitute(REPLACE(...), list(REPLACE=as.name(n)))
  f
}

funlist - lapply(funnames, funfactory)

funlist is a list of function objects that wrap calls to the
named functions.

 In general, I'm looking for all the information I can find on the subject of
 dynamic function definition (i.e. using code to automate the definition of
 functions at runtime).  I'm most interested in introspection facilities and
 dynamic code generation.  E.g. is it possible to write a module that
 redefines itself when sourced?  Or can a function redefine itself when
 first run?  Or how can a function find out about how it was called?

You should read chapter 6 of the R Language Definition manual, which is
titled Computing on the language.

-- 
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