← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:drop-py2-requirement into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:drop-py2-requirement into launchpad-buildd:master.

Commit message:
Remove Python 2 support from packaging

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/415787

Now that we've decommissioned our powerpc build infrastructure, we no longer need to retain xenial or Python 2 support.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:drop-py2-requirement into launchpad-buildd:master.
diff --git a/.gitignore b/.gitignore
index ef4c204..4a9f33a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,7 +8,6 @@ dist
 debian/debhelper-build-stamp
 debian/files
 debian/launchpad-buildd
-debian/python-lpbuildd
 debian/python3-lpbuildd
 debian/tmp
 debian/*.debhelper.log
diff --git a/Makefile b/Makefile
index 28f8bf1..fea4c04 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,5 @@ realclean:
 .PHONY: all clean deb
 
 check:
-	PYTHONPATH=$(CURDIR):$(PYTHONPATH) python -m testtools.run \
-		discover -v
 	PYTHONPATH=$(CURDIR):$(PYTHONPATH) python3 -m testtools.run \
 		discover -v
diff --git a/bin/builder-prep b/bin/builder-prep
index 0a75e9a..7fc82fe 100755
--- a/bin/builder-prep
+++ b/bin/builder-prep
@@ -9,7 +9,7 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin:${PATH}
 
 NTPDATE=ntpdate
 SUDO=sudo
-PACKAGES="launchpad-buildd python-lpbuildd python3-lpbuildd sbuild bzr-builder bzr git-build-recipe git dpkg-dev python-debian python3-debian"
+PACKAGES="launchpad-buildd python3-lpbuildd sbuild bzr-builder bzr git-build-recipe git dpkg-dev python3-debian"
 KERNEL=$(uname -snrvm)
 
 echo "Kernel version: $KERNEL"
diff --git a/debian/changelog b/debian/changelog
index 85dc4e2..355fb51 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 launchpad-buildd (209) UNRELEASED; urgency=medium
 
   * Upgrade charm to bionic and Python 3.
+  * Remove Python 2 support.
 
  -- Colin Watson <cjwatson@xxxxxxxxxx>  Thu, 10 Feb 2022 09:27:28 +0000
 
diff --git a/debian/check-python3-twisted b/debian/check-python3-twisted
deleted file mode 100755
index 21331e8..0000000
--- a/debian/check-python3-twisted
+++ /dev/null
@@ -1,9 +0,0 @@
-#! /usr/bin/python3
-
-import sys
-
-import twisted
-
-
-ok = (twisted.version.major, twisted.version.minor) >= (16, 4)
-sys.exit(0 if ok else 1)
diff --git a/debian/control b/debian/control
index d3e90d9..25cc5f1 100644
--- a/debian/control
+++ b/debian/control
@@ -13,25 +13,6 @@ Build-Depends: apt-utils,
                dh-python,
                git,
                intltool,
-               python (>= 2.6.6-3~),
-               python-apt,
-               python-debian,
-               python-fixtures,
-               python-mock,
-               python-netaddr,
-               python-pylxd,
-               python-requests,
-               python-responses,
-               python-setuptools,
-               python-six,
-               python-systemfixtures,
-               python-testtools,
-               python-twisted,
-               python-txfixtures,
-# We don't use the bits of pylxd that require this at run-time, but at
-# build-time pybuild fails if it's not available.
-               python-ws4py,
-               python-zope.interface,
                python3 (>= 3.3),
                python3-apt,
                python3-debian,
@@ -44,7 +25,7 @@ Build-Depends: apt-utils,
                python3-six,
                python3-systemfixtures,
                python3-testtools,
-               python3-twisted,
+               python3-twisted (>= 16.4.0),
                python3-txfixtures,
 # We don't use the bits of pylxd that require this at run-time, but at
 # build-time pybuild fails if it's not available.
@@ -68,9 +49,9 @@ Depends: adduser,
          lxd,
          ntpdate,
          pristine-tar,
-         ${lpbuildd-python-prefix},
-         ${lpbuildd-python-prefix}-apt,
-         ${lpbuildd-python-prefix}-lpbuildd (= ${source:Version}),
+         python3,
+         python3-apt,
+         python3-lpbuildd (= ${source:Version}),
          sbuild,
          schroot,
          sudo,
@@ -84,23 +65,6 @@ Description: Launchpad buildd slave
  slave instance on the same computer, be sure to give them independent configs
  and independent filecaches etc.
 
-Package: python-lpbuildd
-Section: python
-Architecture: all
-Depends: apt-utils,
-         procps,
-         python-apt,
-         python-netaddr,
-         python-pylxd,
-# Work around missing dependency in python-pbr.
-         python-setuptools,
-         ${misc:Depends},
-         ${python:Depends},
-Breaks: launchpad-buildd (<< 88)
-Replaces: launchpad-buildd (<< 88)
-Description: Python 2 libraries for a Launchpad buildd slave
- This contains the Python 2 libraries that control the Launchpad buildd slave.
-
 Package: python3-lpbuildd
 Section: python
 Architecture: all
diff --git a/debian/rules b/debian/rules
index 2746afa..77d4e89 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,17 +6,10 @@
 # 3 (see the file LICENSE).
 
 export PYBUILD_NAME := lpbuildd
-
-ifeq (ok,$(shell debian/check-python3-twisted && echo ok))
-    export LPBUILDD_PYTHON_PREFIX := python3
-    export LIBDIR := $(shell python3 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())')
-else
-    export LPBUILDD_PYTHON_PREFIX := python
-    export LIBDIR := $(shell python2 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())')
-endif
+export LIBDIR := $(shell python3 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())')
 
 %:
-	dh $@ --with=python2,python3 --buildsystem=pybuild
+	dh $@ --with=python3 --buildsystem=pybuild
 
 override_dh_auto_build:
 	dh_auto_build
@@ -24,20 +17,5 @@ override_dh_auto_build:
 	--arch=i386 --port=8221 --name=default --host=buildd.buildd \
 		> buildd-slave-example.conf
 
-ifeq ($(LPBUILDD_PYTHON_PREFIX),python)
-override_dh_install:
-	dh_install
-	find debian/launchpad-buildd -type f | xargs grep -l '#!.*python3' | \
-		xargs -r sed -i 's/\(#!.*\)python3/\1python2/'
-
-override_dh_installinit:
-	dh_installinit
-	sed -i 's/twistd3/twistd/' \
-		debian/launchpad-buildd/etc/init.d/launchpad-buildd
-endif
-
-override_dh_gencontrol:
-	dh_gencontrol -- -Vlpbuildd-python-prefix=$(LPBUILDD_PYTHON_PREFIX)
-
 override_dh_builddeb:
 	dh_builddeb -- -Zgzip
diff --git a/docs/explanation/deployment.rst b/docs/explanation/deployment.rst
index 19b5fef..1f0d3fa 100644
--- a/docs/explanation/deployment.rst
+++ b/docs/explanation/deployment.rst
@@ -8,12 +8,3 @@ https://launchpad.net/~canonical-is-sa/+archive/ubuntu/buildd.  This is done
 by
 https://code.launchpad.net/~canonical-sysadmins/canonical-is-charms/launchpad-buildd-image-modifier
 (currently private, sorry).
-
-At present (November 2020), most of these base VM images are built from
-Ubuntu bionic, and launchpad-buildd runs on Python 3.  However, it's
-necessary to support the powerpc architecture until at least April 2021 (end
-of standard maintenance for xenial), and the powerpc base images need to
-stay on xenial since that architecture is no longer supported by bionic;
-furthermore, the version of Twisted in xenial has some bugs that break
-launchpad-buildd when running on Python 3.  As a result, launchpad-buildd
-must run on both Python 2 and 3 for the time being.
\ No newline at end of file
diff --git a/lpbuildd/target/tests/test_generate_translation_templates.py b/lpbuildd/target/tests/test_generate_translation_templates.py
index d9dfe38..54ac395 100644
--- a/lpbuildd/target/tests/test_generate_translation_templates.py
+++ b/lpbuildd/target/tests/test_generate_translation_templates.py
@@ -6,10 +6,7 @@ __metaclass__ = type
 import os
 import subprocess
 import tarfile
-try:
-    from unittest import mock
-except ImportError:
-    import mock
+from unittest import mock
 
 from fixtures import (
     EnvironmentVariable,
diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py
index 15b2f1c..e94657b 100644
--- a/lpbuildd/target/tests/test_lxd.py
+++ b/lpbuildd/target/tests/test_lxd.py
@@ -15,10 +15,7 @@ import stat
 import tarfile
 from textwrap import dedent
 import time
-try:
-    from unittest import mock
-except ImportError:
-    import mock
+from unittest import mock
 
 from fixtures import (
     EnvironmentVariable,
diff --git a/lpbuildd/tests/test_charm.py b/lpbuildd/tests/test_charm.py
index 3968cc3..671ecaf 100644
--- a/lpbuildd/tests/test_charm.py
+++ b/lpbuildd/tests/test_charm.py
@@ -4,10 +4,7 @@
 __metaclass__ = type
 
 import os
-try:
-    from unittest import mock
-except ImportError:
-    import mock
+from unittest import mock
 
 from fixtures import (
     EnvironmentVariable,
diff --git a/lpbuildd/tests/test_snap.py b/lpbuildd/tests/test_snap.py
index 5aa0671..6fec8e5 100644
--- a/lpbuildd/tests/test_snap.py
+++ b/lpbuildd/tests/test_snap.py
@@ -4,10 +4,7 @@
 __metaclass__ = type
 
 import os
-try:
-    from unittest import mock
-except ImportError:
-    import mock
+from unittest import mock
 
 from fixtures import (
     EnvironmentVariable,
diff --git a/setup.py b/setup.py
index 23ec786..60ecb43 100755
--- a/setup.py
+++ b/setup.py
@@ -71,7 +71,6 @@ setup(
     test_suite='lpbuildd',
     tests_require=[
         'fixtures',
-        'mock; python_version<"3"',
         'responses',
         'systemfixtures',
         'testtools',
diff --git a/system-dependencies.txt b/system-dependencies.txt
index 81c8627..ba2d9af 100644
--- a/system-dependencies.txt
+++ b/system-dependencies.txt
@@ -5,21 +5,6 @@ dpkg-dev
 git
 intltool
 make
-python-apt
-python-debian
-python-fixtures
-python-mock
-python-netaddr
-python-pylxd
-python-requests
-python-responses
-python-setuptools
-python-six
-python-systemfixtures
-python-testtools
-python-twisted
-python-txfixtures
-python-zope.interface
 python3-apt
 python3-debian
 python3-fixtures