Menu

Directions for setting up a plugin repository?

Ethan K
2016-12-15
2016-12-20
  • Ethan K

    Ethan K - 2016-12-15

    Hi-

    Where is the documentation for creating plugin repositories?

    I've created a set of plugins for analyzing neuron connectivity in Tulip. Deploying the plugins is hard though. Right now I have my users download the source files and copy them by hand to the tulip plugin directory. This is error-prone and it's hard to fix bugs or add features in the plugins because users are reluctant to upgrade plugin source.

    My goal is for users to install plugins from inside Tulip. It seems like creating a plugin repository would acheive this.

    Thanks,
    Ethan

     
  • Antoine Lambert

    Antoine Lambert - 2016-12-19

    Hi Ethan,

    Current official Tulip plugins repositories are hosted at the LaBRI in Bordeaux
    and are dedicated to the distribution of precompiled C++ plugins for MacOs and Windows platform considered in a 'testing' state (i.e. not considered stable). Python plugins are currently not handled by it. I agree that it would be an interesting feature for the next Tulip release, I will try to think about it when I will have some time.

    Nevertheless, you can still obtain what you want by using the Python startup hook scripts mechanism offered by Tulip-Python, assuming your plugins code is hosted on GitHub. Copy the following Python script in a .py file inside the following folder: <home_dir>/.TulipX-Y/python/startup and each time Tulip starts, the code of the plugins will be downloaded and then each of them will be registered in the Tulip plugin database.
    So your users will now have to copy a single file for retrieving and updating the plugins
    instead of multiple ones.

    import site, sys, os, tempfile, logging, tempfile, zipfile
    
    from tulip import tlp
    
    def download_file(url, desc=None):
      if sys.version_info >= (3,):
        import urllib.request as urllib2
        import urllib.parse as urlparse
      else:
        import urllib2
        import urlparse
      u = urllib2.urlopen(url)
    
      scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
      filename = os.path.basename(path)
      filename = os.path.join(desc, filename)
    
      with open(filename, 'wb') as f:
        f.write(u.read())
    
      return filename
    
    # create a temporary directory
    tmpDir = tempfile.mkdtemp()
    # download master branch in a zip file from a GitHub repository
    # and save it in the temp dir
    url = "https://github.com/anlambert/tulip_python_plugins/archive/master.zip"
    filename = download_file(url, tmpDir)
    
    # extract the archive content in the temp dir
    zip_ref = zipfile.ZipFile(filename, 'r')
    zip_ref.extractall(tmpDir)
    zip_ref.close()
    
    # load Tulip Python plugins recursively from the temp dir
    tlp.loadPluginsFromDir(tmpDir)
    

    Hope that it will help.

    Antoine

     
  • Ethan K

    Ethan K - 2016-12-20

    Ok. That's a clever trick--using the python script to automatically download the plugins. I will give it a try. Thanks.

     

Log in to post a comment.