From 2c13f6804d7bf277d01b11fdbf6f859a32fd5910 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 10 Dec 2020 10:14:30 -0500 Subject: [PATCH] Add Python 3.9 support (#1071) * Add Python 3.9 support This commit adds official python 3.9 support to qiskit-aer. This includes CI, release notes, and package metadata. Fixes #1067 * Remove wheel job 3.9 skip * Remove unused assertNoLogs method The assertNoLogs methods was built using a private class from python's stdlib unittest library. This should never have been done as it's explicitly marked as private. Accordingly in Python 3.9 this private class has been removed and no longer exists. It turns out this method was not used anywhere in all of qiskit (the same identical code was removed from terra as part of Qiskit/qiskit-terra#5189 in https://github.com/Qiskit/qiskit-terra/pull/5189/commits/ed5155b95c6e93f10d67c2154b58385a8a83b30d). Since the implementation is not sound and nothing uses it this commit just removes the class and method. * Fix azure pipelines job matrix typo Co-authored-by: Victor Villar --- .github/workflows/build.yml | 4 +-- .github/workflows/deploy.yml | 4 +-- .github/workflows/tests_linux.yml | 4 +-- .github/workflows/tests_mac.yml | 4 +-- .github/workflows/tests_windows.yml | 2 +- azure-pipelines.yml | 4 +++ .../notes/add-python3.9-83b3b4e5c3d59571.yaml | 10 ++++++ setup.py | 1 + test/terra/common.py | 34 ------------------- tox.ini | 2 +- 10 files changed, 25 insertions(+), 44 deletions(-) create mode 100644 releasenotes/notes/add-python3.9-83b3b4e5c3d59571.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 555bbb9a6d..840476f306 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,12 +70,12 @@ jobs: with: python-version: 3.8 - name: Install deps - run: python -m pip install -U cibuildwheel==1.7.0 + run: python -m pip install -U cibuildwheel==1.7.1 - name: Build Wheels env: CIBW_BEFORE_ALL_LINUX: "yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm && yum install -y openblas-devel" CIBW_BEFORE_BUILD: "pip install -U virtualenv pybind11" - CIBW_SKIP: "cp27-* cp34-* cp35-* cp39-* pp*" + CIBW_SKIP: "cp27-* cp34-* cp35-* pp*" CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux2010_x86_64:2020-12-03-912b0de" CIBW_MANYLINUX_I686_IMAGE: "quay.io/pypa/manylinux2010_i686:2020-12-03-912b0de" CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2ad5c1f7a0..720d10b490 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,7 +18,7 @@ jobs: python-version: '3.7' - name: Install cibuildwheel run: | - python -m pip install cibuildwheel==1.5.5 + python -m pip install cibuildwheel==1.7.1 - name: Build wheels env: CIBW_BEFORE_ALL_LINUX: "yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm && yum install -y openblas-devel" @@ -74,7 +74,7 @@ jobs: python-version: '3.7' - name: Install cibuildwheel run: | - python -m pip install cibuildwheel==1.5.5 + python -m pip install cibuildwheel==1.7.1 - name: Build wheels env: CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && rpm -i cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && yum clean all && yum -y install cuda-10-1 && yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm" diff --git a/.github/workflows/tests_linux.yml b/.github/workflows/tests_linux.yml index ccb2523f74..28387c7d31 100644 --- a/.github/workflows/tests_linux.yml +++ b/.github/workflows/tests_linux.yml @@ -42,7 +42,7 @@ jobs: needs: ["lint"] strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.6, 3.7, 3.8, 3.9] platform: [ { os: "ubuntu-latest", python-architecture: "x64" }, ] @@ -86,7 +86,7 @@ jobs: timeout-minutes: 25 strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.6, 3.7, 3.8, 3.9] os: ["ubuntu-latest"] env: AER_THRUST_BACKEND: OMP diff --git a/.github/workflows/tests_mac.yml b/.github/workflows/tests_mac.yml index 44045d0b74..5d7b2e4d70 100644 --- a/.github/workflows/tests_mac.yml +++ b/.github/workflows/tests_mac.yml @@ -42,7 +42,7 @@ jobs: needs: ["lint"] strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.6, 3.7, 3.8, 3.9] platform: [ { os: "macOS-latest", python-architecture: "x64"}, ] @@ -80,7 +80,7 @@ jobs: timeout-minutes: 25 strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.6, 3.7, 3.8, 3.9] os: ["macOS-latest"] env: AER_THRUST_BACKEND: OMP diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml index 4e1a8e01d4..3b95d868ea 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows.yml @@ -43,7 +43,7 @@ jobs: timeout-minutes: 25 strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.6, 3.7, 3.8, 3.9] os: ["windows-latest"] env: AER_THRUST_BACKEND: OMP diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1f1f7b4299..86694d3d63 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -140,6 +140,8 @@ stages: python.version: '3.7' Python38: python.version: '3.8' + Python39: + python.version: '3.9' variables: PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip steps: @@ -229,6 +231,8 @@ stages: python.version: '3.7' Python38: python.version: '3.8' + Python39: + python.version: '3.9' variables: PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip steps: diff --git a/releasenotes/notes/add-python3.9-83b3b4e5c3d59571.yaml b/releasenotes/notes/add-python3.9-83b3b4e5c3d59571.yaml new file mode 100644 index 0000000000..dd4629c5cf --- /dev/null +++ b/releasenotes/notes/add-python3.9-83b3b4e5c3d59571.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Python 3.9 support has been added in this release. You can now run Qiskit + Aer using Python 3.9 without building from source. +deprecations: + - | + Python 3.6 support has been deprecated and will be removed in a future + release. When support is removed you will need to upgrade the Python + version you're using to Python 3.7 or above. diff --git a/setup.py b/setup.py index f2f9faf87b..b71bd40de6 100644 --- a/setup.py +++ b/setup.py @@ -116,6 +116,7 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Topic :: Scientific/Engineering", ], python_requires=">=3.6", diff --git a/test/terra/common.py b/test/terra/common.py index 6ac7109c64..32071cc073 100644 --- a/test/terra/common.py +++ b/test/terra/common.py @@ -86,14 +86,6 @@ def _get_resource_path(filename, path=Path.TEST): """ return os.path.normpath(os.path.join(path.value, filename)) - def assertNoLogs(self, logger=None, level=None): - """ - Context manager to test that no message is sent to the specified - logger and level (the opposite of TestCase.assertLogs()). - """ - # pylint: disable=invalid-name - return _AssertNoLogsContext(self, logger, level) - def assertSuccess(self, result): """Assert that simulation executed without errors""" success = getattr(result, 'success', False) @@ -312,32 +304,6 @@ def assertDictAlmostEqual(self, dict1, dict2, delta=None, msg=None, raise self.failureException(msg) -class _AssertNoLogsContext(unittest.case._AssertLogsContext): - """A context manager used to implement TestCase.assertNoLogs().""" - - # pylint: disable=inconsistent-return-statements - def __exit__(self, exc_type, exc_value, tb): - """ - This is a modified version of TestCase._AssertLogsContext.__exit__(...) - """ - self.logger.handlers = self.old_handlers - self.logger.propagate = self.old_propagate - self.logger.setLevel(self.old_level) - if exc_type is not None: - # let unexpected exceptions pass through - return False - - if self.watcher.records: - msg = 'logs of level {} or higher triggered on {}:\n'.format( - logging.getLevelName(self.level), self.logger.name) - for record in self.watcher.records: - msg += 'logger %s %s:%i: %s\n' % (record.name, record.pathname, - record.lineno, - record.getMessage()) - - self._raiseFailure(msg) - - def _is_ci_fork_pull_request(): """ Check if the tests are being run in a CI environment and if it is a pull diff --git a/tox.ini b/tox.ini index 96f8d7dcb5..1145705ef6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 2.1 -envlist = py36, py37, py38, lint +envlist = py36, py37, py38, py39, lint skipsdist = True [testenv]