python-poetry / python-poetry/poetry

Trace on excluded broken symlinks

Open
#8,257 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/build-system kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Issue

The problem: our tool has tests with broken symlinks in 'output' (which is fine, and is a part of the normal test). Those symlinks are in outputs/some/levels/here and in , foo/tests/some/levels/here. Both are excluded from build:

exclude = ["outputs/**", "foo/tests/**"]

Example of the broken symlink:

./foo/tests/by-path/pci-0000:05:00.0-ata-1 -> /dev/sdb

When poetry is run as poetry build or poetry install it fails:

      Traceback (most recent call last):
        File "/home/amarao/git/foo/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/amarao/git/foo/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/amarao/git/foo/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-q88jekkt/overlay/lib/python3.11/site-packages/poetry/core/masonry/api.py", line 57, in build_wheel
          return WheelBuilder.make_in(
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-q88jekkt/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/wheel.py", line 88, in make_in
          wb.build(target_dir=directory)
        File "/tmp/pip-build-env-q88jekkt/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/wheel.py", line 124, in build
          self._copy_module(zip_file)
        File "/tmp/pip-build-env-q88jekkt/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/wheel.py", line 235, in _copy_module
          to_add = self.find_files_to_add()
                   ^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-q88jekkt/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/builder.py", line 201, in find_files_to_add
          include_file.relative_to_project_root()
        File "/tmp/pip-build-env-q88jekkt/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/builder.py", line 397, in relative_to_project_root
          return self.path.relative_to(self.project_root)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/pathlib.py", line 731, in relative_to
          raise ValueError("{!r} is not in the subpath of {!r}"
      ValueError: '/dev/sdb' is not in the subpath of '/home/amarao/git/foo' OR one path is relative and the other is absolute.

Expected behavior: ignore everything in exclude

Actual behavior: trace from poetry for both install and build commands.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the failing path in poetry/core/masonry/builders/builder.py, especially relative_to_project_root(), and the caller in poetry/core/masonry/builders/wheel.py. Reproduce with poetry build or poetry install using an excluded broken symlink; done means excluded symlinks are ignored without a traceback.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.