From b2401ff15a21a8ba389599f1d582ce41d36f9ceb Mon Sep 17 00:00:00 2001
From: ed
Date: Thu, 21 May 2026 23:31:57 +0000
Subject: [PATCH] partyfuse: prefer mfusepy (fuse.py fork);
now supports both fuse2 and fuse3
fallback on fuse.py (fuse2-only) if mfusepy unavailable
fuse3 is 20% faster on large files,
fuse2 == fuse3 on small files
motivated by nixos dropping fuse2 in NixOS/nixpkgs#522340
---
bin/README.md | 4 ++--
bin/partyfuse.py | 22 ++++++++++++++--------
copyparty/__init__.py | 2 +-
copyparty/web/svcs.html | 2 +-
docs/devnotes.md | 2 +-
docs/lics.txt | 2 +-
scripts/deps-docker/Dockerfile | 29 ++++++++++++++++++-----------
scripts/deps-docker/Makefile | 1 +
scripts/docker/Makefile | 2 +-
scripts/sfx.ls | 2 +-
10 files changed, 41 insertions(+), 27 deletions(-)
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"}'