(0.2.5) sys.path alters when launching standalone

So duh, you launch a new process and so it’s a different session, any changes to sys.path aren’t carried over. Maybe there’s something else at play but that seems like a logical explanation.

This isn’t ideal. I can slap a setup script on an empty to waltz around it (and I’ve done so for years) but it’s kind of dull. Yes, yes, this is what launchers are for, and I don’t want to make a launcher everytime I’m just running tests on a random file.

What I’d like is to have a resource var listing directories and automatically append that at startup if any of the directories are missing from path. I’m not saying “be nice if”, I’m saying I’m trying to figure out how to do it.

Now having the resources list (and writting that to a file if necessary), that’s easy. But where to place the path-appending hook? Any ideas?

I usually just throw it at the start of my first startup script. I don’t bother to check if the path is already there or not, since duplicate entries don’t make much difference and it’ll all get cleared when the game closes anyway.

I’ve always had lots of things to initialise at the start, so having the extra path bit didn’t seem odd.

^Duplicates are harmless, yes, but I’m allergic to them.

I’ve been sifting through thread after thread and all I can find is “put it on an empty”. You’re telling me it’s still impossible to run a single line of python without a game object? I forgot why I began coding my own engine, but it’s coming back all of a sudden! Hehe.

Whatever, I’ll hack it together somehow.

If I’m not mistaken Python subprocesses (as well as blenderplayer) both read the PYTHONPATH environment variable. If you set it to what you want, it should be included in your sys.path somehow. Play around with it. See example for inspiration?

1 Like

Thank you, amazing mister Fox c:

Now let’s see about throwing together a panel/some operators to set & get.