diff --git a/bin/README.md b/bin/README.md index 1fef13f4..b6a033b8 100644 --- a/bin/README.md +++ b/bin/README.md @@ -26,12 +26,12 @@ and consider using [../docs/rclone.md](../docs/rclone.md) instead; usually a bit ## to run this on windows: * install [winfsp](https://github.com/billziss-gh/winfsp/releases/latest) and [python 3](https://www.python.org/downloads/) * [x] add python 3.x to PATH (it asks during install) -* `python -m pip install --user fusepy` (or grab a copy of `fuse.py` from the `connect` page on your copyparty, and keep it in the same folder) +* `python -m pip install --user mfusepy` (or grab a copy of `mfusepy.py` from the `connect` page on your copyparty, and keep it in the same folder) * `python ./partyfuse.py n: http://192.168.1.69:3923/` 10% faster in [msys2](https://www.msys2.org/), 700% faster if debug prints are enabled: * `pacman -S mingw64/mingw-w64-x86_64-python{,-pip}` -* `/mingw64/bin/python3 -m pip install --user fusepy` +* `/mingw64/bin/python3 -m pip install --user mfusepy` * `/mingw64/bin/python3 ./partyfuse.py [...]` you could replace winfsp with [dokan](https://github.com/dokan-dev/dokany/releases/latest), let me know if you [figure out how](https://github.com/dokan-dev/dokany/wiki/FUSE) diff --git a/bin/partyfuse.py b/bin/partyfuse.py index 7be355e1..4b6ab90e 100755 --- a/bin/partyfuse.py +++ b/bin/partyfuse.py @@ -21,7 +21,7 @@ usage: python partyfuse.py http://192.168.1.69:3923/ ./music dependencies: - python3 -m pip install --user fusepy # or grab it from the connect page + python3 -m pip install --user mfusepy # or grab it from the connect page + on Linux: sudo apk add fuse + on Macos: https://osxfuse.github.io/ + on Windows: https://github.com/billziss-gh/winfsp/releases/latest @@ -92,8 +92,13 @@ is_dbg = False try: - from fuse import FUSE, FuseOSError, Operations + from mfusepy import FUSE, FuseOSError, Operations except: + try: + from fuse import FUSE, FuseOSError, Operations + except: + FUSE = None + if WINDOWS: libfuse = "install https://github.com/billziss-gh/winfsp/releases/latest" elif MACOS: @@ -102,12 +107,13 @@ except: libfuse = "apt install libfuse2\n modprobe fuse" m = """\033[33m - could not import fuse; these may help: - {} -m pip install --user fusepy + could not import mfusepy; these may help: + {} -m pip install --user mfusepy {} \033[0m""" - print(m.format(sys.executable, libfuse)) - raise + if not FUSE: + print(m.format(sys.executable, libfuse)) + raise def termsafe(txt): @@ -143,10 +149,10 @@ def fancy_log(fmt, *a): def register_wtf8(): - def wtf8_enc(text): + def wtf8_enc(text, errors=""): return str(text).encode("utf-8", "surrogateescape"), len(text) - def wtf8_dec(binary): + def wtf8_dec(binary, errors=""): return bytes(binary).decode("utf-8", "surrogateescape"), len(binary) def wtf8_search(encoding_name): diff --git a/copyparty/__init__.py b/copyparty/__init__.py index 8bffed86..a698107c 100644 --- a/copyparty/__init__.py +++ b/copyparty/__init__.py @@ -77,7 +77,7 @@ web/deps/busy.mp3 web/deps/easymde.css web/deps/easymde.js web/deps/marked.js -web/deps/fuse.py +web/deps/mfusepy.py web/deps/mini-fa.css web/deps/mini-fa.woff web/deps/prism.css diff --git a/copyparty/web/svcs.html b/copyparty/web/svcs.html index bf1c1517..5daa5d22 100644 --- a/copyparty/web/svcs.html +++ b/copyparty/web/svcs.html @@ -233,7 +233,7 @@

partyfuse

partyfuse.py -- fast, read-only, - needs fuse.py in the same folder, + needs mfusepy.py in the same folder, needs winfsp doesn't need root

