Best practices for adding .gitignore file for Python projects? [closed] Best practices for adding .gitignore file for Python projects? [closed] python python

Best practices for adding .gitignore file for Python projects? [closed]


Github has a great boilerplate .gitignore

# Byte-compiled / optimized / DLL files__pycache__/*.py[cod]# C extensions*.so# Distribution / packagingbin/build/develop-eggs/dist/eggs/lib/lib64/parts/sdist/var/*.egg-info/.installed.cfg*.egg# Installer logspip-log.txtpip-delete-this-directory.txt# Unit test / coverage reports.tox/.coverage.cachenosetests.xmlcoverage.xml# Translations*.mo# Mr Developer.mr.developer.cfg.project.pydevproject# Rope.ropeproject# Django stuff:*.log*.pot# Sphinx documentationdocs/_build/


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

.installed.cfgbindevelop-eggsdistdownloadseggspartssrc/*.egg-infoliblib64

Thanks to Jacob Kaplan-Moss

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


Covers most of the general stuff -

# Byte-compiled / optimized / DLL files__pycache__/*.py[cod]*$py.class# C extensions*.so# Distribution / packaging.Pythonbuild/develop-eggs/dist/downloads/eggs/.eggs/lib/lib64/parts/sdist/var/wheels/*.egg-info/.installed.cfg*.eggMANIFEST# PyInstaller#  Usually these files are written by a python script from a template#  before PyInstaller builds the exe, so as to inject date/other infos into it.*.manifest*.spec# Installer logspip-log.txtpip-delete-this-directory.txt# Unit test / coverage reportshtmlcov/.tox/.coverage.coverage.*.cachenosetests.xmlcoverage.xml*.cover.hypothesis/.pytest_cache/# Translations*.mo*.pot# Django stuff:*.loglocal_settings.pydb.sqlite3# Flask stuff:instance/.webassets-cache# Scrapy stuff:.scrapy# Sphinx documentationdocs/_build/# PyBuildertarget/# Jupyter Notebook.ipynb_checkpoints# pyenv.python-version# celery beat schedule filecelerybeat-schedule# SageMath parsed files*.sage.py# Environments.env.venvenv/venv/ENV/env.bak/venv.bak/# Spyder project settings.spyderproject.spyproject# Rope project settings.ropeproject# mkdocs documentation/site# mypy.mypy_cache/

Reference: python .gitignore