@@ -0,0 +1,117 @@
1+;;; .dir-locals.el
2+;;
3+;; If you get ``*** EPC Error ***`` with this setup in your emacs session,
4+;; mostly you have jedi-mode enabled but the python enviroment is missed. The
5+;; python environment has to be next to the ``<repo>/.dir-locals.el`` in::
6+;;
7+;; ./local/py3
8+;;
9+;; In Emacs, some buffer locals are referencing the project environment:
10+;;
11+;; - prj-root --> <repo>/
12+;; - python-environment-directory --> <repo>/local
13+;; - python-environment-default-root-name --> py3
14+;; - python-shell-virtualenv-root --> <repo>/local/py3
15+;; When this variable is set with the path of the virtualenv to use,
16+;; `process-environment' and `exec-path' get proper values in order to run
17+;; shells inside the specified virtualenv, example::
18+;; (setq python-shell-virtualenv-root "/path/to/env/")
19+;;
20+;; To setup such an environment build target 'pyenv' or 'pyenvinstall'::
21+;;
22+;; $ make pyenvinstall
23+;;
24+;; Alternatively create the virtualenv, source it and install jedi + epc
25+;; (required by `emacs-jedi <https://tkf.github.io/emacs-jedi>`_)::
26+;;
27+;; $ virtualenv --python=python3 "--no-site-packages" ./local/py3
28+;; ...
29+;; $ source ./local/py3/bin/activate
30+;; (py3)$ # now install into the activated 'py3' environment ..
31+;; (py3)$ pip install jedi epc
32+;; ...
33+
34+((nil
35+ . ((fill-column . 80)
36+ ))
37+ (python-mode
38+ . ((indent-tabs-mode . nil)
39+
40+ ;; project root folder is where the `.dir-locals.el' is located
41+ (eval . (setq-local
42+ prj-root (locate-dominating-file default-directory ".dir-locals.el")))
43+
44+ (eval . (setq-local
45+ python-environment-directory (expand-file-name "./local" prj-root)))
46+
47+ ;; use 'py3' enviroment as default
48+ (eval . (setq-local
49+ python-environment-default-root-name "py3"))
50+
51+ (eval . (setq-local
52+ python-shell-virtualenv-root
53+ (concat python-environment-directory
54+ "/"
55+ python-environment-default-root-name)))
56+
57+ ;; python-shell-virtualenv-path is obsolete, use python-shell-virtualenv-root!
58+ ;; (eval . (setq-local
59+ ;; python-shell-virtualenv-path python-shell-virtualenv-root))
60+
61+ (eval . (setq-local
62+ python-shell-interpreter
63+ (expand-file-name "bin/python" python-shell-virtualenv-root)))
64+
65+ (eval . (setq-local
66+ python-environment-virtualenv
67+ (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
68+ ;;"--system-site-packages"
69+ "--quiet")))
70+
71+ (eval . (setq-local
72+ pylint-command
73+ (expand-file-name "bin/pylint" python-shell-virtualenv-root)))
74+
75+ ;; pylint will find the '.pylintrc' file next to the CWD
76+ ;; https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
77+ (eval . (setq-local
78+ flycheck-pylintrc ".pylintrc"))
79+
80+ ;; flycheck & other python stuff should use the local py3 environment
81+ (eval . (setq-local
82+ flycheck-python-pylint-executable python-shell-interpreter))
83+
84+ ;; use 'M-x jedi:show-setup-info' and 'M-x epc:controller' to inspect jedi server
85+
86+ ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-root -- You
87+ ;; can specify a full path instead of a name (relative path). In that case,
88+ ;; python-environment-directory is ignored and Python virtual environment
89+ ;; is created at the specified path.
90+ (eval . (setq-local jedi:environment-root python-shell-virtualenv-root))
91+
92+ ;; https://tkf.github.io/emacs-jedi/latest/#jedi:server-command
93+ (eval .(setq-local
94+ jedi:server-command
95+ (list python-shell-interpreter
96+ jedi:server-script)
97+ ))
98+
99+ ;; jedi:environment-virtualenv --> see above 'python-environment-virtualenv'
100+ ;; is set buffer local! No need to setup jedi:environment-virtualenv:
101+ ;;
102+ ;; Virtualenv command to use. A list of string. If it is nil,
103+ ;; python-environment-virtualenv is used instead. You must set non-nil
104+ ;; value to jedi:environment-root in order to make this setting work.
105+ ;;
106+ ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-virtualenv
107+ ;;
108+ ;; (eval . (setq-local
109+ ;; jedi:environment-virtualenv
110+ ;; (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
111+ ;; ;;"--python"
112+ ;; ;;"/usr/bin/python3.4"
113+ ;; )))
114+
115+ ;; jedi:server-args
116+
117+ )))