diff --git a/docs/devnotes.md b/docs/devnotes.md index afb86d9f..a1d90d8c 100644 --- a/docs/devnotes.md +++ b/docs/devnotes.md @@ -374,7 +374,7 @@ some third-party code has been vendored into the git repo; some for convenience, * `dnslib` (MIT) may be deleted and replaced with a systemwide install of the original [dnslib](https://github.com/paulc/dnslib/), HOWEVER: * will cause problems for mDNS in some network environments; 6c1cf68bca7376c6291c3cfe710ebd5bd5ed3e6c + 94d1924fa97e5faaf1ebfd85cae73faebcb89fa1 -* inside the folder `/copyparty/web/deps` (only in distributed archives/builds) is [fuse.py](https://github.com/fusepy/fusepy/blob/master/fuse.py), to make it downloadable from the connect-page on the web-ui +* inside the folder `/copyparty/web/deps` (only in distributed archives/builds) is [mfusepy.py](https://github.com/mxmlnkn/mfusepy/blob/master/mfusepy.py) (sizegolfed, no important changes), to make it downloadable from the connect-page on the web-ui * inside the folder `/copyparty/web` (only in distributed archives/builds) is a collection of javascript libraries (produced by [deps-docker](https://github.com/9001/copyparty/tree/hovudstraum/scripts/deps-docker)) which are used clientside by the web-UI: * [marked.js](https://github.com/markedjs/marked/releases) (MIT) powers the markdown editor, and has been [patched](https://github.com/9001/copyparty/blob/hovudstraum/scripts/deps-docker/marked-ln.patch) to include the line-numbers of each input line, to enable scroll-sync between the editor and the preview-pane. This patch is [not strictly necessary anymore](https://github.com/markedjs/marked/issues/2134) but I haven't gotten around to making the change yet diff --git a/docs/lics.txt b/docs/lics.txt index cf1edd2f..7380eada 100644 --- a/docs/lics.txt +++ b/docs/lics.txt @@ -36,7 +36,7 @@ https://github.com/ahupp/python-magic/ C: 2001-2014 Adam Hupp L: MIT -https://github.com/fusepy/fusepy +https://github.com/mxmlnkn/mfusepy C: 2012 Giorgos Verigakis L: ISC diff --git a/scripts/deps-docker/Dockerfile b/scripts/deps-docker/Dockerfile index 9f236e88..6f8663e8 100644 --- a/scripts/deps-docker/Dockerfile +++ b/scripts/deps-docker/Dockerfile @@ -24,8 +24,9 @@ RUN mkdir -p /z/dist/no-pk \ && wget https://fonts.gstatic.com/s/sourcecodepro/v11/HI_SiYsKILxRpg3hIP6sJ7fM7PqlPevW.woff2 -O scp.woff2 \ && apk add \ bash brotli cmake make g++ git gzip lame npm patch pigz \ - python3 python3-dev py3-brotli sox tar unzip wget \ + python3 python3-dev py3-pip py3-brotli sox tar unzip wget \ && rm -f /usr/lib/python3*/EXTERNALLY-MANAGED \ + && pip install strip_hints \ && wget https://github.com/markedjs/marked/archive/v$ver_marked.tar.gz -O marked.tgz \ && wget https://github.com/Ionaru/easy-markdown-editor/archive/$ver_mde.tar.gz -O mde.tgz \ && wget https://github.com/codemirror/codemirror5/archive/$ver_codemirror.tar.gz -O codemirror.tgz \ @@ -34,7 +35,7 @@ RUN mkdir -p /z/dist/no-pk \ && wget https://github.com/google/zopfli/archive/zopfli-$ver_zopfli.tar.gz -O zopfli.tgz \ && wget https://github.com/Daninet/hash-wasm/releases/download/v$ver_hashwasm/hash-wasm@$ver_hashwasm.zip -O hash-wasm.zip \ && wget https://github.com/PrismJS/prism/archive/refs/tags/v$ver_prism.tar.gz -O prism.tgz \ - && wget https://files.pythonhosted.org/packages/04/0b/4506cb2e831cea4b0214d3625430e921faaa05a7fb520458c75a2dbd2152/fusepy-3.0.1.tar.gz -O fusepy.tgz \ + && wget https://files.pythonhosted.org/packages/91/47/746287c8962274f73ee25edb3840d80899464bfffbe2c435424c2d60a071/mfusepy-3.1.1.tar.gz -O mfusepy.tgz \ && (mkdir hash-wasm \ && cd hash-wasm \ && unzip ../hash-wasm.zip) \ @@ -51,7 +52,7 @@ RUN mkdir -p /z/dist/no-pk \ && npm i gulp-cli -g ) \ && tar --no-same-owner -xf dompurify.tgz \ && tar --no-same-owner -xf prism.tgz \ - && tar --no-same-owner -xf fusepy.tgz \ + && tar --no-same-owner -xf mfusepy.tgz \ && unzip fontawesome.zip \ && tar --no-same-owner -xf zopfli.tgz @@ -148,16 +149,22 @@ RUN cd /z/dist \ && rmdir no-pk -# build fusepy -COPY uncomment.py /z -RUN mv /z/fusepy-3.0.1/fuse.py /z/dist/f1 \ +# build mfusepy -- just sizegolfing for the sfx, mfusepy.py works fine as-is +COPY uncomment.py unhint.py /z +RUN mv /z/mfusepy-3.1.1/mfusepy.py /z/dist/ \ && cd /z/dist \ + && python3 /z/unhint.py \ + && mv mfusepy.py f1 \ && python3 /z/uncomment.py f1 \ - && sed -ri '/self.__critical_exception = e/d' f1 \ - && awk '/^log =/{s=0} !s; /^from traceback im/{s=1;print"from functools import partial";print"basestring = str"}' f2 \ - && awk '/LoggingMixIn:/{exit} --s<0;/self.use_ns = getattr/{s=7}' f1 \ - && awk "/if _machine =/{s=0} /'(mips|ppc|ppc64)'/{s=1} !s" f2 \ - && rm f1 && mv f2 fuse.py + && sed -ri '/self.__critical_exception/d; /^from (typing|collections.abc) import/d' f1 \ + && sed -ri '/^(FieldsEntry|BitFieldsEntry|ReadDirResult) =/d' f1 \ + && awk "/if TYPE_CHECKING:/{s=1;sub(/TYPE_CHECKING/,"1");print}!s;/else:/{s=0}" f2 \ + && awk '/^def _nullable_dummy_function/{print"class Operations:\n pass";exit};1' f1 \ + && awk '/^# Note that/{s=3} --s<0; /self.use_ns = getattr/{s=16}' f2 \ + && awk "/if _machine =/{s=0} /_machine == '(mips|ppc|ppc64)'/{s=1} !s" f1 \ + && awk '/else:/{s=0} /elif _system == .NetBSD/{s=1} !s' f2 \ + && awk '/^if _system == .NetBSD_False/{s=1;print"if 0:\n pass"} /^elif/{s=0} !s' f1 \ + && rm f2 && mv f1 mfusepy.py # git diff -U2 --no-index marked-1.1.0-orig/ marked-1.1.0-edit/ -U2 | sed -r '/^index /d;s`^(diff --git a/)[^/]+/(.* b/)[^/]+/`\1\2`; s`^(---|\+\+\+) ([ab]/)[^/]+/`\1 \2`' > ../dev/copyparty/scripts/deps-docker/marked-ln.patch diff --git a/scripts/deps-docker/Makefile b/scripts/deps-docker/Makefile index dcd1f03f..63043a2e 100644 --- a/scripts/deps-docker/Makefile +++ b/scripts/deps-docker/Makefile @@ -5,6 +5,7 @@ vend := $(self)/../../copyparty/web/deps all: cp -pv ../uncomment.py . + cp -pv ../strip_hints/a.py unhint.py docker build -t build-copyparty-deps . diff --git a/scripts/docker/Makefile b/scripts/docker/Makefile index 26c7d8e3..e36e3d45 100644 --- a/scripts/docker/Makefile +++ b/scripts/docker/Makefile @@ -41,7 +41,7 @@ hclean: purge: -docker kill `docker ps -q` -docker rm `docker ps -qa` - -docker rmi `docker images -qa` + -docker rmi `docker images -qa` -f sh: @printf "\n\033[1;31mopening a shell in the most recently created docker image\033[0m\n" diff --git a/scripts/sfx.ls b/scripts/sfx.ls index 66ad6133..eb24b478 100644 --- a/scripts/sfx.ls +++ b/scripts/sfx.ls @@ -80,7 +80,7 @@ copyparty/web/deps/__init__.py, copyparty/web/deps/busy.mp3, copyparty/web/deps/easymde.css, copyparty/web/deps/easymde.js, -copyparty/web/deps/fuse.py, +copyparty/web/deps/mfusepy.py, copyparty/web/deps/marked.js, copyparty/web/deps/mini-fa.css, copyparty/web/deps/mini-fa.woff,