Importing C python module in Google App Engine - google-app-engine

I am developing an application on Google app engine using Python. I want to use editdist feature of Python and for that reason I am importing editdist C python module in my program, but it is showing that module editdist does not exist.
When I import editdist for my local application it is working fine but not for Google app engine application.
Can anyone suggest me a method to import this module?

App Engine is a "pure python" environment, and you cannot use any C extensions or other code that must be compiled.
There is therefore no way to use this program on App Engine, and all of the competing "production quality" python libraries I found were implemented as C modules.
There do exist alternate implementations of the Levenshtein distance algorithm, though none are as nearly as fast as editdist. These more naïve implementations might still be acceptable depending upon your needs.

Here could be couple alternatives that are implemented with Python (I haven't tested them myself):
http://www.korokithakis.net/node/87
http://code.activestate.com/recipes/576874-levenshtein-distance/

Related

Are Cloud Endpoints with Go Google App Engine Standard possible?

I have implemented a simple API in Go on Google App Engine Standard using just:
func init() {
http.HandleFunc("/api/v1/resource",submitResource)
}
Nothing special. However I want to port this code to using Cloud Endpoints instead in order to get the better monitoring and diagnostics.
Is it even possible with STANDARD instances or must I move to FLEXIBLE?
I can't find any documentation on this. Nor answers to this seemingly simple question. At the moment I half wish I had chosen Python because its support seems more mature. I chose Go because it seems more appropriate for API-like code because my minimal research suggested Go offered better performance.
If it is possible, are there any pointers to how please?
Only Python and Java are supported on GAE Standard via the Endpoints Frameworks. However, Go is supported on GAE Flexible.
Here is the Go GAE Flexible sample:
https://github.com/GoogleCloudPlatform/golang-samples/tree/master/endpoints/getting-started
After much research and trial and error, the simple answer is "No." - as of Dec 2016.
The longer answer is it's possible if you want to put far too much effort into making up to date libraries of your own. There is basically no support, even in alpha, for the current Google Cloud Endpoints using Go with Google App Engine Standard.
It's possible to run Go+endpoints on GAE Standard environment, however libraries might be outdated now.
Libraries and sample app can be found on github:
https://github.com/GoogleCloudPlatform/go-endpoints
I have successfully deployed "Greetings" as AppEngine SE app, and it works.

Golang lua-script like runs on GAE

I am looking for a solution for a script language like lua to use with Go application running on GAE. I have found golua and luar projects and planned to use them as the solution.
However, once I ran them on GAE environment, I encountered
"o-app-builder: Failed parsing input: parser: bad import "unsafe" in
github.com/stevedonovan/luar/luar.go"
I was confused but finally found that apparently GAE trimmed unsafe package out for a reason. Since luar and golua need the package, I think I have to find a new solution for this.
Is there any way to use luar and golua on GAE? If it is not possible, are there any alternative script languages that will run on GAE environment?
The just announced Managed VMs will allow you to run App Engine applications on Compute Engine virtual machines. This allows access to the full range of libraries, filesystems and sockets. As of today (April 20th, 2014) Managed VMs are in Limited Preview, so you'll need to fill out the form here to get access.

cannot find package "appengine/cloudsql"

I develop some GO libraries using Google Cloud SQL and MySQL server. When I imported `appengine/cloudsql, an error below occured.
cloud.go:20:2: cannot find package "appengine/cloudsql" in any of:
/usr/local/Cellar/go/1.1.2/src/pkg/appengine/cloudsql (from $GOROOT)
/Users/lameduck/myGo/src/appengine/cloudsql (from $GOPATH)
I know this package, appengine/cloudsql, is only for Google App Engine and it doesn't exist on everywhere else.
I'm wondering how can I use it for GAE and standard sql library for other environments in a single library.
PS: I can setup Google App Engine SDK correctly. My question is not relevant to it. I hope my library runs on Google App Engine and standalone environment together. (I already made a code for GAE and a code for other dabatases.) It is Ok that users have to setup some configurations. But I don't want that users have to modify a library source code.
Thanks for any help.
I solved the problem. I used a build constraint to use the proper routine and avoid an error. There is a build constraint for App Engine, appengine.
The App Engine SDK introduces a new build constraint term:
"appengine". Files that specify
// +build appengine will be built by the App Engine SDK and ignored by
the go tool. Conversely, files that specify
// +build !appengine are ignored by the App Engine SDK, while the go
tool will happily build them.
PS:
Anway, I upvoted other answers. Thank you.
Package import is done during compile/link time. And Go doesn't support runtime conditional imports in distinction from Python.
Feature you are looking for is dynamic library loading (like in C/C++ you can load .so/.dll in runtime), but Go currently doesn't support it.

Making a Go Webapp independent of Google App Engine

This question comes from working on my webapp, a feed reader written in Go. The code is available at http://github.com/matthewbauer/rivulet although that should not be necessary to answer the question.
I have a webapp written in Go that is running on Google's App Engine. It uses the usual common App Engine libraries like datastore, memcache, and user.
Is there any way to let my users run this app on their own without breaking App Engine compatibility?
Go now provides build constraints that exclude/include files based on target build platform:
// +build !appengine
So, I know that this is possible. But, my biggest problem is with my libraries that depend on App Engine: datastore, memcache, and user. I know other libraries provide datastore and memcache, and I can implement user on my own, but how would I go about wrapping it up?
I know that I can have them set up a development server with the SDK, but that might be too involved for some users. I want a single executable that normal Go projects provide. IS that possible?
If any examples exist, I haven't found them yet; any examples of App Engine independent webapps would be appreciated. I can learn by example.
You will probably have refactor your code.
The basic rule of thumb will be anywhere you depend on an AppEngine package define your own interface for the way you use it. This will allow you decouple the app from the appengine libraries.
Once you've defined those interfaces then you can start providing alternatives that satisfy the interfaces. You'll be able to plugin any Datastore or Memcache that satisfies the interfaces and your app will be able to both run on appengine or as a standalone with the alternatives.

Google app engine to run executable files

Is it possible to run executable files in google app engine? Like by using Runtime.exec?
There is whitelist on google app engine documentation which list classes that can be used but functions/ inside the classes are not specified.
No, absolutely not.
The only thing that make AppEngine possible is that both the Python and Java environments are controlled by Google so that performance/scability and security issues are minimized. They don't even allow to use all the standard Java/Python classes, so imagine the problems that could arise if they let people run any executable file. One may even be a virus!

Resources