Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading Python third party libraries

Google App engine documentation states that it is possible to upload and use third party libraries provided they written in pure Python.

What are the steps I need to take to do this?

like image 580
afroze Avatar asked Dec 20 '22 21:12

afroze


1 Answers

What I did is created a file called fix_path.py in my root directory that looks like this:

import os
import sys
import jinja2   
# path to lib direcotory
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib'))

Then I created a lib directory, and drop the module in there.

For example, I use WTForms. My file structure looks like this.

  • lib
    • wtforms
  • fix_path.py
  • somefile.py

when I am ready to call it from my somefile script

import fix_path # has to be first.
import wtforms

here is this example in my github source. checkout fix_path.py for setup and views.py for usage.

like image 127
Busilinks Avatar answered Jan 15 '23 03:01

Busilinks