pierocampanelli
pierocampanelli

Reputation: 948

Python project organization (specially for external libs)

I plan to organize my python project the following way:

<my_project>/
         webapp/
           mymodulea.py
           mymoduleb.py
           mymodulec.py
           mylargemodule/
                 __init.py__
                 mysubmodule1.py
                 mysubmodule2.py
         backend/
           mybackend1.py
           mybackend2.py
         lib/
            python_external_lib1.py
            python_external_large_lib2/
                    __init__.py
                    blabla.py
            python_external_lib2.py

in my development IDE (PYdev) to have all working I have setup webapp/, backend/ and lib/ as source folders and all of course works.

How can I deploy it on a remote server? Have I to set PYTHONPATH in a startupscript ?Or have I to it programmatively?

Upvotes: 2

Views: 278

Answers (1)

Ned Batchelder
Ned Batchelder

Reputation: 375664

If you are treating webapp, backend, and lib as source folders, then you are importing (for example) mymodulea, mybackend1, and python_external_large_lib2.

Then on the server, you must put webapp, backend, and lib into your python path. Doing it in some kind of startup script is the usual way to do it. Doing it programmatically is complicated because now your code needs to know what environment it's running in to configure the path correctly.

Upvotes: 1

Related Questions