<div>Whether rpy is installed or not, can simple be checked&nbsp;with try and except commands. There maybe better way, but it is working in posix and nt. In nt, pywin32&nbsp;also requires in order to run rpy. </div>
<div>&nbsp;</div>
<div>&nbsp; # I have very weak info about mac os. I&nbsp;am assuming that in order to run rpy in mac,&nbsp;pywin32 is also required, right?<br>&nbsp; if <a href="http://os.name">os.name</a> != &quot;posix&quot;:&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp; try:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import win32api<br>&nbsp;&nbsp;&nbsp; except ImportError:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return &quot;Pywin32 2.1.0, python dependencies, is missing.&quot;<br>&nbsp;</div>
<div>&nbsp; #checking whether rpy is installed or not<br>&nbsp; try:<br>&nbsp;&nbsp;&nbsp; import rpy<br>&nbsp; except ImportError:<br>&nbsp;&nbsp;&nbsp; return &quot;RPy 1.0.1, python dependencies, is missing.&quot;<br>&nbsp; except:<br>&nbsp;&nbsp;&nbsp; return &quot;R 2.6.1 is missing.&quot;<br>
&nbsp;</div>
<div><span class="gmail_quote">On 5/14/08, <b class="gmail_sendername">Barry Rowlingson</b> &lt;<a href="mailto:b.rowlingson@lancaster.ac.uk">b.rowlingson@lancaster.ac.uk</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span class="q">volkan kepoglu wrote:<br><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px; BORDER-LEFT: #ccc 1px solid">It would be nice to have a<br>standard method for<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px; BORDER-LEFT: #ccc 1px solid">plugins to test and report requirements before they install themselves<br></blockquote>properly. Checking for &gt; things like rpy and specific R packages would be<br>
one of those things.<br></blockquote><br></span>Here&#39;s some more thinking:<br><br>plugins should define a &quot;requirements&quot; function in their __init__.py file which will look something like this:<br><br>def requirements():<br>
&nbsp;reqs = {<br>&nbsp; &nbsp;&#39;qgis&#39;: [&#39;&gt;=0.9.0&#39;,&#39;&lt;0.11.0&#39;] ,<br>&nbsp; &nbsp;&#39;qgis-plugins&#39;: [],<br>&nbsp; &nbsp;&#39;python&#39;: &#39;&gt;=2.3.0&#39;,<br>&nbsp; &nbsp;&#39;python-packages&#39;: [&#39;rpy&#39;],<br>&nbsp; &nbsp;&#39;rpy-r&#39;: &#39;&gt;=2.4.0&#39;,<br>
&nbsp; &nbsp;&#39;r-packages&#39;: [&#39;DCluster&#39;],<br>&nbsp; &nbsp;&#39;other&#39;: otherRequirements,<br>&nbsp; &nbsp;}<br>&nbsp;return reqs<br><br>&nbsp;- so basically it returns a dict of name:value pairs which the requirements testing system can get. Note that the system can display the requirements as text, and also test the requirements. Obviously the system needs a way of testing each dependency type.<br>
<br>&nbsp;The &#39;other&#39; type is special, and its value is a function in the plugin that is called with one argument, &#39;test&#39; and returns a list of two items. The first item is the test description, and the second item is the test status. Test status is a list of two items, the first is True or False for the test and the second is a note string. If the function is called with &#39;test=False&#39;, the status should be (None,None) and the test isn&#39;t performed.<br>
<br>&nbsp;For example, here&#39;s an otherRequirements function that tests if the <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://os.name/" target="_blank">os.name</a> parameter is &#39;nt&#39; or &#39;posix&#39;:<br>
<br>&nbsp;def otherRequirements(test=False):<br>&nbsp;status=(None,None)<br>&nbsp;if test:<br>&nbsp; &nbsp;import os<br>&nbsp; &nbsp;status=(False,&#39;OS not valid&#39;)<br>&nbsp; &nbsp;if os.name==&quot;nt&quot; or os.name==&quot;posix&quot;:<br>&nbsp; &nbsp; &nbsp;status=(True,&#39;OS is valid&#39;)<br>
&nbsp;return (&#39;OS is nt or posix&#39;,status)<br><br>&nbsp;I&#39;m not sure that returning a dict() from requirements is correct, since it might be neessary to impose an ordering on the testing (no point testing for R packages if rpy isn&#39;t installed, for example).<br>
<br>&nbsp;Any other ideas?<br><span class="sg"><br>Barry<br></span></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Volkan Kepoglu<br>PhD Candidate<br>GGIT Department in METU,<br>Ankara, Turkey.