From nobody Mon Feb 9 16:19:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645654315796965.6492443233208; Wed, 23 Feb 2022 14:11:55 -0800 (PST) Received: from localhost ([::1]:58410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMzrW-00041T-U0 for importer@patchew.org; Wed, 23 Feb 2022 17:11:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMzp8-00010t-2X for qemu-devel@nongnu.org; Wed, 23 Feb 2022 17:09:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMzp5-0005sI-MQ for qemu-devel@nongnu.org; Wed, 23 Feb 2022 17:09:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-VDNx6z-bMhOu6gyCsWoyUg-1; Wed, 23 Feb 2022 17:09:18 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06D568145F0; Wed, 23 Feb 2022 22:09:17 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0AE8709E5; Wed, 23 Feb 2022 22:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645654162; 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; bh=YWsFNrDith/OR/Vykh2sZYZFIHsfrC69qr+hpaSmqHE=; b=XsmbPd3U8LUmwWIj2VqaCmtMAOtQgOyOh/DeCyQX+IHBRVtLSlX2hYYcYcGOSe+tvqzaGK 8WY8kTkxhfqM26bNaVtOEZTc3jGFgqk/u/hn5NJ8chRHuw3RTqf6iYSYCRPAXcxUpZCBY2 MyDWvU5YITF2aBuwoTGrVsUTqDD1wj4= X-MC-Unique: VDNx6z-bMhOu6gyCsWoyUg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 3/6] Python: discourage direct setup.py install Date: Wed, 23 Feb 2022 17:08:57 -0500 Message-Id: <20220223220900.2226630-4-jsnow@redhat.com> In-Reply-To: <20220223220900.2226630-1-jsnow@redhat.com> References: <20220223220900.2226630-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Beraldo Leal , qemu-block@nongnu.org, Markus Armbruster , Eduardo Habkost , Hanna Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645654318024100001 When invoking setup.py directly, the default behavior for 'install' is to run the bdist_egg installation hook, which is ... actually deprecated by setuptools. It doesn't seem to work quite right anymore. By contrast, 'pip install' will invoke the bdist_wheel hook instead. This leads to differences in behavior for the two approaches. I advocate using pip in the documentation in this directory, but the 'setup.py' which has been used for quite a long time in the Python world may deceptively appear to work at first glance. Add an error message that will save a bit of time and frustration that points the user towards using the supported installation invocation. Reported-by: Daniel P. Berrang=C3=A9 Signed-off-by: John Snow Reviewed-by: Beraldo Leal Message-id: 20220207213039.2278569-1-jsnow@redhat.com Signed-off-by: John Snow --- python/setup.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index 2014f81b75..c5bc45919a 100755 --- a/python/setup.py +++ b/python/setup.py @@ -5,9 +5,26 @@ """ =20 import setuptools +from setuptools.command import bdist_egg +import sys import pkg_resources =20 =20 +class bdist_egg_guard(bdist_egg.bdist_egg): + """ + Protect against bdist_egg from being executed + + This prevents calling 'setup.py install' directly, as the 'install' + CLI option will invoke the deprecated bdist_egg hook. "pip install" + calls the more modern bdist_wheel hook, which is what we want. + """ + def run(self): + sys.exit( + 'Installation directly via setup.py is not supported.\n' + 'Please use `pip install .` instead.' + ) + + def main(): """ QEMU tooling installer @@ -16,7 +33,7 @@ def main(): # https://medium.com/@daveshawley/safely-using-setup-cfg-for-metadata-= 1babbe54c108 pkg_resources.require('setuptools>=3D39.2') =20 - setuptools.setup() + setuptools.setup(cmdclass=3D{'bdist_egg': bdist_egg_guard}) =20 =20 if __name__ =3D=3D '__main__': --=20 2.34.1