rules_appengine icon indicating copy to clipboard operation
rules_appengine copied to clipboard

py_appengine_binary only works for targets at the top-level of the workspace

Open jo2y opened this issue 7 years ago • 2 comments

While working on #10, I found that py_appengine_binary only works if the build target is at the top-level of the workspace. Part of what's happening is the wrapper appengine_config.py file created by py_appengine.bzl is created under a different directory in sandbox than the other files from the target. Something like this:

...runfiles/ appengine_config.py examples/ py/ hello_world/ main.py

sys.path is configured to include the ...runfiles, directory but not examples/py/hello_world, so when devappserver does an 'import main', it fails. I'm not sure the fix is to just update sys.path to include that path. I believe that appcfg and gcloud expect all of the files to be together. Eg.

/ appengine_config.py main.py

Is it supported in bazel to construct a sandbox with a specific layout? I think this will help with adding gcloud support and third party modules. For example, the setup instruction recommends pip install GoogleAppEngineCloudStorageClient -t <your_app_directory/lib> to use GCS. It's expected to be under the lib directory and to be uploaded with the rest of the app.

jo2y avatar Mar 11 '18 23:03 jo2y

yaml configs are symlinked to relevant directory(have to be specified in configs for build target). But imports have to be relative to top level directory. So in your case app.yaml would use examples.py.hello_world.main.app as script entry point

maximermilov avatar Dec 11 '18 23:12 maximermilov

Usage example: https://github.com/google/cauliflowervest/blob/master/cauliflowervest/server/app.yaml

maximermilov avatar Dec 11 '18 23:12 maximermilov