Skip to content

Commit

Permalink
Update zipapp script
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 committed May 12, 2024
1 parent 29b5413 commit 82c2ace
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions .config/ci/zipapp.sh
Expand Up @@ -10,7 +10,13 @@ DIR=$(realpath "$(dirname "$0")/../../")
cd $DIR

if [ ! -e "pyproject.toml" ]; then
echo "zipapp.sh must be called from scapy root folder"
echo "zipapp.sh was not able to find scapy's root folder"
exit 1
fi

MODE="$1"
if [ -z "$MODE" ] || ( [ "$MODE" != "full" ] && [ "$MODE" != "simple" ] ); then
echo "Usage: zipapp.sh <simple/full>"
exit 1
fi

Expand All @@ -19,6 +25,9 @@ then
PYTHON=${PYTHON:-python3}
fi

# Get Scapy version
SCPY_VERSION=$(python3 -c "print(__import__('scapy').__version__)")

# Get temp directory
TMPFLD="$(mktemp -d)"
if [ -z "$TMPFLD" ] || [ ! -d "$TMPFLD" ]; then
Expand All @@ -45,11 +54,17 @@ cd "$SCPY" && find . -not \( \
-wholename "./scapy*" -o \
-wholename "./pyproject.toml" -o \
-wholename "./LICENSE" \
\) -print
\) -delete
cd $DIR

# Get DEST file
DEST="./dist/scapy.pyz"
# Depending on the mode, install dependencies and get DEST file
if [ "$MODE" == "full" ]; then
$PYTHON -m pip install --target "$SCPY" IPython
DEST="./dist/scapy-full-$SCPY_VERSION.pyz"
else
DEST="./dist/scapy-$SCPY_VERSION.pyz"
fi

if [ ! -d "./dist" ]; then
mkdir dist
fi
Expand All @@ -66,3 +81,5 @@ $PYTHON -m zipapp \

# Cleanup
rm -rf "$TMPFLD"

echo "Success. zipapp avaiable at $DEST"

0 comments on commit 82c2ace

Please sign in to comment.