move venv to .venv

This commit is contained in:
Mateusz Gruszczyński
2026-06-15 08:14:04 +02:00
parent b710f6e6f9
commit aa87ced07b
8 changed files with 29 additions and 27 deletions
+4 -4
View File
@@ -83,7 +83,7 @@ Clone the repository and run the local development installer:
git clone https://github.com/zdzichu6969/pyTorrent.git git clone https://github.com/zdzichu6969/pyTorrent.git
cd pyTorrent cd pyTorrent
./install.sh ./install.sh
. venv/bin/activate . .venv/bin/activate
python app.py python app.py
``` ```
@@ -196,7 +196,7 @@ curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/script
Recommended production command: Recommended production command:
```bash ```bash
. venv/bin/activate . .venv/bin/activate
gunicorn --worker-class gthread \ gunicorn --worker-class gthread \
--workers 1 \ --workers 1 \
--threads 32 \ --threads 32 \
@@ -276,7 +276,7 @@ PYTORRENT_AUTH_PROVIDER=local
Reset a local user's password: Reset a local user's password:
```bash ```bash
. venv/bin/activate . .venv/bin/activate
python -m pytorrent.cli reset-password admin new_password python -m pytorrent.cli reset-password admin new_password
``` ```
@@ -470,7 +470,7 @@ PYTORRENT_DEBUG_INSTALL=1 bash scripts/install_stack.sh
## Development ## Development
```bash ```bash
. venv/bin/activate . .venv/bin/activate
python app.py python app.py
``` ```
+1 -1
View File
@@ -13,7 +13,7 @@ Group=pytorrent
WorkingDirectory=/opt/pyTorrent WorkingDirectory=/opt/pyTorrent
Environment="PYTHONUNBUFFERED=1" Environment="PYTHONUNBUFFERED=1"
EnvironmentFile=/opt/pyTorrent/.env EnvironmentFile=/opt/pyTorrent/.env
ExecStart=/opt/pyTorrent/venv/bin/gunicorn -c /opt/pyTorrent/gunicorn.conf.py --worker-class gthread --workers 1 --threads 32 --bind ${PYTORRENT_HOST}:${PYTORRENT_PORT} wsgi:app ExecStart=/opt/pyTorrent/.venv/bin/gunicorn -c /opt/pyTorrent/gunicorn.conf.py --worker-class gthread --workers 1 --threads 32 --bind ${PYTORRENT_HOST}:${PYTORRENT_PORT} wsgi:app
Restart=always Restart=always
RestartSec=3 RestartSec=3
KillSignal=SIGINT KillSignal=SIGINT
+3 -3
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
python3 -m venv venv python3 -m venv .venv
. venv/bin/activate . .venv/bin/activate
pip install --upgrade pip pip install --upgrade pip
pip install -r requirements.txt pip install -r requirements.txt
cp -n .env.example .env || true cp -n .env.example .env || true
@@ -11,4 +11,4 @@ mkdir -p data
chmod 755 data chmod 755 data
./scripts/download_geoip.sh data/GeoLite2-City.mmdb ./scripts/download_geoip.sh data/GeoLite2-City.mmdb
python -c "from pytorrent.db import init_db; init_db(); print(\"SQLite initialized\")" python -c "from pytorrent.db import init_db; init_db(); print(\"SQLite initialized\")"
echo "Run: . venv/bin/activate && python app.py" echo "Run: . .venv/bin/activate && python app.py"
+1 -1
View File
@@ -131,7 +131,7 @@ curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/script
The API configurator can be run manually: The API configurator can be run manually:
```bash ```bash
/opt/pytorrent/venv/bin/python /opt/pytorrent/scripts/stack_installers/configure_pytorrent_api.py \ /opt/pytorrent/.venv/bin/python /opt/pytorrent/scripts/stack_installers/configure_pytorrent_api.py \
--base-url http://127.0.0.1:8090 \ --base-url http://127.0.0.1:8090 \
--profile-name "Local rTorrent" \ --profile-name "Local rTorrent" \
--scgi-url scgi://127.0.0.1:5000 --scgi-url scgi://127.0.0.1:5000
+6 -5
View File
@@ -46,6 +46,7 @@ mkdir -p "${APP_DIR}"
rsync -a --delete \ rsync -a --delete \
--exclude '.git' \ --exclude '.git' \
--exclude '.venv' \
--exclude 'venv' \ --exclude 'venv' \
--exclude '__pycache__' \ --exclude '__pycache__' \
--exclude '*.pyc' \ --exclude '*.pyc' \
@@ -53,10 +54,10 @@ rsync -a --delete \
cd "${APP_DIR}" cd "${APP_DIR}"
"${PYTHON_BIN}" -m venv venv "${PYTHON_BIN}" -m venv .venv
venv/bin/pip install --upgrade pip wheel .venv/bin/pip install --upgrade pip wheel
venv/bin/pip install -r requirements.txt .venv/bin/pip install -r requirements.txt
mkdir -p data instance logs mkdir -p data instance logs
@@ -91,7 +92,7 @@ chown "${APP_USER}:${APP_USER}" .env
if [[ -f scripts/download_frontend_libs.py ]]; then if [[ -f scripts/download_frontend_libs.py ]]; then
sudo -u "${APP_USER}" \ sudo -u "${APP_USER}" \
"${APP_DIR}/venv/bin/python" \ "${APP_DIR}/.venv/bin/python" \
scripts/download_frontend_libs.py || true scripts/download_frontend_libs.py || true
fi fi
@@ -113,7 +114,7 @@ Group=${APP_USER}
WorkingDirectory=${APP_DIR} WorkingDirectory=${APP_DIR}
Environment="PYTHONUNBUFFERED=1" Environment="PYTHONUNBUFFERED=1"
EnvironmentFile=${APP_DIR}/.env EnvironmentFile=${APP_DIR}/.env
ExecStart=${APP_DIR}/venv/bin/gunicorn -c ${APP_DIR}/gunicorn.conf.py --worker-class gthread --workers 1 --threads 32 --bind \${PYTORRENT_HOST}:\${PYTORRENT_PORT} --access-logfile - --error-logfile - wsgi:app ExecStart=${APP_DIR}/.venv/bin/gunicorn -c ${APP_DIR}/gunicorn.conf.py --worker-class gthread --workers 1 --threads 32 --bind \${PYTORRENT_HOST}:\${PYTORRENT_PORT} --access-logfile - --error-logfile - wsgi:app
Restart=always Restart=always
RestartSec=3 RestartSec=3
KillSignal=SIGINT KillSignal=SIGINT
+7 -7
View File
@@ -299,16 +299,16 @@ copy_application() {
local project_dir local project_dir
project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
mkdir -p "${APP_DIR}" mkdir -p "${APP_DIR}"
rsync -a --delete --exclude '.git' --exclude 'venv' --exclude '__pycache__' --exclude '*.pyc' "${project_dir}/" "${APP_DIR}/" rsync -a --delete --exclude '.git' --exclude 'venv' --exclude '.venv' --exclude '__pycache__' --exclude '*.pyc' "${project_dir}/" "${APP_DIR}/"
chown -R "${APP_USER}:${APP_USER}" "${APP_DIR}" "/var/lib/${APP_USER}" || true chown -R "${APP_USER}:${APP_USER}" "${APP_DIR}" "/var/lib/${APP_USER}" || true
} }
install_python_app() { install_python_app() {
# Note: A private virtualenv keeps pyTorrent dependencies isolated from system Python packages. # Note: A private virtualenv keeps pyTorrent dependencies isolated from system Python packages.
cd "${APP_DIR}" cd "${APP_DIR}"
"${PYTHON_BIN}" -m venv venv "${PYTHON_BIN}" -m venv .venv
venv/bin/pip install --upgrade pip wheel .venv/bin/pip install --upgrade pip wheel
venv/bin/pip install -r requirements.txt .venv/bin/pip install -r requirements.txt
mkdir -p data instance logs mkdir -p data instance logs
chown -R "${APP_USER}:${APP_USER}" "${APP_DIR}" chown -R "${APP_USER}:${APP_USER}" "${APP_DIR}"
} }
@@ -426,7 +426,7 @@ write_env() {
install_frontend_libs() { install_frontend_libs() {
# Note: Offline mode downloads local JS/CSS assets during installation; online mode uses CDN links. # Note: Offline mode downloads local JS/CSS assets during installation; online mode uses CDN links.
if [[ "${LIBS_MODE}" == "offline" && -f "${APP_DIR}/scripts/download_frontend_libs.py" ]]; then if [[ "${LIBS_MODE}" == "offline" && -f "${APP_DIR}/scripts/download_frontend_libs.py" ]]; then
sudo -u "${APP_USER}" "${APP_DIR}/venv/bin/python" "${APP_DIR}/scripts/download_frontend_libs.py" || true sudo -u "${APP_USER}" "${APP_DIR}/.venv/bin/python" "${APP_DIR}/scripts/download_frontend_libs.py" || true
fi fi
if [[ -f "${APP_DIR}/scripts/download_geoip.sh" ]]; then if [[ -f "${APP_DIR}/scripts/download_geoip.sh" ]]; then
sudo -u "${APP_USER}" bash "${APP_DIR}/scripts/download_geoip.sh" "${APP_DIR}/data/GeoLite2-City.mmdb" || true sudo -u "${APP_USER}" bash "${APP_DIR}/scripts/download_geoip.sh" "${APP_DIR}/data/GeoLite2-City.mmdb" || true
@@ -444,7 +444,7 @@ configure_database() {
PROFILE_NAME="${PROFILE_NAME}" \ PROFILE_NAME="${PROFILE_NAME}" \
SCGI_URL="${SCGI_URL}" \ SCGI_URL="${SCGI_URL}" \
SKIP_PROFILE="${SKIP_PROFILE}" \ SKIP_PROFILE="${SKIP_PROFILE}" \
"${APP_DIR}/venv/bin/python" - <<'PY' "${APP_DIR}/.venv/bin/python" - <<'PY'
import os import os
from pytorrent.db import connect, init_db, utcnow from pytorrent.db import connect, init_db, utcnow
from pytorrent.services.auth import password_hash from pytorrent.services.auth import password_hash
@@ -518,7 +518,7 @@ Group=${APP_USER}
WorkingDirectory=${APP_DIR} WorkingDirectory=${APP_DIR}
Environment="PYTHONUNBUFFERED=1" Environment="PYTHONUNBUFFERED=1"
EnvironmentFile=${APP_DIR}/.env EnvironmentFile=${APP_DIR}/.env
ExecStart=${APP_DIR}/venv/bin/gunicorn -c ${APP_DIR}/gunicorn.conf.py --worker-class gthread --workers 1 --threads 32 --bind \${PYTORRENT_HOST}:\${PYTORRENT_PORT} wsgi:app ExecStart=${APP_DIR}/.venv/bin/gunicorn -c ${APP_DIR}/gunicorn.conf.py --worker-class gthread --workers 1 --threads 32 --bind \${PYTORRENT_HOST}:\${PYTORRENT_PORT} wsgi:app
Restart=always Restart=always
RestartSec=3 RestartSec=3
KillSignal=SIGINT KillSignal=SIGINT
@@ -44,15 +44,16 @@ mkdir -p "${APP_DIR}"
rsync -a --delete \ rsync -a --delete \
--exclude '.git' \ --exclude '.git' \
--exclude 'venv' \ --exclude 'venv' \
--exclude '.venv' \
--exclude '__pycache__' \ --exclude '__pycache__' \
--exclude '*.pyc' \ --exclude '*.pyc' \
./ "${APP_DIR}/" ./ "${APP_DIR}/"
cd "${APP_DIR}" cd "${APP_DIR}"
"${PYTHON_BIN}" -m venv venv "${PYTHON_BIN}" -m venv .venv
venv/bin/pip install --upgrade pip wheel .venv/bin/pip install --upgrade pip wheel
venv/bin/pip install -r requirements.txt .venv/bin/pip install -r requirements.txt
mkdir -p data instance logs data/logs mkdir -p data instance logs data/logs
chown -R "${APP_USER}:${APP_USER}" "${APP_DIR}" "/var/lib/${APP_USER}" chown -R "${APP_USER}:${APP_USER}" "${APP_DIR}" "/var/lib/${APP_USER}"
@@ -95,7 +96,7 @@ chown -R "${APP_USER}:${APP_USER}" "${PYTORRENT_LOG_DIR_VALUE}" || true
chown "${APP_USER}:${APP_USER}" .env chown "${APP_USER}:${APP_USER}" .env
if [[ -f scripts/download_frontend_libs.py ]]; then if [[ -f scripts/download_frontend_libs.py ]]; then
sudo -u "${APP_USER}" "${APP_DIR}/venv/bin/python" scripts/download_frontend_libs.py || true sudo -u "${APP_USER}" "${APP_DIR}/.venv/bin/python" scripts/download_frontend_libs.py || true
fi fi
if [[ -f scripts/download_geoip.sh ]]; then if [[ -f scripts/download_geoip.sh ]]; then
@@ -115,7 +116,7 @@ Group=${APP_USER}
WorkingDirectory=${APP_DIR} WorkingDirectory=${APP_DIR}
Environment="PYTHONUNBUFFERED=1" Environment="PYTHONUNBUFFERED=1"
EnvironmentFile=${APP_DIR}/.env EnvironmentFile=${APP_DIR}/.env
ExecStart=${APP_DIR}/venv/bin/gunicorn -c ${APP_DIR}/gunicorn.conf.py --worker-class gthread --workers 1 --threads 32 --bind \${PYTORRENT_HOST}:\${PYTORRENT_PORT} --access-logfile - --error-logfile - wsgi:app ExecStart=${APP_DIR}/.venv/bin/gunicorn -c ${APP_DIR}/gunicorn.conf.py --worker-class gthread --workers 1 --threads 32 --bind \${PYTORRENT_HOST}:\${PYTORRENT_PORT} --access-logfile - --error-logfile - wsgi:app
Restart=always Restart=always
RestartSec=3 RestartSec=3
KillSignal=SIGINT KillSignal=SIGINT
@@ -233,7 +233,7 @@ fi
bash "${PROJECT_DIR}/scripts/install_pytorrent_only.sh" "${PYTORRENT_ONLY_ARGS[@]}" bash "${PROJECT_DIR}/scripts/install_pytorrent_only.sh" "${PYTORRENT_ONLY_ARGS[@]}"
if [[ -n "${PYTORRENT_API_TOKEN}" ]]; then if [[ -n "${PYTORRENT_API_TOKEN}" ]]; then
"${PYTORRENT_APP_DIR}/venv/bin/python" "${PYTORRENT_APP_DIR}/scripts/stack_installers/configure_pytorrent_api.py" \ "${PYTORRENT_APP_DIR}/.venv/bin/python" "${PYTORRENT_APP_DIR}/scripts/stack_installers/configure_pytorrent_api.py" \
--base-url "${PYTORRENT_BASE_URL}" \ --base-url "${PYTORRENT_BASE_URL}" \
--profile-name "${PYTORRENT_PROFILE_NAME}" \ --profile-name "${PYTORRENT_PROFILE_NAME}" \
--scgi-url "${PYTORRENT_RTORRENT_SCGI_URL}" \ --scgi-url "${PYTORRENT_RTORRENT_SCGI_URL}" \