Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve warnings in editable install #3569

Merged
merged 5 commits into from Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGES.rst
Expand Up @@ -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 <userguide/quickstart:dependency-management>` -- by :user:`mfbutner`
* #3554: Changed requires to requests in the pyproject.toml example in the :doc:`Dependency management section of the Quickstart guide <userguide/quickstart>` -- by :user:`mfbutner`

Misc
^^^^
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions 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).
11 changes: 11 additions & 0 deletions docs/userguide/development_mode.rst
Expand Up @@ -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 <python:reference/import>`.
Users are encouraged to avoid such scenarios [#cwd]_.

.. attention::
Editable installs are **not a perfect replacement for regular installs**
Expand Down Expand Up @@ -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 <https://tox.wiki/en/stable/config.html#conf-changedir>`_
can be used to prevent such kinds of situations (chekout `this blog post
abravalheri marked this conversation as resolved.
Show resolved Hide resolved
<https://blog.ganssle.io/articles/2019/08/test-as-installed.html>`_ 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
Expand Down
7 changes: 4 additions & 3 deletions setuptools/build_meta.py
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions setuptools/command/editable_wheel.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down