Skip to content

Commit

Permalink
Merge branches 'maintenance/gha-macos-amd64' and 'bugfixes/992-packag…
Browse files Browse the repository at this point in the history
…ing-in-tree-backend-tmp-copy-logic'
  • Loading branch information
webknjaz committed May 30, 2024
3 parents c3d67e5 + 40b0d27 + 3d5a01b commit 5f9ebbb
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ jobs:
*-macosx_universal2
*-musllinux_*
*-win32
*_arm64
pp*'
|| ''
}}
Expand Down Expand Up @@ -175,28 +174,41 @@ jobs:
- 3.8
- 3.7
no-extensions: ['', 'Y']
os: [ubuntu, macos, windows]
os:
- ubuntu-latest
- macos-latest
- windows-latest
experimental: [false]
exclude:
- os: macos
- os: macos-latest
no-extensions: Y
- os: windows
- os: windows-latest
no-extensions: Y
- os: macos-latest
pyver: 3.7 # Python < v3.8 does not support Apple Silicon ARM64
include:
- pyver: pypy-3.10
no-extensions: Y
experimental: false
os: ubuntu
os: ubuntu-latest
- pyver: pypy-3.9
no-extensions: Y
experimental: false
os: ubuntu
os: ubuntu-latest
- pyver: pypy-3.8
no-extensions: Y
experimental: false
os: ubuntu
os: ubuntu-latest
- os: macos-13 # run legacy versions on Intel CPUs
pyver: 3.7
no-extensions: ''
experimental: false
- os: macos-13 # run legacy versions on Intel CPUs
pyver: 3.7
no-extensions: Y
experimental: false
fail-fast: false
runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 5
continue-on-error: ${{ matrix.experimental }}
steps:
Expand Down
9 changes: 9 additions & 0 deletions CHANGES/1014.packaging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
A flaw in the logic for copying the project directory into a
temporary folder that led to infinite recursion when :envvar:`TMPDIR`
was set to a project subdirectory path. This was happening in Fedora
and its downstream due to the use of `pyproject-rpm-macros
<https://src.fedoraproject.org/rpms/pyproject-rpm-macros>`__. It was
only reproducible with ``pip wheel`` and was not affecting the
``pyproject-build`` users.

-- by :user:`hroncok` and :user:`webknjaz`
3 changes: 3 additions & 0 deletions CHANGES/1015.contrib.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The CI/CD setup has been updated to test ``arm64`` wheels
under macOS 14, except for Python 3.7 that is unsupported
in that environment -- by :user:`webknjaz`.
1 change: 1 addition & 0 deletions CHANGES/992.packaging.rst
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@

default_role = "any"
nitpicky = True
nitpick_ignore = [
("envvar", "TMPDIR"),
]

# -- Options for towncrier_draft extension -----------------------------------

Expand Down
37 changes: 35 additions & 2 deletions packaging/pep517_backend/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import typing as t
from contextlib import contextmanager, nullcontext, suppress
from functools import partial
from pathlib import Path
from shutil import copytree
from sys import implementation as _system_implementation
Expand Down Expand Up @@ -194,12 +195,44 @@ def _get_sanitized_long_description(self):
_DistutilsDistributionMetadata.get_long_description = _orig_func


def _exclude_dir_path(
excluded_dir_path: Path,
visited_directory: str,
_visited_dir_contents: list[str],
) -> list[str]:
"""Prevent recursive directory traversal."""
# This stops the temporary directory from being copied
# into self recursively forever.
# Ref: https://github.com/aio-libs/yarl/issues/992
visited_directory_subdirs_to_ignore = [
subdir
for subdir in _visited_dir_contents
if excluded_dir_path == Path(visited_directory) / subdir
]
if visited_directory_subdirs_to_ignore:
print(
f'Preventing `{excluded_dir_path !s}` from being '
'copied into itself recursively...',
file=_standard_error_stream,
)
return visited_directory_subdirs_to_ignore


@contextmanager
def _in_temporary_directory(src_dir: Path) -> t.Iterator[None]:
with TemporaryDirectory(prefix='.tmp-yarl-pep517-') as tmp_dir:
tmp_dir_path = Path(tmp_dir)
root_tmp_dir_path = tmp_dir_path.parent
_exclude_tmpdir_parent = partial(_exclude_dir_path, root_tmp_dir_path)

with chdir_cm(tmp_dir):
tmp_src_dir = Path(tmp_dir) / 'src'
copytree(src_dir, tmp_src_dir, symlinks=True)
tmp_src_dir = tmp_dir_path / 'src'
copytree(
src_dir,
tmp_src_dir,
ignore=_exclude_tmpdir_parent,
symlinks=True,
)
os.chdir(tmp_src_dir)
yield

Expand Down

0 comments on commit 5f9ebbb

Please sign in to comment.