diff options
author | Claudia | 2024-03-15 01:10:57 +0100 |
---|---|---|
committer | Claudia | 2024-03-15 01:13:27 +0100 |
commit | 18f511311e0847f4e311f836ed318f121bb29faa (patch) | |
tree | 1e9a90d47cdf2c9d055533bdbf842b8bd268e1c7 | |
parent | 7f8176f8ee0641a441218d92a8f9704ad6fbdf4c (diff) | |
download | aur-18f511311e0847f4e311f836ed318f121bb29faa.tar.gz |
Allow module import without PYTHONPATH manipulation
-rw-r--r-- | .SRCINFO | 7 | ||||
-rw-r--r-- | PKGBUILD | 21 | ||||
-rw-r--r-- | __init__.py.template | 7 | ||||
-rw-r--r-- | shrinko8.py.template | 5 |
4 files changed, 27 insertions, 13 deletions
@@ -1,7 +1,7 @@ pkgbase = shrinko8 pkgdesc = Shrink (minify) Pico-8 carts, as well as other tools (e.g. linting, format conversion) pkgver = 1.1.2 - pkgrel = 1 + pkgrel = 2 url = https://github.com/thisismypassport/shrinko8 arch = any license = MIT @@ -11,14 +11,17 @@ pkgbase = shrinko8 makedepends = python-setuptools makedepends = python-wheel depends = python-pillow + depends = python-qualify options = !strip source = shrinko8-1.1.2.tar.gz::https://github.com/thisismypassport/shrinko8/archive/v1.1.2.tar.gz + source = __init__.py.template source = pyproject.toml.template source = shrinko8.py.template source = test_cart.p8 sha512sums = 79dfea0a1322a81073cfbd51785f78eafcb62b070154eb8b4878a1482b80257317ae47e39f6b51c4a14f046588bd59307278dfdc1a93983e671e598e0594baa5 + sha512sums = e484cb3881923665ff3bf7cb7522f897227896b81d8c8b094f7be8c49d79f1ed6d069bb82d878be36210df80ddf75cb009eb92ea03a2bc9cd3988f651e0bee57 sha512sums = f10fb1b15dfe370ae85eb8d80065929591d06f3626e5ff69930b491bc3c781cb4b8485af130bbb892b70fb54f0eee70e3aadce28cdc1a40993c7620ad449fc9e - sha512sums = e0b80e28bd6253a31647038d20acb362a826592b8ef68596d837e16cad0c11e22c12e5bcd14b94055010bda70423c9e5339a0f80ee4ff774955e10cf3802ceec + sha512sums = c00dc0e42044d30c5b99888ac4d6f1a563decfbc357b0f6057c6417b0c0c2d225a64ad3e5bd3f7017b97c92384cca8e48e240778654e0bb516d89776c1ca24a7 sha512sums = b51c0ed94ffec9f0aa93d09bd6e4fcb155c69dd5dcfc5e155156227e5574f872bd61d541bfe6b98150c78bd8d4142f964c9bbd3c304c8daf58c9f8f21b59f2e6 pkgname = shrinko8 @@ -2,12 +2,12 @@ pkgname=shrinko8 pkgver=1.1.2 -pkgrel=1 +pkgrel=2 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') +depends=('python-pillow' 'python-qualify') makedepends=( 'python-build' 'python-installer' @@ -19,6 +19,7 @@ options=('!strip') source=( "${pkgname}-${pkgver}.tar.gz::https://github.com/thisismypassport/shrinko8/archive/v${pkgver}.tar.gz" + '__init__.py.template' 'pyproject.toml.template' 'shrinko8.py.template' 'test_cart.p8' @@ -26,8 +27,9 @@ source=( sha512sums=( '79dfea0a1322a81073cfbd51785f78eafcb62b070154eb8b4878a1482b80257317ae47e39f6b51c4a14f046588bd59307278dfdc1a93983e671e598e0594baa5' + 'e484cb3881923665ff3bf7cb7522f897227896b81d8c8b094f7be8c49d79f1ed6d069bb82d878be36210df80ddf75cb009eb92ea03a2bc9cd3988f651e0bee57' 'f10fb1b15dfe370ae85eb8d80065929591d06f3626e5ff69930b491bc3c781cb4b8485af130bbb892b70fb54f0eee70e3aadce28cdc1a40993c7620ad449fc9e' - 'e0b80e28bd6253a31647038d20acb362a826592b8ef68596d837e16cad0c11e22c12e5bcd14b94055010bda70423c9e5339a0f80ee4ff774955e10cf3802ceec' + 'c00dc0e42044d30c5b99888ac4d6f1a563decfbc357b0f6057c6417b0c0c2d225a64ad3e5bd3f7017b97c92384cca8e48e240778654e0bb516d89776c1ca24a7' 'b51c0ed94ffec9f0aa93d09bd6e4fcb155c69dd5dcfc5e155156227e5574f872bd61d541bfe6b98150c78bd8d4142f964c9bbd3c304c8daf58c9f8f21b59f2e6' ) @@ -37,12 +39,17 @@ prepare() { # 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}" + j2 -f env -o 'pyproject.toml' '../pyproject.toml.template' - \ + <<< "pkgver=${pkgver}" + + echo >&2 'Preparing Python namespace compatibility fix' + mkdir -pv shrinko8 + j2 -f env -o 'shrinko8/__init__.py' '../__init__.py.template' - \ + <<< "pkgver=${pkgver}" echo >&2 'Preparing Python packages' - mkdir -pv shrinko8 tests xargs < 'files.lst' bash -c 'mv -v $@ shrinko8/' _ + mkdir -pv tests mv -v run_tests.py test_utils.py test_input test_compare \ tests/ } @@ -69,7 +76,7 @@ check() { python -m installer --destdir=. \ "${srcdir}/${pkgname}-${pkgver}/dist"/*.whl - PYTHONPATH="${PWD}/$(_site_packages)/${pkgname}" + PYTHONPATH="${PWD}/$(_site_packages)" export PYTHONPATH echo >&2 'Running minification test' diff --git a/__init__.py.template b/__init__.py.template new file mode 100644 index 000000000000..20045f71847b --- /dev/null +++ b/__init__.py.template @@ -0,0 +1,7 @@ +"""Allow shrinko8 to work without exposing its top-level module +names to the global module namespace.""" + +import python_qualify +python_qualify.enable_submodules(__name__) + +__version__ = '{{ pkgver }}' diff --git a/shrinko8.py.template b/shrinko8.py.template index f152676f62e1..0158e22bd030 100644 --- a/shrinko8.py.template +++ b/shrinko8.py.template @@ -3,10 +3,7 @@ import re import sys -# Accommodate absolute imports in upstream code -sys.path.insert(0, "{{ site_packages }}/shrinko8") - -from shrinko8 import main +from shrinko8.shrinko8 import main if __name__ == "__main__": sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0]) sys.exit(main(sys.argv[1:])) |