From ea3104e7e39f79519b5a9f41d3234e9869df7b17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Tue, 31 Mar 2020 21:01:30 +0200
Subject: [PATCH] debian: switch to Python 3 (#41206)

---
 debian/bijoe-manage                           |  5 ++--
 debian/control                                | 26 +++++++++----------
 debian/py3dist-overrides                      |  4 +++
 debian/python-bijoe.dirs                      |  1 -
 debian/python-bijoe.install                   |  1 -
 .../{python-bijoe.docs => python3-bijoe.docs} |  0
 debian/python3-bijoe.install                  |  1 +
 debian/rules                                  |  4 ++-
 debian/uwsgi.ini                              |  2 +-
 manage.py                                     |  2 +-
 10 files changed, 25 insertions(+), 21 deletions(-)
 create mode 100644 debian/py3dist-overrides
 delete mode 100644 debian/python-bijoe.dirs
 delete mode 100644 debian/python-bijoe.install
 rename debian/{python-bijoe.docs => python3-bijoe.docs} (100%)
 create mode 100644 debian/python3-bijoe.install

diff --git a/debian/bijoe-manage b/debian/bijoe-manage
index c447d80..d70d302 100755
--- a/debian/bijoe-manage
+++ b/debian/bijoe-manage
@@ -18,9 +18,8 @@ fi
 
 if test $# -eq 0
 then
-    python ${MANAGE} help
+    python3 ${MANAGE} help
     exit 1
 fi
 
-python ${MANAGE} "$@"
-
+python3 ${MANAGE} "$@"
diff --git a/debian/control b/debian/control
index 5002e70..612ed4b 100644
--- a/debian/control
+++ b/debian/control
@@ -2,28 +2,28 @@ Source: bijoe
 Section: python
 Priority: optional
 Maintainer: Benjamin Dauvergne <bdauvergne@entrouvert.com>
-Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6), debhelper (>= 9), python-django, dh-python, dh-systemd
+Build-Depends: python3-setuptools, python3-all, debhelper (>= 9), python3-django, dh-python, dh-systemd
 Standards-Version: 3.9.1
-Homepage: http://dev.entrouvert.org/projects/publik-bi/
+Homepage: https://dev.entrouvert.org/projects/bijoe/
 
-Package: python-bijoe
+Package: python3-bijoe
 Architecture: all
-Depends: ${python:Depends},
+Depends: ${python3:Depends},
     ${misc:Depends},
-    python-django-jsonfield (>= 0.9.19),
-    python-hobo,
-    python-django-select2,
-    python-django-tenant-schemas,
-    python-psycopg2,
-    python-django-mellon,
+    python3-django-jsonfield (>= 0.9.19),
+    python3-hobo,
+    python3-django-select2,
+    python3-django-tenant-schemas,
+    python3-psycopg2,
+    python3-django-mellon,
     wcs-olap
 Description: BI dashboard from Postgres db with star schema
 
 Package: bijoe
 Architecture: all
-Depends: ${python:Depends},
+Depends: ${python3:Depends},
     ${misc:Depends},
-    python-bijoe (= ${binary:Version}),
+    python3-bijoe (= ${binary:Version}),
     uwsgi,
-    uwsgi-plugin-python
+    uwsgi-plugin-python3
 Description: BI dashboard from Postgres db with star schema
diff --git a/debian/py3dist-overrides b/debian/py3dist-overrides
new file mode 100644
index 0000000..865b9e9
--- /dev/null
+++ b/debian/py3dist-overrides
@@ -0,0 +1,4 @@
+isodate python3-isodate
+psycopg2 python3-psycopg2
+XStatic-ChartNew.js python3-xstatic-chartnew-js
+xstatic-select2 python3-xstatic-select2
diff --git a/debian/python-bijoe.dirs b/debian/python-bijoe.dirs
deleted file mode 100644
index 83a5884..0000000
--- a/debian/python-bijoe.dirs
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/bijoe
diff --git a/debian/python-bijoe.install b/debian/python-bijoe.install
deleted file mode 100644
index 5fda4d4..0000000
--- a/debian/python-bijoe.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/python2*/*-packages
diff --git a/debian/python-bijoe.docs b/debian/python3-bijoe.docs
similarity index 100%
rename from debian/python-bijoe.docs
rename to debian/python3-bijoe.docs
diff --git a/debian/python3-bijoe.install b/debian/python3-bijoe.install
new file mode 100644
index 0000000..8e72dc9
--- /dev/null
+++ b/debian/python3-bijoe.install
@@ -0,0 +1 @@
+usr/lib/python3.*
diff --git a/debian/rules b/debian/rules
index c980527..783a5ce 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,4 +1,6 @@
 #!/usr/bin/make -f
 
+export PYBUILD_DISABLE=test
+
 %:
-	dh $@ --with python2,systemd
+	dh $@ --with python3,systemd --buildsystem=pybuild
diff --git a/debian/uwsgi.ini b/debian/uwsgi.ini
index cae702f..fda6669 100644
--- a/debian/uwsgi.ini
+++ b/debian/uwsgi.ini
@@ -2,7 +2,7 @@
 auto-procname = true
 procname-prefix-spaced = bijoe
 
-plugin = python
+plugin = python3
 module = bijoe.wsgi:application
 
 http-socket = /run/bijoe/bijoe.sock
diff --git a/manage.py b/manage.py
index 65ea9ae..08ff10a 100755
--- a/manage.py
+++ b/manage.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import os
 import sys
 
-- 
2.26.0

