mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
Use rye
This commit is contained in:
parent
33c099022b
commit
6672d532fd
16 changed files with 526 additions and 408 deletions
64
manage
64
manage
|
|
@ -39,8 +39,6 @@ PATH="${REPO_ROOT}/node_modules/.bin:${PATH}"
|
|||
|
||||
# config
|
||||
|
||||
PYOBJECTS="searx"
|
||||
PY_SETUP_EXTRAS='[test]'
|
||||
GECKODRIVER_VERSION="v0.34.0"
|
||||
# SPHINXOPTS=
|
||||
BLACK_OPTIONS=("--target-version" "py311" "--line-length" "120" "--skip-string-normalization")
|
||||
|
|
@ -148,7 +146,7 @@ webapp.run() {
|
|||
sleep 3
|
||||
xdg-open http://127.0.0.1:8888/
|
||||
)&
|
||||
SEARXNG_DEBUG=1 pyenv.cmd python -m searx.webapp
|
||||
SEARXNG_DEBUG=1 rye run python -m searx.webapp
|
||||
}
|
||||
|
||||
docker.push() {
|
||||
|
|
@ -237,19 +235,17 @@ docker.build() {
|
|||
|
||||
# shellcheck disable=SC2119
|
||||
gecko.driver() {
|
||||
pyenv.install
|
||||
|
||||
build_msg INSTALL "gecko.driver"
|
||||
# run installation in a subprocess and activate pyenv
|
||||
( set -e
|
||||
pyenv.activate
|
||||
|
||||
INSTALLED_VERSION=$(geckodriver -V 2> /dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION=""
|
||||
INSTALLED_VERSION=$(${PY_ENV_BIN}/geckodriver -V 2> /dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION=""
|
||||
set +e
|
||||
if [ "${INSTALLED_VERSION}" = "${GECKODRIVER_VERSION}" ]; then
|
||||
build_msg INSTALL "geckodriver already installed"
|
||||
return
|
||||
fi
|
||||
rye sync
|
||||
|
||||
PLATFORM="$(python3 -c 'import platform; print(platform.system().lower(), platform.architecture()[0])')"
|
||||
case "$PLATFORM" in
|
||||
"linux 32bit" | "linux2 32bit") ARCH="linux32";;
|
||||
|
|
@ -272,7 +268,7 @@ gecko.driver() {
|
|||
|
||||
pygments.less() {
|
||||
build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
|
||||
if ! pyenv.cmd python searxng_extra/update/update_pygments.py; then
|
||||
if ! rye run python searxng_extra/update/update_pygments.py; then
|
||||
build_msg PYGMENTS "building LESS files for pygments failed"
|
||||
return 1
|
||||
fi
|
||||
|
|
@ -281,60 +277,14 @@ pygments.less() {
|
|||
|
||||
py.build() {
|
||||
build_msg BUILD "python package ${PYDIST}"
|
||||
pyenv.cmd python setup.py \
|
||||
rye run python setup.py \
|
||||
sdist -d "${PYDIST}" \
|
||||
bdist_wheel --bdist-dir "${PYBUILD}" -d "${PYDIST}"
|
||||
}
|
||||
|
||||
py.clean() {
|
||||
build_msg CLEAN pyenv
|
||||
( set -e
|
||||
pyenv.drop
|
||||
[ "$VERBOSE" = "1" ] && set -x
|
||||
rm -rf "${PYDIST}" "${PYBUILD}" "${PY_ENV}" ./.tox ./*.egg-info
|
||||
find . -name '*.pyc' -exec rm -f {} +
|
||||
find . -name '*.pyo' -exec rm -f {} +
|
||||
find . -name __pycache__ -exec rm -rf {} +
|
||||
)
|
||||
}
|
||||
|
||||
pyenv.check() {
|
||||
cat <<EOF
|
||||
import yaml
|
||||
print('import yaml --> OK')
|
||||
EOF
|
||||
}
|
||||
|
||||
pyenv.install() {
|
||||
|
||||
if ! pyenv.OK; then
|
||||
py.clean > /dev/null
|
||||
fi
|
||||
if pyenv.install.OK > /dev/null; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
( set -e
|
||||
pyenv
|
||||
build_msg PYENV "[install] pip install -e 'searx${PY_SETUP_EXTRAS}'"
|
||||
"${PY_ENV_BIN}/python" -m pip install -e ".${PY_SETUP_EXTRAS}"
|
||||
)
|
||||
local exit_val=$?
|
||||
if [ ! $exit_val -eq 0 ]; then
|
||||
die 42 "error while pip install (${PY_ENV_BIN})"
|
||||
fi
|
||||
}
|
||||
|
||||
pyenv.uninstall() {
|
||||
build_msg PYENV "[pyenv.uninstall] uninstall packages: ${PYOBJECTS}"
|
||||
pyenv.cmd python setup.py develop --uninstall 2>&1 \
|
||||
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
|
||||
}
|
||||
|
||||
format.python() {
|
||||
build_msg TEST "[format.python] black \$BLACK_TARGETS"
|
||||
pyenv.cmd black "${BLACK_OPTIONS[@]}" "${BLACK_TARGETS[@]}"
|
||||
rye run black "${BLACK_OPTIONS[@]}" "${BLACK_TARGETS[@]}"
|
||||
dump_return $?
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue