I have made a custom python module (say awesome-lib.py), which is to be imported and used by the multiple other python modules(module1.py, module2.py etc). The problem is that all the modules need to be in separate folders and each of them should have a copy of awesome-lib.py for them to import it. I thought of two options for doing this:
- Each module folder will have a copy of
awesome-lib.pyin it. That way I canimport awesome-liband used it in each module. But issue is when I have to make any changes inawesome-lib.py. I would have to copy the file in each module folder separately, so this might not be a good approach. - I can package the
awesome-lib.pyusingdistutils. Whenever I make the change in the module, I will updateawesome-lib.pyin each module using some script. But still I want the awesome-lib distribution package to be individually included in each module folder.
Can anyone please tell me an efficient way to achieve this? So that I can easily change one file and the changes are reflected in all the modules separately.
P.S: I want the awesome-lib.py in each module folder separately because I need to zip the contents of it and upload each module on AWS Lambda as a Lambda zip package.
let only one copy of awesome-lib.py placed where it is placed and append it's path in other modules. let sample path is "/home/user/awesome-lib.py"
Add following code in every other module you want to import awesome-lib.py
import sys sys.path.append('home/user/awesome-lib') import awesome-libNote: path of awesome-lib may differ on your choice