Flask, Heroku and Github Dependencies/File Structure
Question: Quite a beginner at the whole flask/heroku/github business, but been using
python for several years now and had experience with tortoise SVN. I have been
following the tutorial on how to push code to heroku at this link
<https://devcenter.heroku.com/articles/python> and after much tinkering I
managed to get my web app uploaded. However I have definitely missed
something.

Currently within the project I have a file structure to organize different
processes (for example webservice calls and database handling), these are then
imported into the main app by a code of the sort:

    
    
    ## Webservices
    dirname, filename = os.path.split(os.path.abspath(__file__))
    WSdirname = dirname + '\\WebServices\\'
    sys.path.append(WSdirname)
    
    import WebservicesModule as WSmodule # Module resides in "WebSerivices" folder
    

Which implies files are stored in a structure like

    
    
    AppFolder\
        app.py
        WebServices\
            WebservicesModules.py
            ...
        Database\
            DatabaseModules.py
            ...
    

Locally this works. However once pushed by git to heroku it would seem that
the code cannot access the `WebservicesModule` module. Giving an error in the
form

> Import error: no module named WebservicesModule.

To explain why I have this file structure; as there will be a large number of
webservices required it is easier to have them contained within the same
folder. Similarly for the database operations and so forth.

My question is this. Is my code bad practice, meaning heroku doesn't allow it?
Or has git hub not uploaded my files to heroku, hence not being able to find
them (despite being in the file structure of the master directory)? Or is
there some issue I don't know about? Do I need to declare these modules as
dependencies in the requirements.txt, despite doing so in the code?

Cheers for any help you can provide :)!


Answer: The issue is that locally you are developing on Windows, while Heroku's slugs
use some variant of Linux. `\` is the directory separator on Windows but
**`/`** is the directory separator on Linux.

Rather than hard-coding `\WebServices\` use `os.path.join` to join your path
and subdirectories:

    
    
    WSdirname = os.path.join(dirname, "WebServices")
    

That will ensure that no matter _what_ platform you deploy to, the correct
directory separator is used.

