bodkan / slendr

Population genetic simulations in R 🌍
https://bodkan.net/slendr
Other
54 stars 5 forks source link

Should slendr's internal `pylib.py` script be sourced into a dedicated environment? #151

Closed bodkan closed 6 months ago

bodkan commented 8 months ago

Right now I'm sourcing pylib.py into a general environmentbut I wonder if it would be cleaner to source it into its own environment via the envir = argument I just learned about.

I realized this after reading this blogpost.

Actually, I should also check if reticulate finally allows importing custom Python modules using system.file() path -- this was actually why I improvised with reticulate::source_python() in the first place, as simply using import pylib wasn't possible with reticulate at that time. I should test if they fixed the problem in the meantime.

Probably not critical but perhaps worth thinking about for later. 🤔

bodkan commented 6 months ago

Nah. The envir = argument of reticulate::source_python() isn't doing what I thought it's doing.

But while I was at it, I at least __*-mangled slendr's internal Python functions which are loaded by init_env(). That way they are not likely to clash with Python functions the users might define in the slendr embedded Python sessions.