qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cleber Rosa <crosa@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: kwolf@redhat.com, berrange@redhat.com, qemu-devel@nongnu.org,
	ehabkost@redhat.com
Subject: Re: [PATCH 1/1] python: add check-python target
Date: Tue, 14 Jul 2020 00:30:03 -0400	[thread overview]
Message-ID: <20200714043003.GA3012808@localhost.localdomain> (raw)
In-Reply-To: <20200714013026.9019-2-jsnow@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2802 bytes --]

On Mon, Jul 13, 2020 at 09:30:26PM -0400, John Snow wrote:
> Move pylintrc and flake8 up to the root of the python folder where
> they're the most useful. Add a requirements.cqa.txt file to house
> the requirements necessary to build a venv sufficient for running
> code quality analysis on the python folder. Add a makefile that
> will build the venv and run the tests.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  Makefile                    |  1 +
>  python/{qemu => }/.flake8   |  0
>  python/Makefile.include     | 33 +++++++++++++++++++++++++++++++++
>  python/{qemu => }/pylintrc  |  1 +
>  python/requirements.cqa.txt |  3 +++
>  5 files changed, 38 insertions(+)
>  rename python/{qemu => }/.flake8 (100%)
>  create mode 100644 python/Makefile.include
>  rename python/{qemu => }/pylintrc (99%)
>  create mode 100644 python/requirements.cqa.txt
> 
> diff --git a/Makefile b/Makefile
> index b1b8a5a6d0..41808be392 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -478,6 +478,7 @@ dummy := $(call unnest-vars,, \
>                  trace-obj-y)
>  
>  include $(SRC_PATH)/tests/Makefile.include
> +include $(SRC_PATH)/python/Makefile.include
>  
>  all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
>  
> diff --git a/python/qemu/.flake8 b/python/.flake8
> similarity index 100%
> rename from python/qemu/.flake8
> rename to python/.flake8
> diff --git a/python/Makefile.include b/python/Makefile.include
> new file mode 100644
> index 0000000000..917808e2f1
> --- /dev/null
> +++ b/python/Makefile.include
> @@ -0,0 +1,33 @@
> +# -*- Mode: makefile -*-
> +
> +PYLIB_VENV_DIR=$(BUILD_DIR)/venv/cqa
> +PYLIB_VENV_REQ=$(SRC_PATH)/python/requirements.cqa.txt
> +
> +$(PYLIB_VENV_DIR): $(PYLIB_VENV_REQ)
> +	$(call quiet-command, \
> +	    $(PYTHON) -m venv $@, \
> +	    VENV, $@)
> +	$(call quiet-command, \
> +	    $(PYLIB_VENV_DIR)/bin/python3 -m pip -q install -r $(PYLIB_VENV_REQ), \
> +	    PIP, $(PYLIB_VENV_REQ))
> +	$(call quiet-command, touch $@)
> +

Maybe we should try to create a generic rule that takes a directory
name and a requirements file and creates the venv accordingly, instead
of duplicating the other similar rules under tests/Makefile.include?

> +pylib-venv: $(PYLIB_VENV_DIR)
> +
> +check-python: pylib-venv
> +	$(call quiet-command, cd $(SRC_PATH)/python && \
> +	    $(PYLIB_VENV_DIR)/bin/python3 -m flake8 qemu, \
> +	    FLAKE8, \
> +	    $(SRC_PATH)/python/qemu \

I can see how this venv would be very useful to run the same checks on
other Python code (for instance, the acceptance tests themselves), so
we'd also need another "check-python"-like rule, or include those on
the same call.

Ideas? :)

Thanks!
- Cleber.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-07-14  4:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14  1:30 [PATCH 0/1] python: add make check-python target John Snow
2020-07-14  1:30 ` [PATCH 1/1] python: add " John Snow
2020-07-14  4:30   ` Cleber Rosa [this message]
2020-07-14 18:36     ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200714043003.GA3012808@localhost.localdomain \
    --to=crosa@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).