Skip to content

Building with Python 3.11.4 generates tarfile.LinkOutsideDestinationError #674

@effigies

Description

@effigies

I have a project where the changelog lives in the root of the repository and I link to it from the doc directory so that it's part of our docs:

project/
  doc/
    source/
      changelog.rst -> ../../Changelog
      ...
    ...
  project/
    ...
  Changelog
  ...

As of Python 3.11.4, attempting to run python -m build produces:

❯ python -m build                                            
* Creating venv isolated environment...
* Installing packages in isolated environment... (hatch-vcs, hatchling)
* Getting build dependencies for sdist...
* Building sdist...

Traceback (most recent call last):
  File "/home/chris/mambaforge/envs/py3114/lib/python3.11/site-packages/build/__main__.py", line 388, in main
    built = build_call(
            ^^^^^^^^^^^
  File "/home/chris/mambaforge/envs/py3114/lib/python3.11/site-packages/build/__main__.py", line 247, in build_package_via_sdist
    t.extractall(sdist_out)
  File "/home/chris/mambaforge/envs/py3114/lib/python3.11/tarfile.py", line 2249, in extractall
    tarinfo = self._get_extract_tarinfo(member, filter_function, path)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chris/mambaforge/envs/py3114/lib/python3.11/tarfile.py", line 2303, in _get_extract_tarinfo
    self._handle_fatal_error(e)
  File "/home/chris/mambaforge/envs/py3114/lib/python3.11/tarfile.py", line 2301, in _get_extract_tarinfo
    tarinfo = filter_function(tarinfo, path)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chris/mambaforge/envs/py3114/lib/python3.11/tarfile.py", line 819, in data_filter
    new_attrs = _get_filtered_attrs(member, dest_path, True)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chris/mambaforge/envs/py3114/lib/python3.11/tarfile.py", line 806, in _get_filtered_attrs
    raise LinkOutsideDestinationError(member, target_path)
tarfile.LinkOutsideDestinationError: 'nibabel-5.2.0.dev36+g30ba615e/doc/source/changelog.rst' would link to '/Changelog', which is outside the destination

ERROR 'nibabel-5.2.0.dev36+g30ba615e/doc/source/changelog.rst' would link to '/Changelog', which is outside the destination

If I run either python -m build -s or python -m build -w, this error does not occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions