From 0394d7451e8361d72b34a9042f3f2424cc1cfd61 Mon Sep 17 00:00:00 2001
From: Emmanuel Cazenave <ecazenave@entrouvert.com>
Date: Mon, 8 Jun 2020 14:13:04 +0200
Subject: [PATCH] debian: switch to Python 3 (#43753)

---
 debian/compat                    |  2 +-
 debian/control                   | 74 ++++++++++++++++----------------
 debian/py3dist-overrides         |  7 +++
 debian/pydist-overrides          |  1 -
 debian/python-passerelle.dirs    |  1 -
 debian/python-passerelle.docs    |  2 -
 debian/python-passerelle.install |  2 -
 debian/rules                     | 10 +++--
 debian/uwsgi.ini                 |  2 +-
 9 files changed, 52 insertions(+), 49 deletions(-)
 create mode 100644 debian/py3dist-overrides
 delete mode 100644 debian/pydist-overrides
 delete mode 100644 debian/python-passerelle.dirs
 delete mode 100644 debian/python-passerelle.docs
 delete mode 100644 debian/python-passerelle.install

diff --git a/debian/compat b/debian/compat
index ec635144..f599e28b 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-9
+10
diff --git a/debian/control b/debian/control
index a1304bf3..72315a04 100644
--- a/debian/control
+++ b/debian/control
@@ -2,57 +2,55 @@ Source: passerelle
 Section: python
 Priority: optional
 Maintainer: Thomas NOËL <tnoel@entrouvert.com>
-Build-Depends: debhelper (>= 9.0.0),
-    python-django,
-    python-setuptools (>= 0.6b3),
-    python-all (>= 2.6.6-3),
+Build-Depends: debhelper (>= 10),
+    python3-django,
+    python3-setuptools,
+    python3-all,
     dh-python,
     dh-systemd
 Standards-Version: 3.9.6
 Homepage: https://dev.entrouvert.org/projects/passerelle
-X-Python-Version: >= 2.7
 
-Package: python-passerelle
+Package: python3-passerelle
 Architecture: all
-Depends: ${python:Depends},
+Depends: ${python3:Depends},
     ${misc:Depends},
-    python-django (>= 1:1.11),
-    python-gadjo,
-    python-django-model-utils,
-    python-requests,
-    python-setuptools,
-    python-suds,
-    python-cmislib,
-    python-lxml,
-    python-dateutil,
-    python-pyproj,
-    python-pil,
-    python-zeep (>= 3.2),
-    python-jsonschema,
-    python-unidecode,
-    python-pyexcel-io,
-    python-pyexcel-ods,
-    python-pyexcel-xls,
-    python-crypto,
-    python-pycryptodome,
-    python-feedparser,
-    python-pdfrw,
-    python-httplib2,
-    python-xmlschema
-Recommends: python-soappy, python-phpserialize
+    python3-django (>= 1:1.11),
+    python3-gadjo,
+    python3-django-model-utils,
+    python3-requests,
+    python3-setuptools,
+    python3-suds,
+    python3-cmislib,
+    python3-lxml,
+    python3-dateutil,
+    python3-pyproj,
+    python3-pil,
+    python3-zeep (>= 3.2),
+    python3-jsonschema,
+    python3-unidecode,
+    python3-pyexcel-io,
+    python3-pyexcel-ods,
+    python3-pyexcel-xls,
+    python3-crypto,
+    python3-pycryptodome,
+    python3-feedparser,
+    python3-pdfrw,
+    python3-httplib2,
+    python3-xmlschema
 Description: Uniform access to multiple data sources and services (Python module)
 
 Package: passerelle
 Architecture: all
 Depends: ${misc:Depends}, adduser,
-    python-passerelle (= ${binary:Version}),
-    python-hobo,
-    python-django-tenant-schemas,
-    python-psycopg2,
-    python-memcache,
-    python-django-mellon,
+    python3-passerelle (= ${binary:Version}),
+    python3-hobo,
+    python3-django-tenant-schemas,
+    python3-psycopg2,
+    python3-memcache,
+    python3-django-mellon,
     uwsgi,
-    uwsgi-plugin-python
+    uwsgi-plugin-python3
 Recommends: nginx, memcached
 Suggests: postgresql
 Description: Uniform access to multiple data sources and services
diff --git a/debian/py3dist-overrides b/debian/py3dist-overrides
new file mode 100644
index 00000000..050a2a53
--- /dev/null
+++ b/debian/py3dist-overrides
@@ -0,0 +1,7 @@
+cmislib_maykin python3-cmislib
+gadjo python3-gadjo
+pyexcel_io python3-pyexcel-io
+pyexcel_ods python3-pyexcel-ods
+pyexcel_xls python3-pyexcel-xls
+suds_jurko python3-suds
+xmlschema python3-xmlschema
diff --git a/debian/pydist-overrides b/debian/pydist-overrides
deleted file mode 100644
index 5837774e..00000000
--- a/debian/pydist-overrides
+++ /dev/null
@@ -1 +0,0 @@
-django-jsonresponse python-django-jsonresponse
diff --git a/debian/python-passerelle.dirs b/debian/python-passerelle.dirs
deleted file mode 100644
index afe0cdd2..00000000
--- a/debian/python-passerelle.dirs
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/passerelle
diff --git a/debian/python-passerelle.docs b/debian/python-passerelle.docs
deleted file mode 100644
index df15c73b..00000000
--- a/debian/python-passerelle.docs
+++ /dev/null
@@ -1,2 +0,0 @@
-README
-LICENSE
diff --git a/debian/python-passerelle.install b/debian/python-passerelle.install
deleted file mode 100644
index 0c08527d..00000000
--- a/debian/python-passerelle.install
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin/manage.py /usr/lib/passerelle
-usr/lib/python2*/*-packages
diff --git a/debian/rules b/debian/rules
index 83aef84d..3e8dd04b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,8 +1,12 @@
 #!/usr/bin/make -f
 # -*- makefile -*-
 
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
+export PYBUILD_NAME=passerelle
+export PYBUILD_DISABLE=test
 
 %:
-	dh $@ --with python2,systemd
+	dh $@ --with python3,systemd --buildsystem=pybuild
+
+override_dh_install:
+	dh_install
+	mv $(CURDIR)/debian/python3-passerelle/usr/bin/manage.py $(CURDIR)/debian/passerelle/usr/lib/passerelle/manage.py
diff --git a/debian/uwsgi.ini b/debian/uwsgi.ini
index d5a1a095..bf3a7fe9 100644
--- a/debian/uwsgi.ini
+++ b/debian/uwsgi.ini
@@ -2,7 +2,7 @@
 auto-procname = true
 procname-prefix-spaced = passerelle
 
-plugin = python
+plugin = python3
 module = passerelle.wsgi:application
 
 http-socket = /run/passerelle/passerelle.sock
-- 
2.27.0

