aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Tong <hubert.reinterpretcast@gmail.com>2019-09-20 15:20:41 +0000
committerHubert Tong <hubert.reinterpretcast@gmail.com>2019-09-20 15:20:41 +0000
commitff933341a3cf875aa35748b80d4244a333e423fe (patch)
treec238b375c9a7547231950868705b3ec2445b68e7
parent4c2511c775511675884296797908464134189402 (diff)
[LNT] Python 3 support: Fix implicit package-relative imports
Summary: This patch replaces implicit package-relative imports with explicitly relative imports and makes further adjustments necessary to correct for circular import issues encountered when running with Python 2.7 following the initial changes. Finally, `from __future__ import absolute_import` is added to all of the files changed as part of this exercise. These changes help with running tests (without result submission) with Python 3. Reviewers: cmatthews, thopre, kristof.beyls, MaskRay Reviewed By: MaskRay Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D67795 git-svn-id: https://llvm.org/svn/llvm-project/lnt/trunk@372404 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lnt/external/stats/pstat.py2
-rw-r--r--lnt/external/stats/stats.py3
-rw-r--r--lnt/formats/__init__.py5
-rw-r--r--lnt/lnttool/__init__.py3
-rw-r--r--lnt/server/db/testsuite.py6
-rw-r--r--lnt/server/db/testsuitedb.py3
-rw-r--r--lnt/testing/profile/__init__.py7
-rw-r--r--lnt/testing/profile/perf.py5
-rw-r--r--lnt/testing/profile/profilev2impl.py3
9 files changed, 23 insertions, 14 deletions
diff --git a/lnt/external/stats/pstat.py b/lnt/external/stats/pstat.py
index aa8c616..748dbef 100644
--- a/lnt/external/stats/pstat.py
+++ b/lnt/external/stats/pstat.py
@@ -105,8 +105,8 @@ functions/methods. Their inclusion here is for function name consistency.
##
## 11/08/98 ... fixed aput to output large arrays correctly
+from __future__ import absolute_import
from __future__ import print_function
-import stats # required 3rd party module
import string, copy
from types import *
diff --git a/lnt/external/stats/stats.py b/lnt/external/stats/stats.py
index c792d13..4fb5d36 100644
--- a/lnt/external/stats/stats.py
+++ b/lnt/external/stats/stats.py
@@ -222,8 +222,9 @@ SUPPORT FUNCTIONS: writecc
## changed name of skewness and askewness to skew and askew
## fixed (a)histogram (which sometimes counted points <lowerlimit)
+from __future__ import absolute_import
from __future__ import print_function
-import pstat # required 3rd party module
+from . import pstat # required 3rd party module
import math, string, copy # required python modules
from types import *
diff --git a/lnt/formats/__init__.py b/lnt/formats/__init__.py
index 9079450..c03ffb8 100644
--- a/lnt/formats/__init__.py
+++ b/lnt/formats/__init__.py
@@ -7,8 +7,9 @@ callable taking a path_or_file object, the 'write' function should be a
callable taking a Python object to write, and the path_or_file to write to.
"""
-from PlistFormat import format as plist
-from JSONFormat import format as json
+from __future__ import absolute_import
+from .PlistFormat import format as plist
+from .JSONFormat import format as json
formats = [plist, json]
formats_by_name = dict((f['name'], f) for f in formats)
diff --git a/lnt/lnttool/__init__.py b/lnt/lnttool/__init__.py
index 7760218..28a041b 100644
--- a/lnt/lnttool/__init__.py
+++ b/lnt/lnttool/__init__.py
@@ -1 +1,2 @@
-from main import main
+from __future__ import absolute_import
+from .main import main
diff --git a/lnt/server/db/testsuite.py b/lnt/server/db/testsuite.py
index 9e89600..d8e2f40 100644
--- a/lnt/server/db/testsuite.py
+++ b/lnt/server/db/testsuite.py
@@ -2,10 +2,10 @@
Database models for the TestSuites abstraction.
"""
+from __future__ import absolute_import
import json
import lnt
-import testsuitedb
-import util
+from . import util
import sqlalchemy
import sqlalchemy.ext.declarative
@@ -114,6 +114,7 @@ class TestSuite(Base):
@staticmethod
def from_json(data):
+ from . import testsuitedb
if data.get('format_version') != '2':
raise ValueError("Expected \"format_version\": \"2\" in schema")
name = data['name']
@@ -349,6 +350,7 @@ class SampleField(FieldMixin, Base):
def _upgrade_to(connectable, tsschema, new_schema, dry_run=False):
+ from . import testsuitedb
new = json.loads(new_schema.jsonschema)
old = json.loads(tsschema.jsonschema)
ts_name = new['name']
diff --git a/lnt/server/db/testsuitedb.py b/lnt/server/db/testsuitedb.py
index fdf72c0..303a46d 100644
--- a/lnt/server/db/testsuitedb.py
+++ b/lnt/server/db/testsuitedb.py
@@ -5,6 +5,7 @@ These are a bit magical because the models themselves are driven by the test
suite metadata, so we only create the classes at runtime.
"""
+from __future__ import absolute_import
import datetime
import json
import os
@@ -18,7 +19,7 @@ from sqlalchemy.orm.exc import ObjectDeletedError
from typing import List
from lnt.util import logger
-import testsuite
+from . import testsuite
import lnt.testing.profile.profile as profile
import lnt
from lnt.server.ui.util import convert_revision
diff --git a/lnt/testing/profile/__init__.py b/lnt/testing/profile/__init__.py
index 841e71e..c570776 100644
--- a/lnt/testing/profile/__init__.py
+++ b/lnt/testing/profile/__init__.py
@@ -1,7 +1,8 @@
# This is the profile implementation registry. Register new profile
# implementations here.
-from profilev1impl import ProfileV1
-from profilev2impl import ProfileV2
-from perf import LinuxPerfProfile
+from __future__ import absolute_import
+from .profilev1impl import ProfileV1
+from .profilev2impl import ProfileV2
+from .perf import LinuxPerfProfile
IMPLEMENTATIONS = {0: LinuxPerfProfile, 1: ProfileV1, 2: ProfileV2}
diff --git a/lnt/testing/profile/perf.py b/lnt/testing/profile/perf.py
index 4c2174e..35901ec 100644
--- a/lnt/testing/profile/perf.py
+++ b/lnt/testing/profile/perf.py
@@ -1,6 +1,7 @@
+from __future__ import absolute_import
from lnt.util import logger
-from profile import ProfileImpl
-from profilev1impl import ProfileV1
+from .profile import ProfileImpl
+from .profilev1impl import ProfileV1
import os
import traceback
diff --git a/lnt/testing/profile/profilev2impl.py b/lnt/testing/profile/profilev2impl.py
index ccb75e9..c0114ba 100644
--- a/lnt/testing/profile/profilev2impl.py
+++ b/lnt/testing/profile/profilev2impl.py
@@ -1,4 +1,5 @@
-from profile import ProfileImpl
+from __future__ import absolute_import
+from .profile import ProfileImpl
import StringIO
import bz2
import copy