LaurentRDC / pandoc-plot

Render and include figures in Pandoc documents using your plotting toolkit of choice
https://laurentrdc.github.io/pandoc-plot/
GNU General Public License v2.0
224 stars 8 forks source link

Allow importing of modules by setting the python workdir/PATH to the directory which the input file is contained in #26

Closed m00nwtchr closed 3 years ago

m00nwtchr commented 3 years ago

Basically i'd like to import a python module that exists alongside the input .MD file, but it looks like the pyhton process is executed in /tmp so it doesn't pick up those modules without having to use absolute paths

LaurentRDC commented 3 years ago

Hello,

I've also considered doing this, but there is no elegant solution which makes this possible for every possible plotting toolkit.

My suggestion is to "upgrade" your PYTHONPATH variable so that the python interpreter will look for modules in e.g. mydir:

PYTHONPATH="$PYTHONPATH":/mydir/
pandoc --filter pandoc-plot ............

disclaimer: I did not actually try this

m00nwtchr commented 3 years ago

ah yea changing the PYTHONPATH worked, but it'd be nice if the input file's directory was automatically added to it when you spawn the python process, but this works for me

LaurentRDC commented 3 years ago

I agree that it would be nice. However, since there's no unified way to do this for all plotting toolkits the PYTHONPATH hack will have to do.