diff --git a/README.md b/README.md index b6c45ca1..cc969724 100644 --- a/README.md +++ b/README.md @@ -2674,6 +2674,7 @@ set any of the following environment variables to disable its associated optiona | `PRTY_NO_CFSSL` | never attempt to generate self-signed certificates using [cfssl](https://github.com/cloudflare/cfssl) | | `PRTY_NO_FFMPEG` | **audio transcoding** goes byebye, **thumbnailing** must be handled by Pillow/libvips | | `PRTY_NO_FFPROBE` | **audio transcoding** goes byebye, **thumbnailing** must be handled by Pillow/libvips, **metadata-scanning** must be handled by mutagen | +| `PRTY_NO_IMPRESO` | do not try to load js/css files using `importlib.resources` | | `PRTY_NO_MUTAGEN` | do not use [mutagen](https://pypi.org/project/mutagen/) for reading metadata from media files; will fallback to ffprobe | | `PRTY_NO_PIL` | disable all [Pillow](https://pypi.org/project/pillow/)-based thumbnail support; will fallback to libvips or ffmpeg | | `PRTY_NO_PILF` | disable Pillow `ImageFont` text rendering, used for folder thumbnails | diff --git a/copyparty/util.py b/copyparty/util.py index 6a6352de..5cd16b5f 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -3941,7 +3941,7 @@ def hidedir(dp) -> None: try: - if sys.version_info < (3, 10): + if sys.version_info < (3, 10) or os.environ.get("PRTY_NO_IMPRESO"): # py3.8 doesn't have .files # py3.9 has broken .is_file raise ImportError() diff --git a/scripts/docker/innvikler.sh b/scripts/docker/innvikler.sh index a2521dc2..01c7dc0a 100644 --- a/scripts/docker/innvikler.sh +++ b/scripts/docker/innvikler.sh @@ -32,6 +32,9 @@ rm -rf \ /tmp/pe-* /z/copyparty-sfx.py \ ensurepip pydoc_data turtle.py turtledemo lib2to3 +# speedhack +sed -ri 's/os.environ.get\("PRTY_NO_IMPRESO"\)/"1"/' /usr/lib/python3.*/site-packages/copyparty/util.py + # drop bytecode find / -xdev -name __pycache__ -print0 | xargs -0 rm -rf diff --git a/scripts/make-sfx.sh b/scripts/make-sfx.sh index cc14fb4f..fc9cf90f 100755 --- a/scripts/make-sfx.sh +++ b/scripts/make-sfx.sh @@ -237,6 +237,8 @@ necho() { tar -zxf $f mv partftpy-*/partftpy . rm -rf partftpy-* partftpy/bin + #(cd partftpy && "$pybin" ../../scripts/strip_hints/a.py; rm uh) # dont need the full thing, just this: + sed -ri 's/from typing import TYPE_CHECKING$/TYPE_CHECKING = False/' partftpy/TftpShared.py necho collecting python-magic v=0.4.27 diff --git a/scripts/sfx.py b/scripts/sfx.py index a1b6477f..f1a4682f 100644 --- a/scripts/sfx.py +++ b/scripts/sfx.py @@ -413,6 +413,9 @@ def run_i(ld): for x in ld: sys.path.insert(0, x) + e = os.environ + e["PRTY_NO_IMPRESO"] = "1" + from copyparty.__main__ import main as p p() diff --git a/scripts/strip_hints/a.py b/scripts/strip_hints/a.py index 59aa76ec..7c74e53d 100644 --- a/scripts/strip_hints/a.py +++ b/scripts/strip_hints/a.py @@ -84,6 +84,9 @@ def uh2(fp): if " # !rm" in ln: continue + if ln.endswith("TYPE_CHECKING"): + ln = ln.replace("from typing import TYPE_CHECKING", "TYPE_CHECKING = False") + lns.append(ln) cs = "\n".join(lns)