Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referencing an external library in a Python appengine project, using Pydev/Eclipse

it's a couple of months I've started development in Python - having myself a C# and Java background.

I'm currently working on 2 different python/appengine applications, and as often happens in those cases, both application share common code - so I would like to refactor and move the common/generic code into a shared place.

In either Java or C# I'd just create a new library project, move the code into the new project and add a reference to the library from the main projects.

I tried the same in Python, but I am unable to make it work.

I am using Eclipse with Pydev plugin.

I've created a new Pydev project, moved the code, and attempted to:

  • reference the library project from the main projects (using Project Properties -> Project References)
  • add the library src folder folder into the main projects (in this case I have an error - I presume it's not possible to leave the project boundaries when adding an existing source folder)
  • add as external library (pretty much the same as google libraries are defined, using Properties -> External libraries)
  • Import as link (from Import -> File System and enabling "Create links in workspace")

In all cases I am able to reference the library code while developing, but when I start debugging, the appengine development server throws an exception because it can't find what I have moved into a separate library project.

Of course I've searched for a solution a lot, but it looks like nobody has experienced the same problem - or maybe nobody doesn't need to do the same :)

The closest solution I've been able to find is to add an ant script to zip the library sources and copy in the target project - but this way debugging is a pain, as I am unable to step into the library code.

Any suggestion?

Needless to say, the proposed solution must take into account that the library code has to be included in the upload process to appengine...

Thanks

like image 996
Antonio Avatar asked Oct 10 '22 01:10

Antonio


1 Answers

The dev_appserver and the production environment don't have any concept of projects or libraries, so you need to structure your app so that all the necessary libraries are under the application's root. The easiest way to do this, usually, is to symlink them in as subdirectories, or worst-case, to copy them (or, using version control, make them sub-repositories).

How that maps to operations in your IDE depends on the IDE, but in general, it's probably easiest to get the app structured as you need it on disk, and work backwards from that to get your IDE set up how you like it.

like image 136
Nick Johnson Avatar answered Oct 18 '22 15:10

Nick Johnson