From 92363514224b0aeba065f83b868a15a2a03601ab Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 17 Jul 2018 10:13:38 +0800
Subject: [PATCH] conditionally do not fetch code by easy_install

If NO_FETCH_BUILD is set, do not fetch code in easy_install. This avoids setup.py
trying to fetch missing dependencies at build time.

This is only used by the deprecated codepath as implemented by setuptools3.bbclass, so
when that ever gets removed this patch can also be deleted.

Upstream-Status: Denied [https://github.com/pypa/setuptools/issues/4735]
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>

Update to apply against v75.6.0.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 setuptools/command/easy_install.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index eb1b4c1..4fd8d14 100644
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -672,6 +672,11 @@ class easy_install(Command):
             os.path.exists(tmpdir) and _rmtree(tmpdir)
 
     def easy_install(self, spec, deps: bool = False) -> Distribution | None:
+        if os.environ.get('NO_FETCH_BUILD', None):
+            log.error("ERROR: Do not try to fetch `%s' for building. "
+                      "Please add its native recipe to DEPENDS." % spec)
+            return None
+
         with self._tmpdir() as tmpdir:
             if not isinstance(spec, Requirement):
                 if URL_SCHEME(spec):
