The final step of creating an extension is distributing it. Since your users may not have Python installed, we should compile the script to an EXE, so that that they will be able to run it stand-alone.
Compiling an extension
There are several ways of compiling a Python script, but we'll do it using py2exe. All we need to do is write a script that compiles our extension script [1]The exclusions for mswsock.dll amd powrprof.dll work around dependency problems that stop the EXE from running on certain systems.:
from distutils.core import setup
import py2exe
setup(
console = [ "dirmon.py" ] ,
options = { "py2exe": {"dll_excludes":["mswsock.dll","powrprof.dll"]} } ,
zipfile = None ,
)
and run it like this:
python _compile.py py2exe --bundle 1
This creates everything you need to distribute in the dist/ sub-directory.
Creating a release
Most plugin channels will have a corresponding .PLUGIN file [2]This is required if the channel has any user-configurable settings., which will need to be distributed along with the compiled EXE.
I like to have a batch script that compiles the extension script, then packages everything up into a release ZIP file:
@ECHO off REM Compile the script. python _compile.py py2exe --bundle 1 REM Create the release ZIP. SET zipFilename=dirmon.zip DEL %zipFilename% 1>nul 2>nul PKZIP.EXE -add -max %zipFilename% dist\dirmon.exe dirmon.plugin










I am a 
