View Single Post
Old 10-28-2015, 06:44 AM   #97
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,741
Karma: 24031403
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by rubeus View Post
What i'm supposed to do if i want to create plugins running with the built in python interpreter?
1. Install Python 2.7 or 3.4 (only required for Sigil 0.8.7)

2. In the Manage Plugins dialog box, click the Auto button(s).

3. Download the Sigil Plugin Guide, which contains many examples.
(Note that validation plugins require Sigil 0.8.7 or higher and hunspell plugins Sigil 0.8.9 or higher.)

4. Locate the plugin folder. If you have a Windows machine, press +R, enter the following path and press Enter:

Code:
%LOCALAPPDATA%\sigil-ebook\sigil\plugins
Create a test folder with two text files in it

Code:
plugin.py
plugin.xml
(The folder must be named test.)

5. Paste the following text into plugin.xml:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<name>test</name>
<type>edit</type>
<author>test</author>
<description>test</description>
<engine>python2.7</engine>
<engine>python3.4</engine>
<version>0.1</version>
<oslist>unx,win,osx</oslist>
</plugin>
6. Paste the following sample code into plugin.py:

Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, division, absolute_import, print_function
import platform
    
# main routine
def run(bk):
    print('Python Laucher Version:', bk.launcher_version())
    print('Python Version:', platform.python_version())
        
    print('\nDone.\n\nPlease click OK to close the Plugin Runner window.')
    return 0

def main():
    print('I reached main when I should not have\n')
    return -1

if __name__ == "__main__":
    sys.exit(main())
7. Restart Sigil and select Plugins > Manage Plugins > Edit > test.
If the plugin works, replace the code in Magenta with your own code.

Quote:
Originally Posted by rubeus View Post
It must run under 3.4?
Since Sigil 0.8.9 comes with a bundled Python 3.4 interpreter, Python 3.4 is recommended.

Quote:
Originally Posted by rubeus View Post
I guess there will be a mixture of plugins where i need to have the 2.7 still installed due to already available plugins, will there be a problem with the built in one?
Some older plugins require Python 2.7, but all plugins written by KevinH and DiapDealer support both Python versions.

Quote:
Originally Posted by rubeus View Post
How does the decision work in Sigil what interpreter is to be used?
Sigil will use the interpreters in the order in which they're defined in plugin.xml.

Last edited by Doitsu; 10-28-2015 at 06:53 AM.
Doitsu is offline   Reply With Quote