diff options
author | Claudia | 2024-03-11 11:13:19 +0100 |
---|---|---|
committer | Claudia | 2024-03-11 11:24:38 +0100 |
commit | 7f8176f8ee0641a441218d92a8f9704ad6fbdf4c (patch) | |
tree | 5cfbe83b3c0cbbe1998b2f84e9e4f305d17fb7c2 | |
download | aur-7f8176f8ee0641a441218d92a8f9704ad6fbdf4c.tar.gz |
shrinko8 v1.1.2
-rw-r--r-- | .SRCINFO | 24 | ||||
-rw-r--r-- | .editorconfig | 29 | ||||
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | PKGBUILD | 105 | ||||
-rw-r--r-- | pyproject.toml.template | 13 | ||||
-rw-r--r-- | shrinko8.py.template | 12 | ||||
-rw-r--r-- | test_cart.p8 | 10 |
7 files changed, 199 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..9ec52dbfc080 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,24 @@ +pkgbase = shrinko8 + pkgdesc = Shrink (minify) Pico-8 carts, as well as other tools (e.g. linting, format conversion) + pkgver = 1.1.2 + pkgrel = 1 + url = https://github.com/thisismypassport/shrinko8 + arch = any + license = MIT + makedepends = python-build + makedepends = python-installer + makedepends = python-j2cli + makedepends = python-setuptools + makedepends = python-wheel + depends = python-pillow + options = !strip + source = shrinko8-1.1.2.tar.gz::https://github.com/thisismypassport/shrinko8/archive/v1.1.2.tar.gz + source = pyproject.toml.template + source = shrinko8.py.template + source = test_cart.p8 + sha512sums = 79dfea0a1322a81073cfbd51785f78eafcb62b070154eb8b4878a1482b80257317ae47e39f6b51c4a14f046588bd59307278dfdc1a93983e671e598e0594baa5 + sha512sums = f10fb1b15dfe370ae85eb8d80065929591d06f3626e5ff69930b491bc3c781cb4b8485af130bbb892b70fb54f0eee70e3aadce28cdc1a40993c7620ad449fc9e + sha512sums = e0b80e28bd6253a31647038d20acb362a826592b8ef68596d837e16cad0c11e22c12e5bcd14b94055010bda70423c9e5339a0f80ee4ff774955e10cf3802ceec + sha512sums = b51c0ed94ffec9f0aa93d09bd6e4fcb155c69dd5dcfc5e155156227e5574f872bd61d541bfe6b98150c78bd8d4142f964c9bbd3c304c8daf58c9f8f21b59f2e6 + +pkgname = shrinko8 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000000..c6887bcdf994 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,29 @@ +# https://editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{diff,patch}] +end_of_line = lf +trim_trailing_whitespace = false + +[PKGBUILD] +indent_size = 2 + +[*.json] +indent_size = 2 + +[*.p8] +indent_size = 4 + +[*.py.template] +indent_size = 4 + +[*.toml.template] +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..9a3601c418fe --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.vscode/ +/src +/pkg +*.log +*.pkg.* +*.tar.* diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..7876a4e06480 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,105 @@ +# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de> + +pkgname=shrinko8 +pkgver=1.1.2 +pkgrel=1 +pkgdesc='Shrink (minify) Pico-8 carts, as well as other tools (e.g. linting, format conversion)' +arch=('any') +url='https://github.com/thisismypassport/shrinko8' +license=('MIT') +depends=('python-pillow') +makedepends=( + 'python-build' + 'python-installer' + 'python-j2cli' + 'python-setuptools' + 'python-wheel' +) +options=('!strip') + +source=( + "${pkgname}-${pkgver}.tar.gz::https://github.com/thisismypassport/shrinko8/archive/v${pkgver}.tar.gz" + 'pyproject.toml.template' + 'shrinko8.py.template' + 'test_cart.p8' +) + +sha512sums=( + '79dfea0a1322a81073cfbd51785f78eafcb62b070154eb8b4878a1482b80257317ae47e39f6b51c4a14f046588bd59307278dfdc1a93983e671e598e0594baa5' + 'f10fb1b15dfe370ae85eb8d80065929591d06f3626e5ff69930b491bc3c781cb4b8485af130bbb892b70fb54f0eee70e3aadce28cdc1a40993c7620ad449fc9e' + 'e0b80e28bd6253a31647038d20acb362a826592b8ef68596d837e16cad0c11e22c12e5bcd14b94055010bda70423c9e5339a0f80ee4ff774955e10cf3802ceec' + 'b51c0ed94ffec9f0aa93d09bd6e4fcb155c69dd5dcfc5e155156227e5574f872bd61d541bfe6b98150c78bd8d4142f964c9bbd3c304c8daf58c9f8f21b59f2e6' +) + +prepare() { + cd "${srcdir}/${pkgname}-${pkgver}" + + # pyinstaller bundles dependencies and the Python runtime, so we + # use setuptools instead + echo >&2 'Preparing setuptools' + j2 -f env -o 'pyproject.toml' '../pyproject.toml.template' - <<< \ + "pkgver=${pkgver}" + + echo >&2 'Preparing Python packages' + mkdir -pv shrinko8 tests + xargs < 'files.lst' bash -c 'mv -v $@ shrinko8/' _ + mv -v run_tests.py test_utils.py test_input test_compare \ + tests/ +} + +_site_packages() { + python -c 'import site; print(site.getsitepackages()[0])' +} + +build() { + cd "${srcdir}/${pkgname}-${pkgver}" + + echo >&2 'Building the wheel' + python -m build --wheel --no-isolation + + echo >&2 'Building the executable' + mkdir -pv bin + j2 -f env -o bin/shrinko8 '../shrinko8.py.template' - <<< \ + "site_packages=$(_site_packages)" +} + +check() { + cd "$(mktemp -d)" + echo >&2 'Installing wheel into a temporary directory' + python -m installer --destdir=. \ + "${srcdir}/${pkgname}-${pkgver}/dist"/*.whl + + PYTHONPATH="${PWD}/$(_site_packages)/${pkgname}" + export PYTHONPATH + + echo >&2 'Running minification test' + python "${srcdir}/${pkgname}-${pkgver}/bin/shrinko8" \ + -m "${srcdir}/test_cart.p8" test_cart_minified.p8 + if [[ "$(wc -c < 'test_cart_minified.p8')" -gt 116 ]]; then + printf >&2 '%s\n' 'Unexpected minification output:' '===' + cat >&2 'test_cart_minified.p8' + printf >&2 '\n%s\n' '===' + exit 1 + fi + + echo >&2 'Running PNG generation test' + python "${srcdir}/${pkgname}-${pkgver}/bin/shrinko8" \ + -m "${srcdir}/test_cart.p8" test_cart.p8.png +} + +package() { + cd "${srcdir}/${pkgname}-${pkgver}" + echo >&2 'Packaging the wheel' + python -I -m installer --destdir="${pkgdir}" dist/*.whl + + echo >&2 'Packaging the executable' + install -D -m 755 -t "${pkgdir}/usr/bin" "bin/${pkgname}" + + echo >&2 'Packaging the README' + install -D -m 644 -t "${pkgdir}/usr/share/doc/${pkgname}" \ + 'README.md' + + echo >&2 'Packaging the license' + install -D -m 644 -t "${pkgdir}/usr/share/licenses/${pkgname}" \ + 'LICENSE' +} diff --git a/pyproject.toml.template b/pyproject.toml.template new file mode 100644 index 000000000000..f2af359068ae --- /dev/null +++ b/pyproject.toml.template @@ -0,0 +1,13 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools"] + +[project] +name = "shrinko8" +version = "{{ pkgver }}" + +[tool.setuptools] +packages = ["shrinko8"] + +[tool.setuptools.package-data] +shrinko8 = ["font.png", "template.png"] diff --git a/shrinko8.py.template b/shrinko8.py.template new file mode 100644 index 000000000000..f152676f62e1 --- /dev/null +++ b/shrinko8.py.template @@ -0,0 +1,12 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys + +# Accommodate absolute imports in upstream code +sys.path.insert(0, "{{ site_packages }}/shrinko8") + +from shrinko8 import main +if __name__ == "__main__": + sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0]) + sys.exit(main(sys.argv[1:])) diff --git a/test_cart.p8 b/test_cart.p8 new file mode 100644 index 000000000000..263413bb0bf2 --- /dev/null +++ b/test_cart.p8 @@ -0,0 +1,10 @@ +pico-8 cartridge // http://www.pico-8.com +version 29 +__lua__ + +color_light_gray = 6 + +function _draw() + cls() + print("hello, world!", 0, 0, color_light_gray) +end |