Skip to content

Instantly share code, notes, and snippets.

@anttivs
Last active December 15, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anttivs/5231170 to your computer and use it in GitHub Desktop.
Save anttivs/5231170 to your computer and use it in GitHub Desktop.
Python, Django and Flymake for Mac OS X

Python, Flymake and Django for Mac

Install Python, Emacs

brew install python
brew install emacs --cocoa
ln -s /usr/local/Cellar/emacs/24.3/Emacs.app /Applications/Emacs.app
pip install pep8
pip install pyflakes
pip install pylint
pip install Django
pip install South   # See http://south.aeracode.org/
pip install django-debug-toolbar  # See https://github.com/django-debug-toolbar/django-debug-toolbar/blob/master/README.rst

~/.bash_profile

alias emacs="open -a /Applications/Emacs.app"
export PATH=~/bin:/usr/local/bin:/usr/local/share/python:$PATH
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"

The latter is not strictly needed for brewed Python but it is needed for Emacs flymake scripts to find packages.

~/.emacs

(when (load "flymake" t)
 (defun flymake-pyflakes-init ()
   (let* ((temp-file (flymake-init-create-temp-buffer-copy
              'flymake-create-temp-inplace))
      (local-file (file-relative-name
           temp-file
           (file-name-directory buffer-file-name))))
     (list "~/bin/pycheckers.sh"  (list local-file))))
  (add-to-list 'flymake-allowed-file-name-masks
            '("\\.py\\'" flymake-pyflakes-init)))

(add-hook 'find-file-hook 'flymake-find-file-hook)

(custom-set-variables
     '(help-at-pt-timer-delay 0.9)
     '(help-at-pt-display-when-idle '(flymake-overlay)))

~/bin/pycheckers.sh

#!/bin/bash

epylint "$1" 2>/dev/null
pyflakes "$1"
pep8 --ignore=E221,E701,E202 --repeat "$1"
true

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment