Let's say I have a script I've written:
~/workspace/myscript/script.py
If I have, for example, a ~/bin
which I have added to my $PATH
, then I could create a symbolic link
~/bin/script -> ~/workspace/myscript/script.py
And everything works fine, I can call my script from anywhere.
Then, say my script starts to grow, and I separate it out
~/workspace/myscript/
script.py
mylib.py
I now run into a problem, as described here, that if I am calling my python script directly (as opposed to importing it as a module) then I cannot do a relative import.
The only solution I have seen is to package up the whole program into a fully fledged python package with a setup.py and installing it system-wide (or managing a home directory python library folder).
This seems like a lot of extra work for the sake of breaking my code into multiple python files.
Is there some way I can:
- Call the script from anywhere (have it callable on path),
- Have the code sparated into multiple files,
- Not have to manage a full python package and installation.
All at once?