Skip to content

Commit

Permalink
Implement shellcheck for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed Sep 22, 2024
1 parent 07255c5 commit 1ba0330
Show file tree
Hide file tree
Showing 17 changed files with 146 additions and 93 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ repos:
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
Expand Down
16 changes: 9 additions & 7 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
set -eu

# This script is a utility for the BeeWare team to publish packages to the
# https://anaconda.org/beeware repository. It won't be any use to you unless
# you have write permissions to the `beeware` repo.
Expand All @@ -13,10 +15,10 @@
# (base) $ ./publish.sh
#

for f in $(find dist -name "*.whl"); do
echo "***** PUBLISH $f ***********************************"
anaconda upload -u beeware $f
if [[ $? == 0 ]]; then
mv $f published
fi
done
while IFS= read -r -d '' FILE
do
echo "***** PUBLISH $FILE ***********************************"
if anaconda upload -u beeware "$FILE"; then
mv "$FILE" published
fi
done < <(find ./dist -name "*.whl" -print0)
2 changes: 1 addition & 1 deletion recipes/argon2-cffi/test_argon2_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


# See https://argon2-cffi.readthedocs.io/en/stable/
def test_basic(self):
def test_basic():
import argon2

ph = argon2.PasswordHasher()
Expand Down
2 changes: 1 addition & 1 deletion recipes/bcrypt/test_bcrypt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def test_basic(self):
def test_basic():
import bcrypt

hashed = b"$2b$12$9cwzD/MRnVT7uvkxAQvkIejrif4bwRTGvIRqO7xf4OYtDQ3sl8CWW"
Expand Down
1 change: 0 additions & 1 deletion recipes/brotli/test_brotli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ def test_basic():
plain = b"it was the best of times, it was the worst of times"
compressed = brotli.compress(plain)

compressed = compressed.hex()
assert len(compressed) < len(plain)
assert plain == brotli.decompress(compressed)
12 changes: 7 additions & 5 deletions recipes/bzip2/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
#!/bin/sh
set -eu

mkdir -p $PREFIX
cp -r include $PREFIX
cp -r lib $PREFIX
: "${PREFIX?ENV VAR MUST BE SET}"

mkdir -p "$PREFIX"
cp -r include "$PREFIX"
cp -r lib "$PREFIX"

# Strip out any dylib files to ensure static linking
find $PREFIX -name "*.dylib" -exec rm -rf {} \;
find "$PREFIX" -name "*.dylib" -exec rm -rf {} \;
24 changes: 13 additions & 11 deletions recipes/freetype/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
#!/bin/sh
set -eu

: "${PREFIX?ENV VAR MUST BE SET}"

./configure \
--host=$HOST_TRIPLET \
--build=$BUILD_TRIPLET \
--host="$HOST_TRIPLET" \
--build="$BUILD_TRIPLET" \
--enable-static \
--without-harfbuzz \
--without-png \
Expand All @@ -12,15 +14,15 @@ set -eu
ZLIB_CFLAGS="-I$INSTALL_ROOT/include" \
ZLIB_LIBS="-L$INSTALL_ROOT/lib -lz"

make -j $CPU_COUNT
make install prefix=$PREFIX
make -j "$CPU_COUNT"
make install prefix="$PREFIX"

