django1: Fix byte-compiled db migrations not loaded
authorJeffery To <jeffery.to@gmail.com>
Fri, 21 Feb 2020 20:45:28 +0000 (04:45 +0800)
committerJeffery To <jeffery.to@gmail.com>
Fri, 13 Mar 2020 20:35:00 +0000 (04:35 +0800)
This patches Django to load byte-compiled (.pyc) db migration scripts,
since Python scripts are often distributed in byte-compiled form in
OpenWrt packages.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/django1/Makefile
lang/python/django1/patches/001-load-byte-compiled-db-migrations.patch [new file with mode: 0644]

index c7d3bbcf6293aac98cb6ecbc32f0f5a08b3528d8..db260a2084a16b2907be3e1c229c1efd5d54a7c0 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=django1
 PKG_VERSION:=1.11.29
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PYPI_NAME:=Django
 PKG_HASH:=4200aefb6678019a0acf0005cd14cfce3a5e6b9b90d06145fcdd2e474ad4329c
diff --git a/lang/python/django1/patches/001-load-byte-compiled-db-migrations.patch b/lang/python/django1/patches/001-load-byte-compiled-db-migrations.patch
new file mode 100644 (file)
index 0000000..e347e55
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/django/db/migrations/loader.py
++++ b/django/db/migrations/loader.py
+@@ -106,7 +106,7 @@ class MigrationLoader(object):
+             # Scan for .py files
+             migration_names = set()
+             for name in os.listdir(directory):
+-                if name.endswith(".py"):
++                if name.endswith(".py") or name.endswith(".pyc"):
+                     import_name = name.rsplit(".", 1)[0]
+                     if import_name[0] not in "_.~":
+                         migration_names.add(import_name)