From ae8a82e9d8462a00af8e40c918b3a1f44766041c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Fritze?= Date: Wed, 10 Jan 2024 11:07:03 +0100 Subject: [PATCH 1/3] make printing the found binary conditional on ENV --- README.md | 5 +++++ clang_tidy/__init__.py | 4 +++- test/test_executable.py | 13 ++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6bfd7e3..0d73bbe 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,8 @@ This repository extends the great work of several other projects: * The CI build process is controlled by [cibuildwheel](https://github.com/pypa/cibuildwheel) which makes building wheels across a number of platforms a pleasant experience (!) We are grateful for the generous provisioning with CI resources that GitHub currently offers to Open Source projects. + +## Troubleshooting + +To see which clang-tidy binary the package is using +you can set `CLANG_TIDY_WHEEL_VERBOSE` to `1` in your environment. diff --git a/clang_tidy/__init__.py b/clang_tidy/__init__.py index d5d33eb..c4dac31 100644 --- a/clang_tidy/__init__.py +++ b/clang_tidy/__init__.py @@ -3,6 +3,7 @@ from pathlib import Path import functools import pkg_resources +import os @functools.lru_cache(maxsize=None) @@ -11,7 +12,8 @@ def _get_executable(name:str) -> Path: for s in ("", ".exe", ".bin", ".dmg")] for exe in possibles: if exe.exists(): - print(f'Resource filename: {exe} ') + if os.environ.get("CLANG_TIDY_WHEEL_VERBOSE", None): + print(f'Found binary: {exe} ') return exe raise FileNotFoundError(f"No executable found for {name} at\n{possibles}") diff --git a/test/test_executable.py b/test/test_executable.py index 36f8317..abdbd93 100644 --- a/test/test_executable.py +++ b/test/test_executable.py @@ -19,12 +19,14 @@ def ensure_tidy_from_wheel(monkeypatch): monkeypatch.delitem(sys.modules, "clang_tidy", raising=False) -def test_executable_file(): +def test_executable_file(capsys): import clang_tidy + clang_tidy._get_executable.cache_clear() exe = clang_tidy._get_executable("clang-tidy") assert os.path.exists(exe) assert os.access(exe, os.X_OK) + assert capsys.readouterr().out == "" def _test_code(code: str): @@ -40,6 +42,15 @@ def _test_code(code: str): os.remove(compilation_unit) +def test_verbose_output(capsys, monkeypatch): + import clang_tidy + monkeypatch.setenv("CLANG_TIDY_WHEEL_VERBOSE", "1") + # need to clear cache to make sure the function is run again + clang_tidy._get_executable.cache_clear() + clang_tidy._get_executable("clang-tidy") + assert capsys.readouterr().out + + @pytest.mark.skipif( os.environ.get("CI", None) and "linux" in sys.platform, reason="https://github.com/ssciwr/clang-tidy-wheel/issues/30", From 4ccbe2c5610f1f6c5db7ec9c85352155e8cc5d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Fritze?= Date: Wed, 10 Jan 2024 12:47:50 +0100 Subject: [PATCH 2/3] new upload+download actions changed behavior wrt multiple artifacts of same name Adjust by explicitly naming uploads and merging in downloads. It's also not possible to use download v3 for upload v4 artifacts --- .github/workflows/release.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 25eba4f..4d55ccd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -117,6 +117,7 @@ jobs: if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU) with: path: ./wheelhouse/*.whl + name: archive_wheels_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.skip }} build-sdist: name: Build source distribution @@ -137,6 +138,7 @@ jobs: - uses: actions/upload-artifact@v4 with: path: dist/*.tar.gz + name: archive_sdist test-sdist: name: Test build from source distribution @@ -151,9 +153,9 @@ jobs: with: python-version: '3.9' - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: artifact + name: archive_sdist path: sdist - name: Install from SDist @@ -177,10 +179,11 @@ jobs: if: github.repository_owner == 'ssciwr' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: artifact + pattern: archive* path: dist + merge-multiple: true - name: Upload to PyPI uses: pypa/gh-action-pypi-publish@v1.8.11 From fcb1eb3a051f2eb2a4074bf186803c06fe09be48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Fritze?= Date: Wed, 10 Jan 2024 16:58:30 +0100 Subject: [PATCH 3/3] make sure we get a valid archive name --- .github/workflows/release.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4d55ccd..b9fe77a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,11 +113,18 @@ jobs: else docker build --build-arg BASEOS=slim-bullseye --build-arg PLATFORM=manylinux -f .github/workflows/Dockerfile . fi + - name: Set artifact name + id: set_artifact_name + shell: bash -l {0} + run: | + VALUE="archive_wheels_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.skip }}" + VALUE="${VALUE//\*/}" + echo "value=${VALUE}" >> ${GITHUB_OUTPUT} - uses: actions/upload-artifact@v4 if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU) with: path: ./wheelhouse/*.whl - name: archive_wheels_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.skip }} + name: ${{ steps.set_artifact_name.outputs.value }} build-sdist: name: Build source distribution