Merge pull request #1036 from tcely/patch-2
Some checks failed
CI / info (push) Has been cancelled
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / test (3.13) (push) Has been cancelled
CI / containerise (push) Has been cancelled

Use Django 5.2
This commit is contained in:
meeb 2025-05-16 14:48:40 +10:00 committed by GitHub
commit 7287bc1dee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 28 deletions

View File

@ -84,7 +84,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] python-version: ['3.10', '3.11', '3.12', '3.13']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install Python ${{ matrix.python-version }} - name: Install Python ${{ matrix.python-version }}
@ -101,8 +101,9 @@ jobs:
cp -v -p tubesync/tubesync/local_settings.py.example tubesync/tubesync/local_settings.py cp -v -p tubesync/tubesync/local_settings.py.example tubesync/tubesync/local_settings.py
cp -v -a -t "${Python3_ROOT_DIR}"/lib/python3.*/site-packages/background_task/ patches/background_task/* cp -v -a -t "${Python3_ROOT_DIR}"/lib/python3.*/site-packages/background_task/ patches/background_task/*
cp -v -a -t "${Python3_ROOT_DIR}"/lib/python3.*/site-packages/yt_dlp/ patches/yt_dlp/* cp -v -a -t "${Python3_ROOT_DIR}"/lib/python3.*/site-packages/yt_dlp/ patches/yt_dlp/*
cd tubesync && python3 -B manage.py collectstatic --no-input --link
- name: Run Django tests - name: Run Django tests
run: cd tubesync && python3 manage.py test --verbosity=2 run: cd tubesync && python3 -B -W default manage.py test --verbosity=2
containerise: containerise:
if: ${{ !cancelled() && 'success' == needs.info.result }} if: ${{ !cancelled() && 'success' == needs.info.result }}

View File

@ -7,7 +7,7 @@ verify_ssl = true
autopep8 = "*" autopep8 = "*"
[packages] [packages]
django = "<5.2" django = "*"
django-sass-processor = {extras = ["management-command"], version = "*"} django-sass-processor = {extras = ["management-command"], version = "*"}
pillow = "*" pillow = "*"
whitenoise = "*" whitenoise = "*"

View File

@ -146,7 +146,7 @@ services:
## Optional authentication ## Optional authentication
Available in `v1.0` (or `:latest`)and later. If you want to enable a basic username and Available in `v1.0` (or `:latest`) and later. If you want to enable a basic username and
password to be required to access the TubeSync dashboard you can set them with the password to be required to access the TubeSync dashboard you can set them with the
following environment variables: following environment variables:
@ -188,6 +188,14 @@ $ docker pull ghcr.io/meeb/tubesync:v[number]
Back-end updates such as database migrations should be automatic. Back-end updates such as database migrations should be automatic.
> [!IMPORTANT]
> `MariaDB` was not automatically upgraded for `UUID` column types.
> To see what changes are needed, you can run:
> ```bash
> docker exec -it tubesync python3 /app/manage.py fix-mariadb --dry-run --uuid-columns
> ```
> Removing the `--dry-run` will attempt to execute those statements using the configured database connection.
# Moving, backing up, etc. # Moving, backing up, etc.
@ -349,7 +357,7 @@ and you can probably break things by playing in the admin. If you still want to
it you can run: it you can run:
```bash ```bash
$ docker exec -ti tubesync python3 /app/manage.py createsuperuser $ docker exec -it tubesync python3 /app/manage.py createsuperuser
``` ```
And follow the instructions to create an initial Django superuser, once created, you And follow the instructions to create an initial Django superuser, once created, you
@ -415,7 +423,7 @@ following this rough guide, you are on your own and should be knowledgeable abou
installing and running WSGI-based Python web applications before attempting this. installing and running WSGI-based Python web applications before attempting this.
1. Clone or download this repo 1. Clone or download this repo
2. Make sure you're running a modern version of Python (>=3.9) and have Pipenv 2. Make sure you're running a modern version of Python (>=3.10) and have Pipenv
installed installed
3. Set up the environment with `pipenv install` 3. Set up the environment with `pipenv install`
4. Copy `tubesync/tubesync/local_settings.py.example` to 4. Copy `tubesync/tubesync/local_settings.py.example` to

View File

@ -1,8 +1,8 @@
import datetime import datetime
posix_epoch = datetime.datetime.utcfromtimestamp(0)
utc_tz = datetime.timezone.utc utc_tz = datetime.timezone.utc
posix_epoch = datetime.datetime.fromtimestamp(0, utc_tz)
def add_epoch(seconds): def add_epoch(seconds):
@ -13,10 +13,9 @@ def add_epoch(seconds):
def subtract_epoch(arg_dt, /): def subtract_epoch(arg_dt, /):
assert isinstance(arg_dt, datetime.datetime) assert isinstance(arg_dt, datetime.datetime)
epoch = posix_epoch.astimezone(utc_tz)
utc_dt = arg_dt.astimezone(utc_tz) utc_dt = arg_dt.astimezone(utc_tz)
return utc_dt - epoch return utc_dt - posix_epoch
def datetime_to_timestamp(arg_dt, /, *, integer=True): def datetime_to_timestamp(arg_dt, /, *, integer=True):
timestamp = subtract_epoch(arg_dt).total_seconds() timestamp = subtract_epoch(arg_dt).total_seconds()

View File

@ -1,8 +1,14 @@
from django import forms from django import forms, VERSION as DJANGO_VERSION
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
if DJANGO_VERSION[0:3] < (5, 0, 0):
_assume_scheme = dict()
else:
# Silence RemovedInDjango60Warning
_assume_scheme = dict(assume_scheme='http')
class ValidateSourceForm(forms.Form): class ValidateSourceForm(forms.Form):
source_type = forms.CharField( source_type = forms.CharField(
@ -12,7 +18,8 @@ class ValidateSourceForm(forms.Form):
) )
source_url = forms.URLField( source_url = forms.URLField(
label=_('Source URL'), label=_('Source URL'),
required=True required=True,
**_assume_scheme,
) )

View File

@ -24,6 +24,7 @@ def SQLTable(arg_table):
needle = arg_table needle = arg_table
if needle.startswith('new__'): if needle.startswith('new__'):
needle = arg_table[len('new__'):] needle = arg_table[len('new__'):]
db.connection.ensure_connection()
valid_table_name = ( valid_table_name = (
needle in new_tables and needle in new_tables and
arg_table in db_tables(include_views=False) arg_table in db_tables(include_views=False)
@ -122,6 +123,7 @@ class Command(BaseCommand):
+ f': {db.connection.vendor}' + f': {db.connection.vendor}'
) )
db.connection.ensure_connection()
db_is_mariadb = ( db_is_mariadb = (
hasattr(db.connection, 'mysql_is_mariadb') and hasattr(db.connection, 'mysql_is_mariadb') and
db.connection.is_usable() and db.connection.is_usable() and
@ -220,7 +222,7 @@ class Command(BaseCommand):
at_31, err_31, out_31 = check_migration_status( '0031_metadata_metadataformat' ) at_31, err_31, out_31 = check_migration_status( '0031_metadata_metadataformat' )
at_31s, err_31s, out_31s = check_migration_status( '0031_squashed_metadata_metadataformat' ) at_31s, err_31s, out_31s = check_migration_status( '0031_squashed_metadata_metadataformat' )
after_31, err_31a, out_31a = check_migration_status( after_31, err_31a, out_31a = check_migration_status(
'0030_alter_source_source_vcodec', '0031_metadata_metadataformat',
needle='Undo Rename table for metadata to sync_media_metadata', needle='Undo Rename table for metadata to sync_media_metadata',
) )

View File

@ -22,20 +22,6 @@ from .filtering import filter_media
from .choices import Val, YouTube_SourceType from .choices import Val, YouTube_SourceType
def is_relative_to(self, *other):
"""Return True if the path is relative to another path or False.
"""
try:
self.relative_to(*other)
return True
except ValueError:
return False
# patch Path for Python 3.8
if not hasattr(Path, 'is_relative_to'):
Path.is_relative_to = is_relative_to
@receiver(pre_save, sender=Source) @receiver(pre_save, sender=Source)
def source_pre_save(sender, instance, **kwargs): def source_pre_save(sender, instance, **kwargs):
# Triggered before a source is saved, if the schedule has been updated recreate # Triggered before a source is saved, if the schedule has been updated recreate

View File

@ -1,3 +1,4 @@
from django import VERSION as DJANGO_VERSION
from pathlib import Path from pathlib import Path
from common.utils import getenv from common.utils import getenv
@ -7,7 +8,7 @@ CONFIG_BASE_DIR = BASE_DIR
DOWNLOADS_BASE_DIR = BASE_DIR DOWNLOADS_BASE_DIR = BASE_DIR
VERSION = '0.15.1' VERSION = '0.15.2'
SECRET_KEY = '' SECRET_KEY = ''
DEBUG = False DEBUG = False
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []
@ -99,7 +100,10 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
TIME_ZONE = getenv('TZ', 'UTC') TIME_ZONE = getenv('TZ', 'UTC')
USE_I18N = True USE_I18N = True
USE_L10N = True # Removed in Django 5.0, set to True by default in Django 4.0
# https://docs.djangoproject.com/en/4.1/releases/4.0/#localization
if DJANGO_VERSION[0:3] < (4, 0, 0):
USE_L10N = True
USE_TZ = True USE_TZ = True