Search code examples
pythongoogle-app-enginedeploymentmodulegae-module

How to make a module accessible for all applications including GAE deployment process


I have a Python module containing some utils that all my GAE applications may use. I created it myself. It is n a separate folder and I sometimes want to update its code, make refactorings etc. Every application I create, can take use functions from this module. Now I need to copy the module folder somewhere inside an application and import its functions. It's an ordinary procedure, nothing fancy. When I make some updates to the code of the module, I then need to overwrite this module if it is already imported in the application. Then I just deploy the application with GAE utility and all works fine. The question is - Is that possible to not have many copies of the module in every application having to overwrite them all every time I update some code inside that, but have one copy in one place and automatically import it from there? I know I can copy the module code somewhere Python searches for modules. Though, I still need to copy this module folder into the application when I deploy it into GAE environment. So, I need one copy of a module accessible for all my application when they are on my local PC and need to have that folder copied into the app when I deploy it. Is there a good and nice solution? Thanks.


Solution

  • You can store your module in a directory outside all your GAE apps and then create a symbolic link to that directory inside all the GAE apps directories. appcfg.py will follow the symbolic link. Quoting from the Python SDK docs:

    If you make a symbolic link to a module's directory in your application directory, appcfg.py will follow the link and include the module in your app.