mirror of
https://github.com/9001/copyparty.git
synced 2025-08-16 08:32:13 -06:00
speedgolf
in some envs (unsure which), importlib.resources is an expensive import; drop it when we know it's useless
This commit is contained in:
parent
21db8833dc
commit
b2aaf40a3e
|
@ -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 |
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue