Skip to content

Commit

Permalink
Merge pull request #65 from ssciwr/print_toggle
Browse files Browse the repository at this point in the history
make printing the found binary conditional on ENV
  • Loading branch information
renefritze authored Mar 18, 2024
2 parents ba761b1 + fcb1eb3 commit 757a007
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +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: ${{ steps.set_artifact_name.outputs.value }}

build-sdist:
name: Build source distribution
Expand All @@ -137,6 +145,7 @@ jobs:
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
name: archive_sdist

test-sdist:
name: Test build from source distribution
Expand All @@ -151,9 +160,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
Expand All @@ -177,10 +186,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/[email protected]
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 3 additions & 1 deletion clang_tidy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import functools
import pkg_resources
import os


@functools.lru_cache(maxsize=None)
Expand All @@ -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}")
Expand Down
13 changes: 12 additions & 1 deletion test/test_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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",
Expand Down

0 comments on commit 757a007

Please sign in to comment.