Skip to content

Commit

Permalink
Validate wheel content (#33)
Browse files Browse the repository at this point in the history
Summary:
This PR checks the wheel content and asserts that:

- all of `libtorchcodec[4567].so` are present in the wheel
- libtorchcodec.so is not in the wheel
- none of libavfilter.so, libavcodec.so etc. are present in the wheel
- none of the doc, test or benchmarks folders are present in the wheel

This adds more reassurance that we won't be publishing broken wheel and thus preserve the user's experience.

Pull Request resolved: #33

Reviewed By: ahmadsharif1

Differential Revision: D58646828

Pulled By: NicolasHug

fbshipit-source-id: 05df551cf455cc519d27619726bae169a52028cc
  • Loading branch information
NicolasHug authored and facebook-github-bot committed Jun 17, 2024
1 parent e1e0352 commit 736a57c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
27 changes: 27 additions & 0 deletions .github/scripts/helpers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

_list_wheel_files() {
unzip -l "$1" | awk '{print $4}'
}

# $1 = path to wheel
# $2 = pattern to grep for in wheel files
# If files matching $2 are found in the wheel, the function errors.
assert_not_in_wheel() {
wheel_files=$(_list_wheel_files "$1")
if grep -q "$2" <<< "$wheel_files"
then
echo "Found files in $1 that start with $2. Exiting!!"
exit 1
fi
}

# See assert_not_in_wheel
assert_in_wheel() {
wheel_files=$(_list_wheel_files "$1")
if ! grep -q "$2" <<< "$wheel_files"
then
echo "Did not find files in $1 that start with $2. Exiting!!"
exit 1
fi
}
22 changes: 17 additions & 5 deletions .github/workflows/wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,27 @@ jobs:
# Just for sanity, make sure FFmpeg isn't installed or needed for buidling.
.github/scripts/assert_ffmpeg_not_installed.sh
# TODO: Need to make sure the wheel only contains torchcodec and not
# the other folders (tests, docs, etc.)
python -m pip install build
BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python -m build . -vvv --no-isolation
- name: Show the .so files in the wheel
- name: Validate wheel content
run: |
# This should show libtorchcodec4.so, libtorchcodec5.so, etc.
source .github/scripts/helpers.sh
wheel_path=`find dist -type f -name "*.whl"`
unzip -l $wheel_path | grep .so
echo "Wheel content:"
unzip -l $wheel_path
for ffmpeg_major_version in 4 5 6 7; do
assert_in_wheel $wheel_path torchcodec/libtorchcodec${ffmpeg_major_version}.so
done
assert_not_in_wheel $wheel_path libtorchcodec.so
for ffmpeg_so in libavcodec.so libavfilter.so libavformat.so libavutil.so libavdevice.so ; do
assert_not_in_wheel $wheel_path $ffmpeg_so
done
assert_not_in_wheel $wheel_path "^test"
assert_not_in_wheel $wheel_path "^doc"
assert_not_in_wheel $wheel_path "^benchmarks"
- uses: actions/upload-artifact@v4
with:
name: sdist-and-wheel-linux_x86_${{ matrix.python-version }}
Expand Down

0 comments on commit 736a57c

Please sign in to comment.