Is there any way to call an installed python egg from python code? I need to cal a sphinx documentation generator from within a python code, and currently i’m doing it like this:
os.system( 'sphinx-build.exe -b html c:\\src c:\\dst' )
This works, but requires some additional configuration: ‘scripts’ folder inside a python installation folder need to be added to a system PATH ( i’m on Windows ). Is it any better, native way to call an installed python egg?
So basically, you want to use Sphinx as a library?
Here is what
sphinx-builddoes:Looking at
entry-points.txtin the EGG-INFO directory, notice that the sphinx-build entry point is thesphinx.mainfunction (located in__init__.py).Have a look at that and duplicate what it does, and you can use sphinx as a library. I have not looked at the code in detail, but it seems that the bulk of the
sphinx-build-command is done by thebuildmethod on aSphinxobject.In your code, you would have to do something like:
You need to have a look at the Sphinx source code to figure out the parameters to
Sphinx.__init__()andSphinx.build()