mv $PREFIX/include/freetype2/* $PREFIX/include
rmdir $PREFIX/include/freetype2
mv "$PREFIX/include/freetype2/"* "$PREFIX/include"
rmdir "$PREFIX/include/freetype2"

# Some versions of Android (e.g. API level 26) have a libft2.so in /system/lib, but our copy
# has an SONAME of libfreetype.so, so there's no conflict.
# rm -r $PREFIX/lib/{*.a,*.la,pkgconfig}
rm -r $PREFIX/lib/{*.la,pkgconfig}

rm -r $PREFIX/share
# find "${PREFIX:?}/lib/" -name "*.a" -exec rm -rf {} \;
find "${PREFIX:?}/lib/" -name "*.la" -exec rm -rf {} \;
rm -r "${PREFIX:?}/lib/pkgconfig"
rm -r "${PREFIX:?}/share"
12 changes: 7 additions & 5 deletions recipes/libffi/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
#!/bin/sh
set -eu

mkdir -p $PREFIX
cp -r include $PREFIX
cp -r lib $PREFIX
: "${PREFIX?ENV VAR MUST BE SET}"

mkdir -p "$PREFIX"
cp -r include "$PREFIX"
cp -r lib "$PREFIX"

# Strip out any dylib files to ensure static linking
find $PREFIX -name "*.dylib" -exec rm -rf {} \;
find "$PREFIX" -name "*.dylib" -exec rm -rf {} \;
25 changes: 18 additions & 7 deletions recipes/libjpeg/build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
#!/bin/bash
#!/bin/sh
set -eu

: "${PREFIX?ENV VAR MUST BE SET}"

# SIMD is only available for x86, so disable for consistency between ABIs.
./configure --host=$HOST_TRIPLET --build=$BUILD_TRIPLET --without-turbojpeg --without-simd
make -j $CPU_COUNT
make install prefix=$PREFIX
./configure \
--host="$HOST_TRIPLET" \
--build="$BUILD_TRIPLET" \
--without-turbojpeg \
--without-simd
make -j "$CPU_COUNT"
make install prefix="$PREFIX"

rm -r "${PREFIX:?}/bin"
rm -r "$PREFIX/doc"
rm -r "$PREFIX/man"

mv "${PREFIX:?}/lib"?? "$PREFIX/lib" # lib32 or lib64

rm -r $PREFIX/{bin,doc,man}
mv $PREFIX/lib?? $PREFIX/lib # lib32 or lib64
rm -r $PREFIX/lib/{*.la,pkgconfig}
rm -r "${PREFIX:?}/lib/pkgconfig"
find "${PREFIX:?}/lib/" -name "*.la" -exec rm -rf {} \;
27 changes: 16 additions & 11 deletions recipes/libpng/build.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
#!/bin/bash
#!/bin/sh
set -eu

./configure --host=$HOST_TRIPLET --build=$BUILD_TRIPLET
make -j $CPU_COUNT
make install prefix=$PREFIX
: "${PREFIX?ENV VAR MUST BE SET}"

find $PREFIX -type l | xargs rm
./configure --host="$HOST_TRIPLET" --build="$BUILD_TRIPLET"
make -j "$CPU_COUNT"
make install prefix="$PREFIX"

rm -r $PREFIX/bin
find "$PREFIX" -type l -print0 | xargs -0 rm

mv $PREFIX/include/libpng16/* $PREFIX/include
rmdir $PREFIX/include/libpng16
# do not unintentionally delete /bin
rm -r "${PREFIX:?}/bin"

mv "$PREFIX/include/libpng16/"* "$PREFIX/include"
rmdir "$PREFIX/include/libpng16"

# Some versions of Android (e.g. API level 26) have a libpng.so in /system/lib, but our copy
# has an SONAME of libpng16.so, so there's no conflict.
# rm -r $PREFIX/lib/{*.a,*.la,pkgconfig}
# find "${PREFIX:?}/lib/" -name '*.a' -exec rm -r {} +
# find "${PREFIX:?}/lib/" -name '*.la' -exec rm -r {} +
# rm -r "$PREFIX/lib/pkgconfig"

# Downstream recipes expect the name libpng.a, not libpng16.a
mv $PREFIX/lib/libpng16.a $PREFIX/lib/libpng.a
mv "$PREFIX/lib/libpng16.a" "$PREFIX/lib/libpng.a"

rm -r $PREFIX/share
rm -r "$PREFIX/share"
5 changes: 3 additions & 2 deletions recipes/lru-dict/test_lru_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def test_basic():
data[1] = None
data[2] = None
data[3] = None
data[1]
_ = data[1]
data[4] = None
assert data.keys == [4, 1, 3]

assert data.keys() == [4, 1, 3]
2 changes: 1 addition & 1 deletion recipes/matplotlib/test_matplotlib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def test_png(self):
def test_png():
import io

import matplotlib.pyplot as plt
Expand Down
10 changes: 6 additions & 4 deletions recipes/ninja/build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/bash
#!/bin/sh
set -eu

mkdir -p $PREFIX
: "${PREFIX?ENV VAR MUST BE SET}"

mkdir -p "$PREFIX"
cp -r ninja wheel

# Ensure the binary is executable
chmod +x wheel/ninja/data/bin/ninja

# Write the metadata for the entry point script
mkdir -p wheel/ninja-$VERSION.dist-info
cat << EOF > wheel/ninja-$VERSION.dist-info/entry_points.txt
mkdir -p "wheel/ninja-$VERSION.dist-info"
cat << EOF > "wheel/ninja-$VERSION.dist-info/entry_points.txt"
[console_scripts]
ninja = ninja:ninja
EOF
12 changes: 7 additions & 5 deletions recipes/openssl/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
#!/bin/sh
set -eu

mkdir -p $PREFIX
cp -r include $PREFIX
cp -r lib $PREFIX
: "${PREFIX?ENV VAR MUST BE SET}"

mkdir -p "$PREFIX"
cp -r include "$PREFIX"
cp -r lib "$PREFIX"

# Strip out any dylib files to ensure static linking
find $PREFIX -name "*.dylib" -exec rm -rf {} \;
find "$PREFIX" -name "*.dylib" -exec rm -rf {} \;
6 changes: 3 additions & 3 deletions recipes/pillow/test/test_pillow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_basic():
img.save(out_file, "png")
out_bytes = out_file.getvalue()

EXPECTED_LEN = 313772
EXPECTED_LEN = 619474
assert len(out_bytes) > int(EXPECTED_LEN * 0.8)
assert len(out_bytes) < int(EXPECTED_LEN * 1.2)

Expand All @@ -29,5 +29,5 @@ def test_font():
from PIL import ImageFont

font = ImageFont.truetype(join(dirname(__file__), "Vera.ttf"), size=20)
font.getsize("Hello") == (51, 19)
font.getsize("Hello world") == (112, 19)
assert font.getbbox("Hello") == (0, 4, 51, 19)
assert font.getbbox("Hello world") == (0, 4, 112, 19)
12 changes: 7 additions & 5 deletions recipes/xz/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
#!/bin/sh
set -eu

mkdir -p $PREFIX
cp -r include $PREFIX
cp -r lib $PREFIX
: "${PREFIX?ENV VAR MUST BE SET}"

mkdir -p "$PREFIX"
cp -r include "$PREFIX"
cp -r lib "$PREFIX"

# Strip out any dylib files to ensure static linking
find $PREFIX -name "*.dylib" -exec rm -rf {} \;
find "$PREFIX" -name "*.dylib" -exec rm -rf {} \;
Loading

0 comments on commit 1ba0330

Please sign in to comment.