qiskit/setup.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

134 lines
4.4 KiB
Python
Raw Normal View History

# This code is part of Qiskit.
Revise travis configuration, using cmake * Revise the travis configuration for using `cmake` for the several targets, and use "stages" instead of parallel jobs: * define three stages that are executed if the previous one suceeds: 1. "linter and pure python test": executes the linter and a test without compiling the binaries, with the idea of providing quick feedback for PRs. 2. "test": launch the test, including the compilation of binaries, under GNU/Linux Python 3.6 and 3.6; and osx Python 3.6. 3. "deploy doc and pypi": for the stable branch, deploy the docs to the landing page, and when using a specific commit message, build the GNU/Linux and osx wheels, uploading them to test.pypi. * use yaml anchors and definitions to avoid repeating code (and working around travis limitations). * Modify the `cmake``configuration to accomodate the stages flow: * allow conditional creation of compilation and QA targets, mainly for saving some time in some jobs. * move the tests to `cmake/tests.cmake`. * Update the tests: * add a `requires_qe_access` decorator that retrieves QE_TOKEN and QE_URL and appends them to the parameters in an unified manner. * add an environment variable `SKIP_ONLINE_TESTS` that allows to skip the tests that need network access. * replace `TRAVIS_FORK_PULL_REQUEST` with the previous two mechanisms, adding support for AppVeyor as well. * fix a problem with matplotlib under osx headless, effectively skipping `test_visualization.py` during the travis osx jobs. * Move Sphinx to `requirements-dev.txt`.
2018-02-13 05:11:28 +08:00
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
Revise travis configuration, using cmake * Revise the travis configuration for using `cmake` for the several targets, and use "stages" instead of parallel jobs: * define three stages that are executed if the previous one suceeds: 1. "linter and pure python test": executes the linter and a test without compiling the binaries, with the idea of providing quick feedback for PRs. 2. "test": launch the test, including the compilation of binaries, under GNU/Linux Python 3.6 and 3.6; and osx Python 3.6. 3. "deploy doc and pypi": for the stable branch, deploy the docs to the landing page, and when using a specific commit message, build the GNU/Linux and osx wheels, uploading them to test.pypi. * use yaml anchors and definitions to avoid repeating code (and working around travis limitations). * Modify the `cmake``configuration to accomodate the stages flow: * allow conditional creation of compilation and QA targets, mainly for saving some time in some jobs. * move the tests to `cmake/tests.cmake`. * Update the tests: * add a `requires_qe_access` decorator that retrieves QE_TOKEN and QE_URL and appends them to the parameters in an unified manner. * add an environment variable `SKIP_ONLINE_TESTS` that allows to skip the tests that need network access. * replace `TRAVIS_FORK_PULL_REQUEST` with the previous two mechanisms, adding support for AppVeyor as well. * fix a problem with matplotlib under osx headless, effectively skipping `test_visualization.py` during the travis osx jobs. * Move Sphinx to `requirements-dev.txt`.
2018-02-13 05:11:28 +08:00
"The Qiskit Terra setup file."
import os
import re
import sys
from setuptools import setup, find_packages, Extension
try:
from Cython.Build import cythonize
except ImportError:
import subprocess
subprocess.call([sys.executable, "-m", "pip", "install", "Cython>=0.27.1"])
from Cython.Build import cythonize
with open("requirements.txt") as f:
REQUIREMENTS = f.read().splitlines()
# Add Cython extensions here
CYTHON_EXTS = {
"qiskit/transpiler/passes/routing/cython/stochastic_swap/utils": (
"qiskit.transpiler.passes.routing.cython.stochastic_swap.utils"
),
"qiskit/transpiler/passes/routing/cython/stochastic_swap/swap_trial": (
"qiskit.transpiler.passes.routing.cython.stochastic_swap.swap_trial"
),
"qiskit/quantum_info/states/cython/exp_value": "qiskit.quantum_info.states.cython.exp_value",
}
INCLUDE_DIRS = []
# Extra link args
LINK_FLAGS = []
# If on Win and not in MSYS2 (i.e. Visual studio compile)
if sys.platform == "win32" and os.environ.get("MSYSTEM") is None:
COMPILER_FLAGS = ["/O2"]
# Everything else
else:
COMPILER_FLAGS = ["-O2", "-funroll-loops", "-std=c++11"]
if sys.platform == "darwin":
# These are needed for compiling on OSX 10.14+
COMPILER_FLAGS.append("-mmacosx-version-min=10.9")
LINK_FLAGS.append("-mmacosx-version-min=10.9")
EXT_MODULES = []
# Add Cython Extensions
for src, module in CYTHON_EXTS.items():
ext = Extension(
module,
sources=[src + ".pyx"],
include_dirs=INCLUDE_DIRS,
extra_compile_args=COMPILER_FLAGS,
extra_link_args=LINK_FLAGS,
language="c++",
)
EXT_MODULES.append(ext)
# Read long description from README.
README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), "README.md")
with open(README_PATH) as readme_file:
README = re.sub(
"<!--- long-description-skip-begin -->.*<!--- long-description-skip-end -->",
"",
readme_file.read(),
flags=re.S | re.M,
)
setup(
name="qiskit-terra",
version="0.18.0",
description="Software for developing quantum computing programs",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/Qiskit/qiskit-terra",
author="Qiskit Development Team",
2020-09-16 03:52:41 +08:00
author_email="hello@qiskit.org",
license="Apache 2.0",
classifiers=[
"Environment :: Console",
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
Add python 3.8 support and deprecate python 3.5 (#3268) * Add python 3.8 support and deprecate python 3.5 This commit adds support for running terra under python 3.8. It does this by adding the trove classifiers to the package metadata and adding a test job for python 3.8 (only travis for now this can be expanded in the future when azure pipelines adds it to their image). At the same time this commit starts the deprecation window for python 3.5. Python 3.5 goes end of life by upstream python in Sept. 2020. We should give our users running with python 3.5 (which is about 10% of our users based on pypi data) fair notice that when upstream python stops supporting it we do as well. * Fix lint * Add back empty cache detection As part of the refactors the empty stestr timing cache removal code was removed from the travis config, but the cache wasn't removed. Adding the python 3.8 job causes a failure because travis has no cached timing data but still creates the empty directory which triggers mtreinish/stestr#266. This adds back the empty cache removal to workaround it so we can use the timing data for scheduling in future runs. * Add azure-pipelines python 3.8 jobs too * Fix python 3.8 dictionary keys changed error Starting in python 3.8 a new RuntimeError is raised, RuntimeError: dictionary keys changed during iteration. This is caused by modifying an iterator while looping over it. We were doing that in the optimize_swap_before_measure pass. This commit fixes this by wrapping the iterator in list() to make a copy of it for looping. This way we don't modify the contents of what we're iterating over in the pass. * Revert "Add azure-pipelines python 3.8 jobs too" The missing matplotlib wheels are blockers for windows and osx environment. Since we do not have the necessary dependencies installed in those ci envs to compile matplotlib from source. We'll rely on just travis for 3.8 testing until the matplotlib 3.2.0 release is pushed so we don't have to compile it. This reverts commit 40157621b135a03b291b93e5d9b801237a14c015. * Add skip for failing matplotlib test The image comparison tests which are quite flaky are failing with matplotlib compiled on 3.8. Looking at the image output from these failures are very subtle (looks like resolution differences) again questioning the value of these tests. This commit just skips the test that is failing here to unblock the PR. * Add azure 3.8 test jobs * Pin to pre-release mpl for python 3.8 * Add spawn guard for python3.8 osx in examples When running examples with execute, transpile, or any other calls using parallel_map() the new default for spawn instead of fork requires that scripts have a __name__ == "__main__" check in them to function properly. If not calls to parallel_map fail errors around the bootstrapping phase. To avoid this in the ci jobs this commit adds the necessary checks to the example scripts we run in ci as part of test_examples. * Remove cryptography pin from constraints file We pinned the cryptography package version back during the cryptography 2.6 release which broke our ci. It was a temporary step to avoid a packaging issue in CI that was blocking development. However, when the issue was resolved we never circled back to fix the issue. Now trying to enable python 3.8 support to terra cryptography >=2.8 is needed for python 3.8 on windows (to get a precompiled binary). This commit removes the unecessary pin to unblock windows 3.8 ci. * Bump cibuildwheel version to build 3.8 wheels cibuildwheel 1.0.0 was released in early November [1] and added support for building python 3.8 wheels. This commit bumps the cibuildwheel version we use in the wheel build jobs at release time to also build 3.8 wheels for upload to pypi. * Add skip and release note about macos py38 issues This commit adds a skip for the failing python 3.8 test on osx and windows so that we don't block everything over a small issue in the tests. It also add a release note documenting the limitation with python 3.8 on macos with regardess to parallel_map/multiprocessing. Since this limitation is new for this release (being the first release with python 3.8 support) we should document it as a known issue in the release notes, especially since it likely won't be resolved until a python 3.8.1 release. * Revert "Add spawn guard for python3.8 osx in examples" While we can fix the tests to work on osx python3.8 by adjusting the example scripts to only call functions using parallel_map from inside a block run via if __name__ == '__main__': this unecessarily changes the scripts for the quirks of a single environment. This commit reverts the example scripts back to their original form and instead just skips the unittest that executes them on python 3.8 macOS. We already have documented this limitation in the release notes. When/if we have an alternative solution for how we launch additional processes in python 3.8 on macOS that does not require this workaround we can look at removing the skip. This reverts commit 76ae197631247f5b18eb322b1482da9b31d5391b. * Apply suggestions from code review Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>
2019-12-11 04:43:58 +08:00
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
Add python 3.8 support and deprecate python 3.5 (#3268) * Add python 3.8 support and deprecate python 3.5 This commit adds support for running terra under python 3.8. It does this by adding the trove classifiers to the package metadata and adding a test job for python 3.8 (only travis for now this can be expanded in the future when azure pipelines adds it to their image). At the same time this commit starts the deprecation window for python 3.5. Python 3.5 goes end of life by upstream python in Sept. 2020. We should give our users running with python 3.5 (which is about 10% of our users based on pypi data) fair notice that when upstream python stops supporting it we do as well. * Fix lint * Add back empty cache detection As part of the refactors the empty stestr timing cache removal code was removed from the travis config, but the cache wasn't removed. Adding the python 3.8 job causes a failure because travis has no cached timing data but still creates the empty directory which triggers mtreinish/stestr#266. This adds back the empty cache removal to workaround it so we can use the timing data for scheduling in future runs. * Add azure-pipelines python 3.8 jobs too * Fix python 3.8 dictionary keys changed error Starting in python 3.8 a new RuntimeError is raised, RuntimeError: dictionary keys changed during iteration. This is caused by modifying an iterator while looping over it. We were doing that in the optimize_swap_before_measure pass. This commit fixes this by wrapping the iterator in list() to make a copy of it for looping. This way we don't modify the contents of what we're iterating over in the pass. * Revert "Add azure-pipelines python 3.8 jobs too" The missing matplotlib wheels are blockers for windows and osx environment. Since we do not have the necessary dependencies installed in those ci envs to compile matplotlib from source. We'll rely on just travis for 3.8 testing until the matplotlib 3.2.0 release is pushed so we don't have to compile it. This reverts commit 40157621b135a03b291b93e5d9b801237a14c015. * Add skip for failing matplotlib test The image comparison tests which are quite flaky are failing with matplotlib compiled on 3.8. Looking at the image output from these failures are very subtle (looks like resolution differences) again questioning the value of these tests. This commit just skips the test that is failing here to unblock the PR. * Add azure 3.8 test jobs * Pin to pre-release mpl for python 3.8 * Add spawn guard for python3.8 osx in examples When running examples with execute, transpile, or any other calls using parallel_map() the new default for spawn instead of fork requires that scripts have a __name__ == "__main__" check in them to function properly. If not calls to parallel_map fail errors around the bootstrapping phase. To avoid this in the ci jobs this commit adds the necessary checks to the example scripts we run in ci as part of test_examples. * Remove cryptography pin from constraints file We pinned the cryptography package version back during the cryptography 2.6 release which broke our ci. It was a temporary step to avoid a packaging issue in CI that was blocking development. However, when the issue was resolved we never circled back to fix the issue. Now trying to enable python 3.8 support to terra cryptography >=2.8 is needed for python 3.8 on windows (to get a precompiled binary). This commit removes the unecessary pin to unblock windows 3.8 ci. * Bump cibuildwheel version to build 3.8 wheels cibuildwheel 1.0.0 was released in early November [1] and added support for building python 3.8 wheels. This commit bumps the cibuildwheel version we use in the wheel build jobs at release time to also build 3.8 wheels for upload to pypi. * Add skip and release note about macos py38 issues This commit adds a skip for the failing python 3.8 test on osx and windows so that we don't block everything over a small issue in the tests. It also add a release note documenting the limitation with python 3.8 on macos with regardess to parallel_map/multiprocessing. Since this limitation is new for this release (being the first release with python 3.8 support) we should document it as a known issue in the release notes, especially since it likely won't be resolved until a python 3.8.1 release. * Revert "Add spawn guard for python3.8 osx in examples" While we can fix the tests to work on osx python3.8 by adjusting the example scripts to only call functions using parallel_map from inside a block run via if __name__ == '__main__': this unecessarily changes the scripts for the quirks of a single environment. This commit reverts the example scripts back to their original form and instead just skips the unittest that executes them on python 3.8 macOS. We already have documented this limitation in the release notes. When/if we have an alternative solution for how we launch additional processes in python 3.8 on macOS that does not require this workaround we can look at removing the skip. This reverts commit 76ae197631247f5b18eb322b1482da9b31d5391b. * Apply suggestions from code review Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>
2019-12-11 04:43:58 +08:00
"Programming Language :: Python :: 3.8",
Add support for Python 3.9 (#5189) * Add support for Python 3.9 Python 3.9.0 was released on 10-05-2020, this commits marks the support of Python 3.9 in qiskit-terra. It adds the supported python version in the package metadata and updates the CI configuration to run test jobs on Python 3.9 and build python 3.9 wheels. * Also deprecate 3.6 * Use latest nodes for CI * Remove Python 3.6 deprecation The Python 3.6 deprecation is being handled separately in #5301 to decouple it from adding python 3.9 support. This commit removes the 3.6 deprecation accordingly. * Bump cibuildwheel version to the latest release * 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 (not just terra). Since the implementation is not sound and nothing uses it this commit just removes the class and method. * Fix lint * Remove aer from macOS and windows jobs * Remove IBMQ provider from ci jobs The ibmq provider is not used by anything in CI anymore. It was an historical artifact when some of the visualization and jupyter tests required it. This is no longer true. However, installing the ibmq provider in the linux 3.9 job is blocking CI because of an unrelated requests library issue with urllib3. To resolve this, this commit just removes the unecessary install. * Add back ibmqprovider to tutorials job, it's needed for aqua tutorials * Fix jupyter test skip * Update test/python/tools/jupyter/test_notebooks.py Co-authored-by: Christian Clauss <cclauss@me.com> * Fix lint * Add back pbars macOS test skip Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-12-02 12:51:32 +08:00
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering",
],
keywords="qiskit sdk quantum",
packages=find_packages(exclude=["test*"]),
install_requires=REQUIREMENTS,
setup_requires=["Cython>=0.27.1"],
include_package_data=True,
python_requires=">=3.6",
extras_require={
"visualization": [
"matplotlib>=2.1",
"ipywidgets>=7.3.0",
"pydot",
"pillow>=4.2.1",
"pylatexenc>=1.4",
"seaborn>=0.9.0",
"pygments>=2.4",
],
"classical-function-compiler": ["tweedledum>=1.0,<2.0"],
"full-featured-simulators": ["qiskit-aer>=0.1"],
"crosstalk-pass": ["z3-solver>=4.7"],
BIP mapping pass (#6580) * wip: initial move * fix a bug when no coupling_map is supplied * Improved documentation and parameter settings * Improved logical/physical qubit mapping * Better handling of measurements and final layout * minor fixes * add unit tests * wip: start refactoring * improve layout handling * simplify dag construction and fix to output all ops * fix to work with ApplyLayout * focus on layout+routing * improve how to call MIPMapping * simplify the spec * add an error handling * fix how to call MIPMapping pass * update user warning for change of given layout * wip: refactor mip model * improve top-level interface * return original dag if fails to solve MIP * minor fixes * care the case no cplex is installed * fix not to ignore swaps in original layers * fix mismatch in layer and su4layer indices * simplify by focusing only on depth objective * rename MIP to BIP * lint lint lint lint * improve interface around dummy steps * improve error message when cplex fails * restore level3 preset passmanager * improve depth objective * Rework optional dependency and add test configuration This commit reworks the logic around the optional dependency on cplex. The pass despite raising an exception if cplex wasn't installed was unconditionally trying to import cplex from the model module at import time. To avoid failures from that this adds a try block around the actual cplex usage in the model module and exports whether it's available or not. At the same time this is leveraged to add a skip condition on the tests so we only run them if cplex is installed. Then to run tests in CI we install cplex in the linux 3.7 job so we at least run it in one environment. It's not available in all our supported environments so getting full coverage in every env is not worth trying for, so just testing the qiskit portion works is enough. * Fix lint * Fix test, lint and logging * Fix lint and test, update docstring * Fix docstring and improve performance taking the risk of failing to map * Update docstring * Replace cplex.Cplex with docplex.mp.model.Model to improve readability Replace cplex.Cplex with docplex.mp.model.Model to improve readability fix requiring docplex version move docplex to requirements-dev * Improve BIPMappingModel interface simplify and improve docstring Improve BIPMappingModel interface * Update qiskit/transpiler/passes/routing/algorithms/bip_model.py Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com> * Fix docplex dependency * fix unnecessary-comprehension * lint * lint * update how to set cplex params and remove redundant constraints * skip unless docplex * fix a bug in arg threads * remove python version restriction * Change spec to require the number of virtual and physical qubits are the same * Update to use 'requires' to require precondition passes * Update qiskit/transpiler/passes/routing/algorithms/bip_model.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * lint * Add release note Add release note fix typos * Update docstring Update docstring fix typo * Improve error handling * Change to return mapped dag for circuits with only 1q-gates * Revert the spec change in the case of only 1q-gates * Update releasenotes/notes/add-bip-mapper-f729f2c5672d7f3e.yaml Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Update releasenotes/notes/add-bip-mapper-f729f2c5672d7f3e.yaml Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Update qiskit/transpiler/passes/routing/bip_mapping.py Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Update qiskit/transpiler/passes/routing/bip_mapping.py Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Update qiskit/transpiler/passes/routing/bip_mapping.py Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Update qiskit/transpiler/passes/routing/bip_mapping.py Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: Giacomo Nannicini <gnannicini@users.noreply.github.com> Co-authored-by: Giacomo Nannicini <giacomo.n@gmail.com> Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-01 14:29:40 +08:00
"bip-mapper": ["cplex", "docplex"],
},
project_urls={
"Bug Tracker": "https://github.com/Qiskit/qiskit-terra/issues",
"Documentation": "https://qiskit.org/documentation/",
"Source Code": "https://github.com/Qiskit/qiskit-terra",
},
ext_modules=cythonize(EXT_MODULES),
zip_safe=False,
)