Total confusion about which path to use for GoLang AppEngine SDK - google-app-engine

I'm having trouble referencing the AppEngine SDK.
After installing Google Cloud SDK, I'm using:
gcloud components install app-engine-go
to install the most recent version of the AppEngine SDK for Go, and afterwards I'm seeing 2 directories:
/usr/local/google-cloud-sdk
/Users/kieran/google-cloud-sdk
The first contains the AppEngine SDK files, the second does not.
In the PATH I'm seeing:
# The next line updates PATH for the Google Cloud SDK.
if [ -f ‘/Users/kieran/google-cloud-sdk/path.bash.inc' ]; then source '/Users/kieran/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/kieran/google-cloud-sdk/completion.bash.inc' ]; then source '/Users/kieran/google-cloud-sdk/completion.bash.inc'; fi
Why is the gcloud installer adding a reference in the PATH to the google-cloud-sdk that does not contain the AppEngine SDK ?
I have read many different articles on here but they all mention a manually downloaded AppEngine SDK, and according to other articles even using "google.golang.org/appengine" is not good enough as it's not always the latest version.
How do I reference the AppEngine SDK that was downloaded by the glcoud installer? With 2 different SDK paths I'm totally confused about which one to use, and even how to reference it in code. I would assume that "appengine" would be sufficient, but that isn't working.

Related

GAE: No longer able to update my Gaelyk project due to appcfg losing support

Recently tried to update my Gaelyk project (yes, it's old, but it works well and I still use it), but Google App Engine will no longer accept the update. The error message returned is "Deployments using appcfg are no longer supported. See https://cloud.google.com/appengine/docs/deprecations". The thing is, I never used appcfg to deploy my application; I used Gaelyk and Gradle. But obviously Gaelyk must have used appcfg under the covers.
I did download the replacement Google Cloud SDK, but this new tool is not similar at all to how Gaelyk and Gradle worked. Is there anything I can do to get Gaelyk to work anymore? Or is Gaelyk just dead and I need to rewrite my application (like in Node.js or something instead of Groovy).
This will be hard, however I will try to help you as possible. I think you may try to migrate it somehow to app.yaml configuration of GAE.
I am not sure what plugins are used in the project. From Gaelyk temple project I can see that it's using appengine-geb which, according to the documentation, behind the scenes, is using gradle-appengine-plugin (there is wrong link on this doc, but proper is bellow).
On the github of gradle-appengine-plugin I have found following.
There is a note:
NOTE: All App Engine users are encouraged to transition to the new
gradle plugin for their projects.
And in FAQ part there is following information:
How do I deploy with gcloud?
If you're using gcloud to deploy your application, the newest version of app deploy > doesn't support war
directories, you will need to provide it with an app.yaml OR you can
use the appengineStage task to create a directory that is deployable
in /build/staged-app
$ ./gradlew appengineStage
$ gcloud app deploy build/staged-app/app.yaml --project [app id]
--version [some version]
NOTES:
You must explicitly define all config files your want to upload
(cron.yaml, etc)
This does not work with EAR formatted projects.
I think the best option will be to migrate to new appenine plugin or if not possible try to implement is with gcloud app deploy command crating the config files manually (at least app.yaml). And for this migration I can provide you this document.
I hope you will manage somehow...
I can confirm that Serge's answer on the Gaelyk Groups site works; the same procedure that he figured out also worked for me. To summarize:
Run gradlew appengineRun as run previously with Gaelyk.
Copy all jar files inside the build\exploded-app\WEB-INF\lib folder into a \src\main\webapp\web-inf\lib folder (for me the new lib folder did not exist previously).
To deploy, use the new required gcloud tool, and instead of running gradlew appengineUpdate (which fails now), instead run
gcloud app deploy appengine-web.xml where that XML file can be found in your webapp/WEB-INF directory. I navigated to that directory to run the gcloud command, but you can use a relative path there if your working directory is elsewhere. (There are a number of optional flags associated with the gcloud app deploy command, but I didn't need any of them.)
Serge needed to use these instructions to convert datastore-indexes.xml to index.yaml and run gcloud app deploy index.yaml, however, I didn't need to do this because I had no datastores.

ImportError: cannot import name cygrpc on development Google App Engine with Firebase Cloud Firestore

I am building a RESTful API using Python 3.6, the Falcon Framework, Google App Engine, and Firebase Cloud Firestore. At runtime I am receiving the following error ...
File "E:\Bill\Documents\GitHubProjects\LetsHang-BackEnd\lib\google\cloud\firestore_v1beta1\_helpers.py", line 24, in <module> import grpc
File "E:\Bill\Documents\GitHubProjects\LetsHang-BackEnd\lib\grpc\__init__.py", line 22, in <module>
from grpc._cython import cygrpc as _cygrpc
ImportError: cannot import name cygrpc
When researching StackOverFlow, I found an article regarding an AWS Lambda deployment, but it suggests a solution based on Docker. Docker is not a viable solution for us. I also found an article off StackOverflow that suggests running "pip install grpcio". We did not without luck.
We build the App Engine dependencies using a requirements.txt file. This file has the following contents ...
falcon==1.4.1
google-api-python-client
google-cloud-firestore
firebase-admin
enum34
grpcio
We apply the requirements file using the command ...
pip install -t lib -r requirements.txt
The App Engine server is started with the command ...
dev_appserver.py .
The development environment is Windows 10.
You seem to be mixing up the GAE standard and flexible environments:
using Python 3.6 is only possible in the flexible environment (which, BTW, is fundamentally Docker-based)
installing app dependencies in the lib directory and using dev_appserver.py for local development are only applicable to the standard environment
Somehow related: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment
Ok. I will write up my findings just in case there's another fool like me.
First, Dan's response is correct. I was mixing standard and flexible environments. I had looked up a method for using the Falcon Framework with App Engine; as it turns out, the only article uses the standard environment. So that's how I wound up using dev_appserver.py. My app, however, is Python 3.6 and has dependencies that prevent stepping down to 2.7.
To develop locally for the flexible environment, you simply need to run as you normally would. In the case of Falcon Framework, that means using the Waitress wsgi server.
I find that it is a good practice to build and use a Python virtual environment. You use the virtualenv command for that. At deployment time, Google builds a docker container for the app in the cloud. To reconstruct all the necessary Python packages, you have to supply a requirements.txt file. If you have a virtual environment, then the requirements file is easily produced using pip freeze.

How to use ujson with Google App Engine

According to the official list of built-in libraries, ujson is available. However, the following app.yaml snippet:
libraries:
- name: ujson
version: '1.35'
...generates this error:
Usage: appcfg.py [options] update <directory> | [file, ...]
appcfg.py: error: Error parsing ./app.yaml: the library "ujson" is not supported
in "./app.yaml", line 89, column 1.
If I try to use other supported C libraries like numpy, it works fine. I am running SDK 159.0.0 (latest) and can even see a "ujson" entry in google-cloud-sdk/lib/googlecloudsdk/third_party/appengine/api/appinfo.py.
Any clue why ujson isn't usable?
ujson v1.35 was added to the app engine runtime in Python SDK version 1.9.55.
This sdk version wasn't included in the gcloud sdk until v161.0.0 (2017-06-28):
Updated App Engine components for Python to version 1.9.55. Please visit the release notes for details
Anecdote:
Some of us still prefer appcfg.py update . instead of gcloud app deploy app.yaml.(We are a rare and dying breed :D).
So in the past I noticed that the appcfg.py tool I was using was an older version from the older app engine tooling. Doesn't come with all the gcloud components update awesomeness. You had to download the binaries each time.
which appcfg.py should reveal the exact one being used which for me was:
$ ~/google_appengine/appcfg.py
I can't say I wasn't warned enough. Besides, I kept seeing this advice/warning each time I ran gcloud components update:
WARNING: There are older versions of Google Cloud Platform tools on your system PATH.
Please remove the following to avoid accidentally invoking these old tools:
/Users/jeff/google_appengine/endpointscfg.py
/usr/local/bin/endpointscfg.py
/Users/jeff/google_appengine/dev_appserver.py
So update to the latest version, update your paths to point to the right appcfg, and enjoy ujson or any of the goodies as and when they drop.
$ ~/google-cloud-sdk/platform/google_appengine/appcfg.py update .

Golang Cloud SDK - gcloud app deploy cannot find import package

according to the official documentation for Google App Engine Standard environment (Go API) the "preferred tooling to deploy a project" is now the Cloud SDK and so we moved to gcloud from goapp.
We are unable to deploy Go projects to GAE because all the sub-packages of every given project can't be found at "deploy time".
The typical folder structure that we have been using for every GAE project was as follows:
-project-name
--app.yaml
--main.go
--assets
---package1
---package2
When global libraries were put in the system GOPATH everything worked smoothly.
Running gcloud app deploy we now get this:
You are about to deploy the following services:
- yourproject/default/123456789 (from [/Path/to/app.yaml])
Deploying to URL: [https://yourproject.appspot.com]
Do you want to continue (Y/n)? Y
Beginning deployment of service [default]...
ERROR: (gcloud.app.deploy) Staging command [/path/to/yourproject/app.yaml /var/folders/b6/5ydn0wdn64jd32sxzzz48b7c0000gn/T/tmpbd4oiG] failed with return code [1].
------------------------------------ STDOUT ------------------------------------
------------------------------------ STDERR ------------------------------------
2017/03/24 10:25:58 failed analyzing /path/to/yourproject: cannot find package "yourpackage" in any of:
($GOROOT not set)
/path/to/gopath/src/yourpackage (from $GOPATH)
GOPATH: /path/to/gopath
--------------------------------------------------------------------------------
while dev_appserver.py works perfectly keeping the same folder structure.
Did we miss something?
How can we deploy to Google App Engine Standard environment using gcloud?
If the project structure needs to be changed: how? Is there official documentation about it?
Thanks in advance,
Edit -- Further infos:
Luigi-Mac-Pro:path/to/yourproject distudio$ gcloud version
Google Cloud SDK 148.0.0
app-engine-go
app-engine-go-darwin-x86_64 1.9.50
app-engine-python 1.9.50
bq 2.0.24
bq-nix 2.0.24
core 2017.03.17
core-nix 2016.11.07
gcloud
gcloud-deps 2017.03.17
gcloud-deps-darwin-x86_64 2017.02.21
gsutil 4.23
gsutil-nix 4.22
Google recommends keeping your dependencies outside of the app directory, and using GOPATH to refer them. In your case, that would mean doing the following:
-project-name
--app.yaml
--main.go
where main.go contains
import (
"package1"
"package2"
)
And somewhere else:
-my_packages
--src
---package1
---package2
And then set GOPATH environment variable to path/to/my_packages prior to running dev_appserver and gcloud app deploy.
For the future
We are working out the long term solution for properly vendoring packages inside your app directory – likely using Go's future native package manager. I'm sorry to say that we don't have a good way of supporting sub-packages for gcloud app deploy. This was an unfortunate side effect of compatibility with the App Engine Flexible environment.

Which version of Eclipse works with PHP Google App Engine?

I've search in vain for about a month now and I can't get my PHP application pushed to Google App Engine, for the PHP platform. I've got the Java version set up nicely on my computer. I followed the instructions for GAE PHP here: https://developers.google.com/appengine/docs/php/gettingstarted/introduction
..but it's really confusing because it essentially tells me to install Eclipse made for PHP which is Luna, but the only versions of Eclipse that GAE supports is Kepler, Juno and Indigo (https://developers.google.com/eclipse/docs/getting_started), so I'm super confused.
I don't think you can install two different GAE plugins on a standard version of Eclipse (which is what I use for the Java GAE plugin).
I also tried (in vain, but it was worth a shot) to upload my app using my Java plugin/setup and obviously this was a terrible idea because all it does is just print the php script/code to the browser.
Any thoughts, brothas/sistas?
I have figured out how to push php files to GAE. There are essentially 3 ways.
Use appcfg.py. Run following command:
--appcfg.py update helloworld/, where helloworld is replaced by the name of the folder containing your project files. Make sure the path is relative to appcfg.py directory or an absolute path.
--Enter your Google username and password at the prompts.
**2. Use the App Engine Launcher, probably found in C:\Program Files (x86)\Google\google_appengine\launcher. Executable is called GoogleAppEngineLauncher.exe. Simply select the project in Launcher and click Deploy.
**3. Use Git. Create a local repository on your machine. Add a repo to your Github account, and follow these instructions: https://developers.google.com/appengine/docs/push-to-deploy#creating_a_cloud_project
**4. Use PhPStorm. Download PHPStorm for free for 30 days, or buy a student version/whatever version you quality for here: . Then follow these instructions: http://confluence.jetbrains.com/display/PhpStorm/Getting+Started+with+PhpStorm+as+Google+App+Engine+PHP+IDE. The only thing I haven't figured out is #5 - where to find the php-cgi.exe file. I can't provide a path for a file I don't have.
** denotes super easy and I have used successfully.
The Google Plugin for Eclipse is only for Java applications. For PHP applications, you'll want to use the Python/PHP SDK and either the command-line tools or the Launcher UI app for running the development server. You can still use Eclipse for editing your PHP source files.
RE #5 - "I can't provide a path for a file I don't have".
That was also my problem.
They are fond of pointing out that the SDK directory should contain dev_appserver.py and ‘google’ and ‘php’ packages but you don't find those in a simple search cause they are invisible. You have to muck through the installation directory.

Resources