From 62f9a0bde39aec0b4a13be441e5f12f568fc58b4 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 26 Aug 2022 14:44:56 +0100 Subject: [PATCH 1/5] Improve warnings in editable install --- setuptools/build_meta.py | 7 ++++--- setuptools/command/editable_wheel.py | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index 8ff9a5ceca..e8f1c72d59 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -437,9 +437,10 @@ def build_editable( info_dir = self._get_dist_info_dir(metadata_directory) opts = ["--dist-info-dir", info_dir] if info_dir else [] cmd = ["editable_wheel", *opts, *self._editable_args(config_settings)] - return self._build_with_temp_dir( - cmd, ".whl", wheel_directory, config_settings - ) + with suppress_known_deprecation(): + return self._build_with_temp_dir( + cmd, ".whl", wheel_directory, config_settings + ) def get_requires_for_build_editable(self, config_settings=None): return self.get_requires_for_build_wheel(config_settings) diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index d05c3a75e9..80c6d5d935 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -393,7 +393,7 @@ def __call__(self, wheel: "WheelFile", files: List[str], mapping: Dict[str, str] def __enter__(self): msg = f""" Editable install will be performed using .pth file to extend `sys.path` with: - {self.path_entries!r} + {list(map(os.fspath, self.path_entries))!r} """ _logger.warning(msg + _LENIENT_WARNING) return self @@ -503,7 +503,11 @@ def __enter__(self): return self def __exit__(self, _exc_type, _exc_value, _traceback): - ... + msg = """\n + Please be careful with folders in your working directory with the same + name as your package as they may take precedence during imports. + """ + warnings.warn(msg, InformationOnly) def _can_symlink_files(base_dir: Path) -> bool: From bab21fe861169cc1cdc395c9fc45aedddc66348c Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 26 Aug 2022 15:16:42 +0100 Subject: [PATCH 2/5] Document CWD limitations in editable docs --- docs/userguide/development_mode.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/userguide/development_mode.rst b/docs/userguide/development_mode.rst index a421999bbc..2dc6dfbd0d 100644 --- a/docs/userguide/development_mode.rst +++ b/docs/userguide/development_mode.rst @@ -155,6 +155,10 @@ Limitations projects structured using :ref:`flat-layout` is still **experimental**. If you experience problems, you can try converting your package structure to the :ref:`src-layout`. +- File system entries in the current working directory + whose names coincidentally match installed packages + may take precedence in :doc:`Python's import system `. + Users are encouraged to avoid such scenarios [#cwd]_. .. attention:: Editable installs are **not a perfect replacement for regular installs** @@ -240,6 +244,13 @@ More information is available on the text of :pep:`PEP 660 <660#what-to-put-in-t packages created with ``pkgutil`` or ``pkg_namespaces``, however this is not officially supported. +.. [#cwd] + Techniques like the :ref:`src-layout` or tooling-specific options like + `tox's changedir `_ + can be used to prevent such kinds of situations (chekout `this blog post + `_ for more + insights). + .. [#installer] For this workaround to work, the installer tool needs to support legacy editable installations. (Future versions of ``pip``, for example, may drop From 8b44cc25a32f6e7fc74533c1b3819bcaea696fae Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 26 Aug 2022 15:17:04 +0100 Subject: [PATCH 3/5] Fix RST syntax in changelog --- CHANGES.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 8e35e3f696..f7a0a003ab 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,7 +8,7 @@ Changes Documentation changes ^^^^^^^^^^^^^^^^^^^^^ -* #3554: Changed requires to requests in the pyproject.toml example in the :ref:`Dependency management section of the Quickstart guide ` -- by :user:`mfbutner` +* #3554: Changed requires to requests in the pyproject.toml example in the :doc:`Dependency management section of the Quickstart guide ` -- by :user:`mfbutner` Misc ^^^^ @@ -44,7 +44,7 @@ Changes Documentation changes ^^^^^^^^^^^^^^^^^^^^^ -* #3538: Corrected documentation on how to use the `legacy-editable` mode. +* #3538: Corrected documentation on how to use the ``legacy-editable`` mode. v65.0.2 From 7aa3e4c38977ae2a8ed1313e88bd083f94f762d6 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 26 Aug 2022 15:19:45 +0100 Subject: [PATCH 4/5] Add news fragment --- changelog.d/3569.misc.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelog.d/3569.misc.rst diff --git a/changelog.d/3569.misc.rst b/changelog.d/3569.misc.rst new file mode 100644 index 0000000000..940789268c --- /dev/null +++ b/changelog.d/3569.misc.rst @@ -0,0 +1,2 @@ +Improved information about conflicting entries in the current working directory +and editable install (in documentation and as an informational warning). From 3c100aa427be613590d026f40dc3cf5943c543b6 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 11 Oct 2022 17:56:26 +0100 Subject: [PATCH 5/5] Fix misspelling in docs/userguide/development_mode.rst --- docs/userguide/development_mode.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/userguide/development_mode.rst b/docs/userguide/development_mode.rst index 2dc6dfbd0d..5378b994b4 100644 --- a/docs/userguide/development_mode.rst +++ b/docs/userguide/development_mode.rst @@ -247,7 +247,7 @@ More information is available on the text of :pep:`PEP 660 <660#what-to-put-in-t .. [#cwd] Techniques like the :ref:`src-layout` or tooling-specific options like `tox's changedir `_ - can be used to prevent such kinds of situations (chekout `this blog post + can be used to prevent such kinds of situations (checkout `this blog post `_ for more insights).