Skip to content

Commit a55b024

Browse files
committed
7 parents 3d7dd47 + 5434cb0 + 063aecd + 3c3b444 + d2e277d + 7aa3e4c + ac7a0dd commit a55b024

File tree

15 files changed

+68
-33
lines changed

15 files changed

+68
-33
lines changed

CHANGES.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Changes
2727

2828
Documentation changes
2929
^^^^^^^^^^^^^^^^^^^^^
30-
* #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`
30+
* #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`
3131

3232
Misc
3333
^^^^
@@ -63,7 +63,7 @@ Changes
6363

6464
Documentation changes
6565
^^^^^^^^^^^^^^^^^^^^^
66-
* #3538: Corrected documentation on how to use the `legacy-editable` mode.
66+
* #3538: Corrected documentation on how to use the ``legacy-editable`` mode.
6767

6868

6969
v65.0.2

changelog.d/3569.misc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improved information about conflicting entries in the current working directory
2+
and editable install (in documentation and as an informational warning).

changelog.d/3576.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated version of ``validate_pyproject``.

changelog.d/3624.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed editable install for multi-module/no-package ``src``-layout projects.

docs/userguide/development_mode.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ Limitations
155155
projects structured using :ref:`flat-layout` is still **experimental**.
156156
If you experience problems, you can try converting your package structure
157157
to the :ref:`src-layout`.
158+
- File system entries in the current working directory
159+
whose names coincidentally match installed packages
160+
may take precedence in :doc:`Python's import system <python:reference/import>`.
161+
Users are encouraged to avoid such scenarios [#cwd]_.
158162

159163
.. attention::
160164
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
240244
packages created with ``pkgutil`` or ``pkg_namespaces``, however this is not
241245
officially supported.
242246
247+
.. [#cwd]
248+
Techniques like the :ref:`src-layout` or tooling-specific options like
249+
`tox's changedir <https://tox.wiki/en/stable/config.html#conf-changedir>`_
250+
can be used to prevent such kinds of situations (chekout `this blog post
251+
<https://blog.ganssle.io/articles/2019/08/test-as-installed.html>`_ for more
252+
insights).
253+
243254
.. [#installer]
244255
For this workaround to work, the installer tool needs to support legacy
245256
editable installations. (Future versions of ``pip``, for example, may drop

setuptools/build_meta.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,10 @@ def build_editable(
437437
info_dir = self._get_dist_info_dir(metadata_directory)
438438
opts = ["--dist-info-dir", info_dir] if info_dir else []
439439
cmd = ["editable_wheel", *opts, *self._editable_args(config_settings)]
440-
return self._build_with_temp_dir(
441-
cmd, ".whl", wheel_directory, config_settings
442-
)
440+
with suppress_known_deprecation():
441+
return self._build_with_temp_dir(
442+
cmd, ".whl", wheel_directory, config_settings
443+
)
443444

444445
def get_requires_for_build_editable(self, config_settings=None):
445446
return self.get_requires_for_build_wheel(config_settings)

setuptools/command/editable_wheel.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def _safely_run(self, cmd_name: str):
294294
msg = f"""{traceback.format_exc()}\n
295295
If you are seeing this warning it is very likely that a setuptools
296296
plugin or customization overrides the `{cmd_name}` command, without
297-
tacking into consideration how editable installs run build steps
297+
taking into consideration how editable installs run build steps
298298
starting from v64.0.0.
299299
300300
Plugin authors and developers relying on custom build steps are encouraged
@@ -393,7 +393,7 @@ def __call__(self, wheel: "WheelFile", files: List[str], mapping: Dict[str, str]
393393
def __enter__(self):
394394
msg = f"""
395395
Editable install will be performed using .pth file to extend `sys.path` with:
396-
{self.path_entries!r}
396+
{list(map(os.fspath, self.path_entries))!r}
397397
"""
398398
_logger.warning(msg + _LENIENT_WARNING)
399399
return self
@@ -503,7 +503,11 @@ def __enter__(self):
503503
return self
504504

505505
def __exit__(self, _exc_type, _exc_value, _traceback):
506-
...
506+
msg = """\n
507+
Please be careful with folders in your working directory with the same
508+
name as your package as they may take precedence during imports.
509+
"""
510+
warnings.warn(msg, InformationOnly)
507511

508512

509513
def _can_symlink_files(base_dir: Path) -> bool:
@@ -551,13 +555,18 @@ def _simple_layout(
551555
False
552556
>>> _simple_layout(['a', 'a.b'], {"": "src", "a.b": "_ab"}, "/tmp/myproj")
553557
False
558+
>>> # Special cases, no packages yet:
559+
>>> _simple_layout([], {"": "src"}, "/tmp/myproj")
560+
True
561+
>>> _simple_layout([], {"a": "_a", "": "src"}, "/tmp/myproj")
562+
False
554563
"""
555564
layout = {
556565
pkg: find_package_path(pkg, package_dir, project_dir)
557566
for pkg in packages
558567
}
559568
if not layout:
560-
return False
569+
return set(package_dir) in ({}, {""})
561570
parent = os.path.commonpath([_parent_path(k, v) for k, v in layout.items()])
562571
return all(
563572
_normalize_path(Path(parent, *key.split('.'))) == _normalize_path(value)

setuptools/command/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def test_args(self):
118118
return list(self._test_args())
119119

120120
def _test_args(self):
121-
if not self.test_suite and sys.version_info >= (2, 7):
121+
if not self.test_suite:
122122
yield 'discover'
123123
if self.verbose:
124124
yield '--verbose'

setuptools/config/_validate_pyproject/extra_validations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
from typing import Mapping, TypeVar
77

8-
from .fastjsonschema_exceptions import JsonSchemaValueException
8+
from .error_reporting import ValidationError
99

1010
T = TypeVar("T", bound=Mapping)
1111

1212

13-
class RedefiningStaticFieldAsDynamic(JsonSchemaValueException):
13+
class RedefiningStaticFieldAsDynamic(ValidationError):
1414
"""According to PEP 621:
1515
1616
Build back-ends MUST raise an error if the metadata specifies a field

setuptools/config/_validate_pyproject/fastjsonschema_validations.py

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)