3

How can I use configured virtualenv and flake8 settings file (setup.cfg in root of project), for flycheck in emacs?

Rustem
  • 2,884
  • 1
  • 17
  • 32

2 Answers2

2

There are a number of plugins for working with virtualenvs. For example, with pyvenv installed I can use the pyvenv-workon command to select a virtualenv from $WORKON_HOME.

virtualenvwrapper and python-environment provide similar support, and all three are available on MELPA.

Flycheck has an option flycheck-flake8rc:

Configuration file for `python-flake8'.

If you have per-project configuration files, it might be easiest to create .dir-locals.el files in the root of each project that sets flycheck-flake8rc to the appropriate value, e.g.

((python-mode
  (flycheck-flake8rc . "/path/to/setup.cfg")))

I would advise not tracking .dir-locals.el in whatever version control system you are using, though of course that is up to you.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
2

I spent some time to find right solution and decided to implement my own:

flycheck-local-flake8

This is plugin for flycheck-flake8 checker, simply uses flake8 from required virtualenv and setup.cfg from root of the python project.

Rustem
  • 2,884
  • 1
  • 17
  • 32