summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-03-21 08:34:44 +0000
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-03-21 08:36:08 +0000
commit533115f08eab629a4f92c0f9f5f8d296153cd765 (patch)
tree619d1e9bb3096a22381e1aa4141d4b56e6e2eb83
parentaefa213c7625d111946f657e9afe3092e8c6a590 (diff)
downloadpython-setuptools-git-533115f08eab629a4f92c0f9f5f8d296153cd765.tar.gz
Refactor ConfigDiscovery._root_dir as a property
-rw-r--r--setuptools/discovery.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/setuptools/discovery.py b/setuptools/discovery.py
index 837cea9e..b9aedfb0 100644
--- a/setuptools/discovery.py
+++ b/setuptools/discovery.py
@@ -270,12 +270,16 @@ class ConfigDiscovery:
self.dist = distribution
self._called = False
self._disabled = False
- self._root_dir: _Path # delay so `src_root` can be set in dist
def _disable(self):
"""Internal API to disable automatic discovery"""
self._disabled = True
+ @property
+ def _root_dir(self) -> _Path:
+ # The best is to wait until `src_root` is set in dist, before using _root_dir.
+ return self.dist.src_root or os.curdir
+
def __call__(self, force=False, name=True):
"""Automatically discover missing configuration fields
and modifies the given ``distribution`` object in-place.
@@ -291,8 +295,6 @@ class ConfigDiscovery:
# Avoid overhead of multiple calls
return
- self._root_dir = self.dist.src_root or os.curdir
-
self._analyse_package_layout()
if name:
self.analyse_name() # depends on ``packages`` and ``py_modules``