All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] .dir-locals: include QEMU code in PYTHONPATH
@ 2026-09-30 16:30 Alex Bennée
  2026-10-13 10:37 ` Alex Bennée
  2026-10-13 10:40 ` Daniel P. Berrangé
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Bennée @ 2026-09-30 16:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée

When editing python code the linters tools have a hard time with our
imports as they can't be found. To ease this we can expand a
PYTHONPATH in .dir-locals so at least Emacs users can have less
warnings in their editor.

I still get complaints from python-mypy about missing library stubs
that mean it can't do proper type analysis though.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 .dir-locals.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 3ac0cfc6f0d..51871619422 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,2 +1,8 @@
 ((c-mode . ((c-file-style . "stroustrup")
-	    (indent-tabs-mode . nil))))
+	    (indent-tabs-mode . nil)))
+ (python-mode .
+              ((eval . (when-let* ((root (locate-dominating-file default-directory ".dir-locals.el")))
+                         (setq-local process-environment (copy-sequence process-environment))
+                         (setenv "PYTHONPATH"
+                                 (concat (expand-file-name "python" root) ":"
+                                         (expand-file-name "tests/functional" root))))))))
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] .dir-locals: include QEMU code in PYTHONPATH
  2026-09-30 16:30 [RFC PATCH] .dir-locals: include QEMU code in PYTHONPATH Alex Bennée
@ 2026-10-13 10:37 ` Alex Bennée
  2026-10-13 10:40 ` Daniel P. Berrangé
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Bennée @ 2026-10-13 10:37 UTC (permalink / raw)
  To: qemu-devel

Alex Bennée <alex.bennee@linaro.org> writes:

> When editing python code the linters tools have a hard time with our
> imports as they can't be found. To ease this we can expand a
> PYTHONPATH in .dir-locals so at least Emacs users can have less
> warnings in their editor.
>
> I still get complaints from python-mypy about missing library stubs
> that mean it can't do proper type analysis though.

Gentle ping for any fellow Emacers who also hack on the python code.

>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  .dir-locals.el | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/.dir-locals.el b/.dir-locals.el
> index 3ac0cfc6f0d..51871619422 100644
> --- a/.dir-locals.el
> +++ b/.dir-locals.el
> @@ -1,2 +1,8 @@
>  ((c-mode . ((c-file-style . "stroustrup")
> -	    (indent-tabs-mode . nil))))
> +	    (indent-tabs-mode . nil)))
> + (python-mode .
> +              ((eval . (when-let* ((root (locate-dominating-file default-directory ".dir-locals.el")))
> +                         (setq-local process-environment (copy-sequence process-environment))
> +                         (setenv "PYTHONPATH"
> +                                 (concat (expand-file-name "python" root) ":"
> +                                         (expand-file-name "tests/functional" root))))))))

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] .dir-locals: include QEMU code in PYTHONPATH
  2026-09-30 16:30 [RFC PATCH] .dir-locals: include QEMU code in PYTHONPATH Alex Bennée
  2026-10-13 10:37 ` Alex Bennée
@ 2026-10-13 10:40 ` Daniel P. Berrangé
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2026-10-13 10:40 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel

On Wed, Sep 30, 2026 at 05:30:50PM +0100, Alex Bennée wrote:
> When editing python code the linters tools have a hard time with our
> imports as they can't be found. To ease this we can expand a
> PYTHONPATH in .dir-locals so at least Emacs users can have less
> warnings in their editor.
> 
> I still get complaints from python-mypy about missing library stubs
> that mean it can't do proper type analysis though.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  .dir-locals.el | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-13 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-30 16:30 [RFC PATCH] .dir-locals: include QEMU code in PYTHONPATH Alex Bennée
2026-10-13 10:37 ` Alex Bennée
2026-10-13 10:40 ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.