launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25124
[Merge] ~cjwatson/launchpad:py3-no-bzr into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-no-bzr into launchpad:master.
Commit message:
Avoid importing bzrlib and subvertpy on Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/388913
Code imports won't work on Python 3 until they've been ported to Breezy. Nevertheless, it's useful to be able to get far enough to import other parts of the test suite.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-no-bzr into launchpad:master.
diff --git a/lib/lp/codehosting/__init__.py b/lib/lp/codehosting/__init__.py
index bd097f9..3bbee21 100644
--- a/lib/lp/codehosting/__init__.py
+++ b/lib/lp/codehosting/__init__.py
@@ -23,13 +23,16 @@ from breezy.library_state import BzrLibraryState as BrzLibraryState
from breezy.plugin import load_plugins as brz_load_plugins
# This import is needed so that brz's logger gets registered.
import breezy.trace
-from bzrlib.plugin import load_plugins as bzr_load_plugins
-# This import is needed so that bzr's logger gets registered.
-import bzrlib.trace
+import six
from zope.security import checker
from lp.services.config import config
+if six.PY2:
+ from bzrlib.plugin import load_plugins as bzr_load_plugins
+ # This import is needed so that bzr's logger gets registered.
+ import bzrlib.trace
+
def get_brz_path():
"""Find the path to the copy of Breezy for this rocketfuel instance"""
@@ -93,9 +96,10 @@ os.environ['BRZ_DISABLE_PLUGINS'] = ':'.join([
'mtn',
])
-# We want to have full access to Launchpad's Bazaar plugins throughout the
+# We want to have full access to Launchpad's Breezy plugins throughout the
# codehosting package.
-bzr_load_plugins([_get_bzr_plugins_path()])
+if six.PY2:
+ bzr_load_plugins([_get_bzr_plugins_path()])
brz_load_plugins()
diff --git a/lib/lp/testing/__init__.py b/lib/lp/testing/__init__.py
index a2c9448..a75ae5c 100644
--- a/lib/lp/testing/__init__.py
+++ b/lib/lp/testing/__init__.py
@@ -86,7 +86,6 @@ from breezy.controldir import (
format_registry,
)
from breezy.transport import get_transport
-from bzrlib import trace as bzr_trace
import fixtures
from lazr.restful.testing.tales import test_tales
from lazr.restful.testing.webservice import FakeRequest
@@ -191,6 +190,9 @@ from lp.testing.fixture import (
from lp.testing.karma import KarmaRecorder
from lp.testing.mail_helpers import pop_notifications
+if six.PY2:
+ from bzrlib import trace as bzr_trace
+
# The following names have been imported for the purpose of being
# exported. They are referred to here to silence lint warnings.
admin_logged_in
@@ -851,7 +853,8 @@ class TestCaseWithFactory(TestCase):
# make it so in order to avoid "No handlers for "brz" logger'
# messages.
trace._brz_logger = logging.getLogger('brz')
- bzr_trace._bzr_logger = logging.getLogger('bzr')
+ if six.PY2:
+ bzr_trace._bzr_logger = logging.getLogger('bzr')
def getUserBrowser(self, url=None, user=None):
"""Return a Browser logged in as a fresh user, maybe opened at `url`.
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 66fa9b3..4d93342 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -150,7 +150,6 @@ from lp.code.model.diff import (
Diff,
PreviewDiff,
)
-from lp.codehosting.codeimport.worker import CodeImportSourceDetails
from lp.hardwaredb.interfaces.hwdb import (
HWSubmissionFormat,
IHWDeviceDriverLinkSet,
@@ -523,6 +522,14 @@ class ObjectFactory(
target_rcstype=None, url=None,
cvs_root=None, cvs_module=None,
stacked_on_url=None, macaroon=None):
+ if not six.PY2:
+ raise NotImplementedError(
+ "Code imports do not yet work on Python 3.")
+
+ # XXX cjwatson 2020-08-07: Move this back up to module level once
+ # codeimport has been ported to Breezy.
+ from lp.codehosting.codeimport.worker import CodeImportSourceDetails
+
if target_id is None:
target_id = self.getUniqueInteger()
if rcstype is None:
diff --git a/setup.py b/setup.py
index 111ac58..b724650 100644
--- a/setup.py
+++ b/setup.py
@@ -154,7 +154,10 @@ setup(
'backports.lzma; python_version < "3.3"',
'beautifulsoup4[lxml]',
'breezy',
- 'bzr',
+ # XXX cjwatson 2020-08-07: This should eventually be removed
+ # entirely, but we need to retain it until codeimport has been
+ # ported to Breezy.
+ 'bzr; python_version < "3"',
'celery',
'contextlib2; python_version < "3.3"',
'cssselect',
@@ -230,7 +233,9 @@ setup(
'soupmatchers',
'Sphinx',
'storm',
- 'subvertpy',
+ # XXX cjwatson 2020-08-07: Temporarily dropped on Python 3 until
+ # codeimport can be ported to Breezy.
+ 'subvertpy; python_version < "3"',
'tenacity',
'testscenarios',
'testtools',