Skip to content

Commit

Permalink
Merge pull request #916 from google/test-python-wheel
Browse files Browse the repository at this point in the history
test pure python wheel on multiple platforms
  • Loading branch information
reyammer authored Jan 23, 2025
2 parents e7e8472 + 62653dd commit 0c6e954
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 8 deletions.
74 changes: 67 additions & 7 deletions .github/workflows/python-build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ jobs:
working-directory: python
- if: matrix.platform.runner != 'windows-latest'
name: Check that `uv add magika.whl` works
run: mkdir /tmp/test-uv && cp -vR dist/*.whl /tmp/test-uv && cd /tmp/test-uv && uv init && uv add ./$(\ls -1 *.whl | head -n 1)
run: |
mkdir /tmp/test-uv
cp -vR dist/*.whl /tmp/test-uv
cd /tmp/test-uv
uv init
uv add ./$(\ls -1 *.whl | head -n 1)
- if: matrix.platform.runner == 'windows-latest'
name: Check that magika install with uv works on Windows
name: Check that `uv add magika.whl` works
shell: pwsh
run: |
mkdir C:\test-uv
Expand All @@ -79,7 +84,6 @@ jobs:
- run: python3 ./python/scripts/run_quick_test_magika_cli.py
- run: python3 ./python/scripts/run_quick_test_magika_module.py
- name: Upload wheels
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }}
Expand All @@ -97,17 +101,73 @@ jobs:
run: uv build --wheel --out-dir ../dist
working-directory: python
- name: Check that `uv add magika.whl` works
run: mkdir /tmp/test-uv && cp -vR dist/*.whl /tmp/test-uv && cd /tmp/test-uv && uv init && uv add ./$(\ls -1 *.whl | head -n 1)
- name: Install wheels
run: |
mkdir /tmp/test-uv
cp -vR dist/*.whl /tmp/test-uv
cd /tmp/test-uv
uv init
uv add ./$(\ls -1 *.whl | head -n 1)
- name: Install the wheel
run: python3 -m pip install $(python -c "import glob; print(glob.glob('dist/*.whl')[0])")
- run: magika --version
- run: "python3 -c 'import magika; m = magika.Magika(); print(m)'"
- run: magika -r tests_data/basic
- run: python3 ./python/scripts/run_quick_test_magika_cli.py
- run: python3 ./python/scripts/run_quick_test_magika_module.py
- name: Upload wheel
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: wheels-pure
name: wheels-pure-python
path: dist

# Download, install, and test the pure python wheel on multiple platforms
test-pure-python-wheel:
needs: [build-pure-python-wheel]
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: windows-latest
target: x64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: wheels-pure-python
path: dist
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # pin@v5
with:
python-version: '3.12'
- name: Install uv
run: curl -LsSf https://astral.sh/uv/0.5.22/install.sh | sh
- if: matrix.platform.runner != 'windows-latest'
name: Check that `uv add magika.whl` works
run: |
mkdir /tmp/test-uv
cp -vR dist/*.whl /tmp/test-uv
cd /tmp/test-uv
uv init
uv add ./$(\ls -1 *.whl | head -n 1)
- if: matrix.platform.runner == 'windows-latest'
name: Check that `uv add magika.whl` works
shell: pwsh
run: |
mkdir C:\test-uv
Copy-Item -Path dist\*.whl -Destination C:\test-uv
cd C:\test-uv
$env:PATH += ";$HOME/.local/bin"
uv init
$wheel = Get-ChildItem -Filter *.whl | Select-Object -ExpandProperty Name
uv add ".\$wheel"
- name: Install the wheel
run: python3 -m pip install $(python -c "import glob; print(glob.glob('dist/*.whl')[0])")
- run: magika --version
- run: "python3 -c 'import magika; m = magika.Magika(); print(m)'"
- run: magika -r tests_data/basic
- run: python3 ./python/scripts/run_quick_test_magika_cli.py
- run: python3 ./python/scripts/run_quick_test_magika_module.py
3 changes: 2 additions & 1 deletion python/scripts/run_quick_test_magika_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def main(client_path: Optional[Path]) -> None:
print(f"stderr:\n{p.stderr}\n" + "-" * 40)
sys.exit(1)

assert p.stderr == ""
if p.stderr != "":
print(f"WARNING: p.stderr not empty: {p.stderr}")

with_error = False
lines = p.stdout.split("\n")
Expand Down

0 comments on commit 0c6e954

Please sign in to comment.