Today
-
Yesterday
-
Total
-
  • Emacs의 Python3 개발 환경
    Programmer/Emacs 2017. 12. 14. 15:10

    emacs의 python 개발 환경은 크게 두 가지가 유명하다.
    하나는 elpy 나머지 하나는 anaconda이다.

    이 두가지 중에 하나를 선택해서 사용한다.


    elpy

    한마디로, emacs에서 python 개발을 위한 all in one 패키지이다.
    설치와 설정이 매우 쉬운면서 여느 IDE와 견주어도 꿀리지 않는 강력함이 있다.

    (use-package elpy
      :ensure t
      :config
      (elpy-enable)
      (setq elpy-rpc-python-command "python3")
      (setq elpy-rpc-backend "jedi")
      (elpy-use-cpython (or (executable-find "python3")
                            (executable-find "/usr/bin/python3")
                            (executable-find "/usr/local/bin/python3")
                            "python3"))
      ;; (elpy-use-ipython)
      (setq python-shell-interpreter-args "--simple-prompt -i")
      (add-hook 'python-mode-hook (lambda ()
                                  (setq indent-tabs-mode nil))))
    
    (use-package ein
      :ensure t)


    anaconda

    anaconda 최대한 작은 것을 지향한다.
    elpy가 자동으로 해주던 것을 일일이 설치하고 설정해야 한다.

    python-mode

    (use-package python
      :mode ("\\.py\\'" . python-mode)
            ("\\.wsgi$" . python-mode)
      :interpreter ("python" . python-mode)
    
      :init
      (setq-default indent-tabs-mode nil)
    
      :config
      (setq python-indent-offset 4)
      ;; TODO pyvenv
      (setq flycheck-python-pycompile-executable
            (or (executable-find "python3")
                (executable-find "/usr/bin/python3")
                (executable-find "/usr/local/bin/python3")
                "python"))
      (setq flycheck-python-pylint-executable
            (or (executable-find "pylint3")
                (executable-find "/usr/bin/pylint3")
                (executable-find "/usr/local/bin/pylint3")
                "pyline"))
      (setq flycheck-python-flake8-executable
            (or (executable-find "flake8")
                (executable-find "/usr/bin/flake8")
                (executable-find "/usr/local/bin/flake8")
                "flake8")))

    anaconda-mode

    (use-package anaconda-mode
      :ensure t
      :diminish anaconda-mode
      :defer t
      :init (progn
              (add-hook 'python-mode-hook #'anaconda-mode)
              (add-hook 'python-mode-hook #'anaconda-eldoc-mode)))
    
    (use-package company-anaconda
      :ensure t
      :commands (company-anaconda)
      :after company
      :init (add-to-list 'company-backends #'company-anaconda))

    unit test

    (use-package nose
      :commands (nosetests-one
                 nosetests-pdb-one
                 nosetests-all
                 nosetests-pdb-all
                 nosetests-module
                 nosetests-pdb-module
                 nosetests-suite
                 nosetests-pdb-suite)
      :config
      (progn
        (add-to-list 'nose-project-root-files "setup.cfg")
        (setq nose-use-verbose nil)))
    
    (use-package pytest
      :commands (pytest-one
                 pytest-pdb-one
                 pytest-all
                 pytest-pdb-all
                 pytest-module
                 pytest-pdb-module)
      :config (add-to-list 'pytest-project-root-files "setup.cfg"))

    virtualenv

    (use-package pyenv-mode
      :if (executable-find "pyenv")
      :commands (pyenv-mode-versions))
    
    (use-package pyvenv
      :defer t)


    댓글

Designed by Tistory.