Recommended .gitignore file for Python projects?

I’m trying to collect some of my default settings, and one thing I realized I don’t have a standard for is .gitignore files. There’s a great thread showing a good .gitignore for Visual Studio projects, but I don’t see many recommendations for Python and related tools (PyGTK, Django).

So far, I have…

  • Django project bug tracked with redmine, same users
  • git and django migrations: ignore the migrations files
  • Heroku: No default language could be detected for this app for python even with runtime.txt
  • Django - syncdb causes error: “DatabaseError: no such table: django_site”
  • Two Heroku Apps for the Same Project?
  • Which PIP Returns Global Instead of VirtualEnv
  • *.pyc
    *.pyo
    

    …for the compiled objects and…

    build/
    dist/
    

    …for the setuptools output.

    Any more recommendations for me?

  • Git Daemon Hang SO_KEEPALIVE
  • Directories have disappeared from git repo
  • Why git push behaves like git push --force?
  • Jenkins, Git and Eclipse
  • Git clone verbose output?
  • importing a git working directory to a second git repository
  • 5 Solutions collect form web for “Recommended .gitignore file for Python projects?”

    When using buildout I have following in .gitignore (along with *.pyo and *.pyc):

    .installed.cfg
    bin
    develop-eggs
    dist
    downloads
    eggs
    parts
    src/*.egg-info
    lib
    lib64
    

    Thanks to Jacob Kaplan-Moss

    Also I tend to put .svn in since we use several SCM-s where I work.

    Github has a great boilerplate .gitignore

    # Byte-compiled / optimized / DLL files
    __pycache__/
    *.py[cod]
    
    # C extensions
    *.so
    
    # Distribution / packaging
    bin/
    build/
    develop-eggs/
    dist/
    eggs/
    lib/
    lib64/
    parts/
    sdist/
    var/
    *.egg-info/
    .installed.cfg
    *.egg
    
    # Installer logs
    pip-log.txt
    pip-delete-this-directory.txt
    
    # Unit test / coverage reports
    .tox/
    .coverage
    .cache
    nosetests.xml
    coverage.xml
    
    # Translations
    *.mo
    
    # Mr Developer
    .mr.developer.cfg
    .project
    .pydevproject
    
    # Rope
    .ropeproject
    
    # Django stuff:
    *.log
    *.pot
    
    # Sphinx documentation
    docs/_build/
    

    local_settings.py, for django projects.

    *~ for all projects.

    One question is if you also want to use git for the deploment of your projects. If so you probably would like to exclude your local sqlite file from the repository, same probably applies to file uploads (mostly in your media folder). (I’m talking about django now, since your question is also tagged with django)

    Here are some other files that may be left behind by setuptools:

    MANIFEST
    *.egg-info
    
    Git Baby is a git and github fan, let's start git clone.