mirror of
https://github.com/9001/copyparty.git
synced 2025-08-16 16:42:13 -06:00
catch common environment issues (#32):
* error-message which explains how to run on py2 / older py3 when trying to run from source * check compatibility between jinja2 and cpython on startup * verify that webdeps are present on startup * verify that webdeps are present when building sfx * make-sfx.sh grabs the strip-hints dependency
This commit is contained in:
parent
9c28ba417e
commit
c355f9bd91
|
@ -6,6 +6,8 @@ import platform
|
|||
import sys
|
||||
import time
|
||||
|
||||
_: int = 1 # --->--->---> hey there! if you are reading this, your python is too old to run copyparty without some help. Please use https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.py or the pypi package instead, or see https://github.com/9001/copyparty/blob/hovudstraum/docs/devnotes.md#building if you want to build it yourself :-)
|
||||
|
||||
try:
|
||||
from typing import TYPE_CHECKING
|
||||
except:
|
||||
|
|
|
@ -261,6 +261,24 @@ def ensure_locale() -> None:
|
|||
warn(t.format(safe))
|
||||
|
||||
|
||||
def ensure_webdeps() -> None:
|
||||
ap = os.path.join(E.mod, "web/deps/mini-fa.woff")
|
||||
if os.path.exists(ap):
|
||||
return
|
||||
|
||||
warn(
|
||||
"""could not find webdeps;
|
||||
if you are running the sfx, or exe, or pypi package, or docker image,
|
||||
then this is a bug! Please let me know so I can fix it, thanks :-)
|
||||
https://github.com/9001/copyparty/issues/new?labels=bug&template=bug_report.md
|
||||
|
||||
however, if you are a dev, or running copyparty from source, and you want
|
||||
full client functionality, you will need to build or obtain the webdeps:
|
||||
https://github.com/9001/copyparty/blob/hovudstraum/docs/devnotes.md#building
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def ensure_cert(al: argparse.Namespace) -> None:
|
||||
"""
|
||||
the default cert (and the entire TLS support) is only here to enable the
|
||||
|
@ -1116,6 +1134,8 @@ def main(argv: Optional[list[str]] = None) -> None:
|
|||
|
||||
ensure_locale()
|
||||
|
||||
ensure_webdeps()
|
||||
|
||||
for k, v in zip(argv[1:], argv[2:]):
|
||||
if k == "-c" and os.path.isfile(v):
|
||||
supp = args_from_cfg(v)
|
||||
|
|
|
@ -33,7 +33,23 @@ except MNFE:
|
|||
* (try another python version, if you have one)
|
||||
* (try copyparty.sfx instead)
|
||||
""".format(
|
||||
os.path.basename(sys.executable)
|
||||
sys.executable
|
||||
)
|
||||
)
|
||||
sys.exit(1)
|
||||
except SyntaxError:
|
||||
if EXE:
|
||||
raise
|
||||
|
||||
print(
|
||||
"""\033[1;31m
|
||||
your jinja2 version is incompatible with your python version;\033[33m
|
||||
please try to replace it with an older version:\033[0m
|
||||
* {} -m pip install --user jinja2==2.11.3
|
||||
* (try another python version, if you have one)
|
||||
* (try copyparty.sfx instead)
|
||||
""".format(
|
||||
sys.executable
|
||||
)
|
||||
)
|
||||
sys.exit(1)
|
||||
|
|
|
@ -236,6 +236,8 @@ pip install black==21.12b0 click==8.0.2 bandit pylint flake8 isort mypy # vscod
|
|||
|
||||
## just the sfx
|
||||
|
||||
if you just want to modify the copyparty source code (py/html/css/js) then this is the easiest approach
|
||||
|
||||
first grab the web-dependencies from a previous sfx (assuming you don't need to modify something in those):
|
||||
|
||||
```sh
|
||||
|
@ -246,7 +248,8 @@ rm x.py
|
|||
cp -R /tmp/pe-copyparty.$(id -u)/copyparty/web/deps copyparty/web/
|
||||
```
|
||||
|
||||
or you could build the web-dependencies from source instead (NB: does not include prismjs, need to grab that manually):
|
||||
or you could build the web-dependencies from source instead:
|
||||
|
||||
```sh
|
||||
make -C scripts/deps-docker
|
||||
```
|
||||
|
@ -285,6 +288,8 @@ python3 setup.py install --skip-build --prefix=/usr --root=$HOME/pe/copyparty
|
|||
|
||||
also builds the sfx so skip the sfx section above
|
||||
|
||||
*WARNING: `rls.sh` has not yet been updated with the docker-images and arch/nix packaging*
|
||||
|
||||
does everything completely from scratch, straight from your local repo
|
||||
|
||||
in the `scripts` folder:
|
||||
|
|
|
@ -109,6 +109,7 @@ while [ ! -z "$1" ]; do
|
|||
no-hl) no_hl=1 ; ;;
|
||||
no-dd) no_dd=1 ; ;;
|
||||
no-cm) no_cm=1 ; ;;
|
||||
ign-wd) ign_wd=1 ; ;;
|
||||
fast) zopf= ; ;;
|
||||
ultra) ultra=1 ; ;;
|
||||
lang) shift;langs="$1"; ;;
|
||||
|
@ -223,7 +224,7 @@ necho() {
|
|||
|
||||
# enable this to dynamically remove type hints at startup,
|
||||
# in case a future python version can use them for performance
|
||||
true || (
|
||||
true && (
|
||||
necho collecting strip-hints
|
||||
f=../build/strip-hints-0.1.10.tar.gz
|
||||
[ -e $f ] ||
|
||||
|
@ -283,12 +284,20 @@ necho() {
|
|||
rm -f copyparty/stolen/*/README.md
|
||||
|
||||
# remove type hints before build instead
|
||||
(cd copyparty; "$pybin" ../../scripts/strip_hints/a.py; rm uh)
|
||||
(cd copyparty; PYTHONPATH="..:$PYTHONPATH" "$pybin" ../../scripts/strip_hints/a.py; rm uh)
|
||||
|
||||
licfile=$(realpath copyparty/res/COPYING.txt)
|
||||
(cd ../scripts; ./genlic.sh "$licfile")
|
||||
}
|
||||
|
||||
[ -e copyparty/web/deps/mini-fa.woff ] || [ $ign_wd ] || { cat <<'EOF'
|
||||
|
||||
could not find webdeps; please see https://github.com/9001/copyparty/blob/hovudstraum/docs/devnotes.md#building
|
||||
or run with argument "ign-wd" if this was intentional
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
ver=
|
||||
[ -z "$repack" ] &&
|
||||
git describe --tags >/dev/null 2>/dev/null && {
|
||||
|
|
Loading…
Reference in a new issue