[Qgis-developer] Re: plug-in requirements
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Tue May 13 18:07:12 EDT 2008
volkan kepoglu wrote:
> It would be nice to have a
> standard method for
>> plugins to test and report requirements before they install themselves
> properly. Checking for > things like rpy and specific R packages would be
> one of those things.
Here's some more thinking:
plugins should define a "requirements" function in their __init__.py
file which will look something like this:
def requirements():
reqs = {
'qgis': ['>=0.9.0','<0.11.0'] ,
'qgis-plugins': [],
'python': '>=2.3.0',
'python-packages': ['rpy'],
'rpy-r': '>=2.4.0',
'r-packages': ['DCluster'],
'other': otherRequirements,
}
return reqs
- 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.
The 'other' type is special, and its value is a function in the plugin
that is called with one argument, 'test' 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 'test=False', the status should be (None,None) and the
test isn't performed.
For example, here's an otherRequirements function that tests if the
os.name parameter is 'nt' or 'posix':
def otherRequirements(test=False):
status=(None,None)
if test:
import os
status=(False,'OS not valid')
if os.name=="nt" or os.name=="posix":
status=(True,'OS is valid')
return ('OS is nt or posix',status)
I'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't installed, for example).
Any other ideas?
Barry
More information about the Qgis-developer
mailing list