From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6152C3F2CE for ; Wed, 4 Mar 2020 19:00:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E0E22166E for ; Wed, 4 Mar 2020 19:00:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iLcKL8xE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E0E22166E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9ZFX-0000ol-KH for qemu-devel@archiver.kernel.org; Wed, 04 Mar 2020 14:00:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37953) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9ZEj-0008KT-FE for qemu-devel@nongnu.org; Wed, 04 Mar 2020 13:59:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9ZEh-0004Ko-SD for qemu-devel@nongnu.org; Wed, 04 Mar 2020 13:59:17 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:56978 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9ZEh-0004KG-NR for qemu-devel@nongnu.org; Wed, 04 Mar 2020 13:59:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583348354; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=tp9tJZjxhV/6/gAbT6rtK1haMnZtSMWMooXxvvOs7YU=; b=iLcKL8xEUmtchF/VLjuw+99sr6Pb38eYYDAsW8kLaa7R4jWEgHYketHU50megSr9bHXcCh ir93/mftsVNuuNcp35Y2H79plbAhsm+x1PU5UOkcZPP50t4pHu8B+ih0fN+coEWLp6z4Tk hTB7UatHmcSN4e88OpR3Q/NYlK2HZwk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-LnKVcfDrNwmAbuDDygMWZA-1; Wed, 04 Mar 2020 13:59:11 -0500 X-MC-Unique: LnKVcfDrNwmAbuDDygMWZA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1B34190B2A0; Wed, 4 Mar 2020 18:59:10 +0000 (UTC) Received: from [10.10.120.212] (ovpn-120-212.rdu2.redhat.com [10.10.120.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id D52F01001B3F; Wed, 4 Mar 2020 18:59:09 +0000 (UTC) Subject: Re: [PATCH v6 7/9] iotests: ignore import warnings from pylint To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , qemu-devel@nongnu.org References: <20200227000639.9644-1-jsnow@redhat.com> <20200227000639.9644-8-jsnow@redhat.com> <02d688f5-2104-ff45-e174-c61b1c25d7cb@redhat.com> <590ac875-bf9d-afbc-e029-f66050d33344@redhat.com> <76a0567c-9f96-7b55-8a25-ee0933d796a0@redhat.com> From: John Snow Autocrypt: addr=jsnow@redhat.com; prefer-encrypt=mutual; keydata= mQINBFTKefwBEAChvwqYC6saTzawbih87LqBYq0d5A8jXYXaiFMV/EvMSDqqY4EY6whXliNO IYzhgrPEe7ZmPxbCSe4iMykjhwMh5byIHDoPGDU+FsQty2KXuoxto+ZdrP9gymAgmyqdk3aV vzzmCa3cOppcqKvA0Kqr10UeX/z4OMVV390V+DVWUvzXpda45/Sxup57pk+hyY52wxxjIqef rj8u5BN93s5uCVTus0oiVA6W+iXYzTvVDStMFVqnTxSxlpZoH5RGKvmoWV3uutByQyBPHW2U 1Y6n6iEZ9MlP3hcDqlo0S8jeP03HaD4gOqCuqLceWF5+2WyHzNfylpNMFVi+Hp0H/nSDtCvQ ua7j+6Pt7q5rvqgHvRipkDDVsjqwasuNc3wyoHexrBeLU/iJBuDld5iLy+dHXoYMB3HmjMxj 3K5/8XhGrDx6BDFeO3HIpi3u2z1jniB7RtyVEtdupED6lqsDj0oSz9NxaOFZrS3Jf6z/kHIf h42mM9Sx7+s4c07N2LieUxcfqhFTaa/voRibF4cmkBVUhOD1AKXNfhEsTvmcz9NbUchCkcvA T9119CrsxfVsE7bXiGvdXnzyGLXdsoosjzwacKdOrVaDmN3Uy+SHiQXo6TlkSdV0XH2PUxTM LsBFIO9qXO43Ai6J6iPAP/01l8fuZfpJE0/L/c25yyaND7xA3wARAQABtCpKb2huIFNub3cg KEpvaG4gSHVzdG9uKSA8anNub3dAcmVkaGF0LmNvbT6JAlQEEwECAD4CGwMCHgECF4AFCwkI BwMFFQoJCAsFFgIDAQAWI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mvd5pL/+5WI6NTdW6DMfigTtdd85fe6PwBNVJL2ZvBfsBJZ5rxg1TOH3KLsYBqBTgW2 glQofxhkJhDEcvjLhe3Y2BlbCWKOmvM8XS9TRt0OwUs= Message-ID: <025df334-9d9f-bee9-4f6a-28894137c6ba@redhat.com> Date: Wed, 4 Mar 2020 13:59:09 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <76a0567c-9f96-7b55-8a25-ee0933d796a0@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Cleber Rosa , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 3/3/20 7:02 PM, Philippe Mathieu-Daud=C3=A9 wrote: > On 3/3/20 8:57 PM, John Snow wrote: >> On 2/27/20 9:14 AM, Philippe Mathieu-Daud=C3=A9 wrote: >>> On 2/27/20 1:06 AM, John Snow wrote: >>>> The right way to solve this is to come up with a virtual environment >>>> infrastructure that sets all the paths correctly, and/or to create >>>> installable python modules that can be imported normally. >>>> >>>> That's hard, so just silence this error for now. >>> >>> I'm tempted to NAck this and require an "installable python module"... >>> >>> Let's discuss why it is that hard! >>> >> >> I've been tricked into this before. It's not work I am interested in >> doing right now; it's WAY beyond the scope of what I am doing here. >> >> It involves properly factoring all of our python code, deciding which >> portions are meant to be installed separately from QEMU itself, coming >> up with a versioning scheme, packaging code, and moving code around in >> many places. >> >> Then it involves coming up with tooling and infrastructure for creating >> virtual environments, installing the right packages to it, and using it >> to run our python tests. >> >> No, that's way too invasive. I'm not doing it and I will scream loudly >> if you make me. >> >> A less invasive hack involves setting the python import path in a >> consolidated spot so that python knows where it can import from. This >> works, but might break the ability to run such tests as one-offs without >> executing the environment setup. >> >> Again, not work I care to do right now and so I won't. The benefit of >> these patches is to provide some minimum viable CI CQA for Python where >> we had none before, NOT fix every possible Python problem in one shot. >=20 > OK I guess we misunderstood each other :) >=20 > I didn't understood your comment as personal to you for this patch, but > generic. It makes sense it is not your priority and it is obvious this > task will take a single developer a lot of time resources. I am > certainly NOT asking you to do it. >=20 > My question was rather community-oriented. > (Cc'ing Eduardo because we talked about this after the last KVM forum). >=20 OK, *that* is a fair question -- but you did threaten to reject the patch, implying it was in-scope for this series. In no uncertain terms, it is not. HOWEVER ... since we're here, let's discuss python packaging. This is the iotests code base. It is not intended to be packaged as such, it's intended to be run in-tree or in the build folder. It will rely on files being in specific paths and so on. (I don't remember if iotests is designed to detect features at runtime or if it still uses the build options to skip tests. Cleber would know better, as he's battled this distinction in the past.) Regardless, I think iotests depends on the qemu version AND the build configuration, so iotests shouldn't be independently packaged or packagable. It should remain "a collection of scripts" instead. In this paradigm, python can only find descendant files. Importing from subfolders using relative paths. In this case, we're trying to climb *up* the path tree, which causes grief. One often quoted solution is to use syspath hacking to dynamically, at runtime, add parent folders to the PYTHONPATH. Most static analysis tooling I have used to date is unable to cope with this workaround -- hence pylint's failure to find the package being imported. (If we progress to using mypy, mypy will also be unable to cope with this statement. It becomes clear we need to create a well defined environment so tools know where they are allowed to look for sources.) However, the thing we are trying to import is something that arguably can be turned into an installable package as a light Python SDK for interfacing with QEMU. That's worth doing. This code does not (AFAIK) depend on any build configuration. That's good! So there are a few approaches, and they're not mutually exclusive. Option 1 *can* be a stopgap to option 2. 1. Use the iotest runners to set the PYTHONPATH to include the python/qemu source tree directory. The imports will fail outside of the test runner now, but we won't have to do any syspath hacking. This is likely not important because the tests already require a good number of environment variables set to function properly anyway. This is a good workaround, but still outside of the scope for this series. Notably, any pylint gating will need to occur under this specialized environment (with PYTHONPATH set.) This might be more of a burden at times. 2. Convert the "python/qemu" folder into an installable "qemu" module. The version of this package can track the `git describe` version well. Once it is installable, there are several ways to use it: A: Install it using pip/setuptools to the system. (pip3 install .) B: Install it to the user's environment (pip3 install --user .) C: Create a virtual environment (using whichever virtual environment tool of your choice) and then having entered the venv, installing it: (pip3 install .) D: Any of the options above, but in editable/develop mode. In this mode, the package is installed using symlinks that point back to the source code files. This allows you to edit the package as you work without having to reinstall after each change. You'll use something like this: pip3 install [--user] -e . python3 setup.py develop [--user] E: Continue just setting PYTHONPATH to point to the package when needed. This is essentially editable/develop mode but without invoking setuptools. At the moment, I don't believe we use any virtualenv configurations or declare our dependencies natively to python tooling -- we rely on configure to check for distribution packages. We may want to get serious about python and begin using virtualenvironments in places where it makes sense (instead of PYTHONPATH hacking), but they are expensive to build so they should be persistent so they can be re-engaged quickly to run tests and other scripts= . (A development venv might include our qemu package, the sphinx packages locked to the correct versions, etc. We have not had major problems here yet, but as our usage of python expands for document building and we revamp QAPI, it may become more important to start fashioning these bespoke environments to create more reproducible builds across different environments.) --js