Skip to content

Commit

Permalink
Replace qiskit metapackage with qiskit-terra
Browse files Browse the repository at this point in the history
This commit completely removes the concept of the `qiskit-terra` package
from Qiskit main.  The hitherto metapackage `qiskit` is promoted to be
the concrete code package.

This is a completely breaking change for packaging purposes for users,
as there is no clean upgrade path from `qiskit-terra` to `qiskit`; PyPI
and pip do not give us the tools to mark that the former obsoletes and
supersedes the latter.  We intend to follow this PR with a technical
blog post somewhere explaining the changes, how users should adapt
("to install Qiskit 1.0, you must start a new venv"), and why we needed
to do this.

The "why", in part, is:

- the metapackage legacy causes awkward upgrade paths on every release;
  some packages still depend on `qiskit-terra`, some on `qiskit`, and
  pip will happily make those two get out-of-sync when upgrading a
  transitive dependency with only a warning that users are used to
  ignoring.

- with the 1.0 release, we (believe we) will have some leeway from users
  to make such a breaking change.

- having the metapackage split makes it difficult for downstream
  projects and developers to test against `main` - they always must
  install both `qiskit-terra` and `qiskit`, and the latter has no
  meaning in editable installs, so needs re-installing after each
  version bump.  Problems surrounding this have already broken CI for
  Qiskit, for at least one internal IBM repo, and at least my dev
  install of Qiskit.  This could be improved a bit with more education,
  but it's still always going to increase the barrier to entry and make
  it much harder to do the right thing.

We will not publish any 1.0 or above version of `qiskit-terra`.  All
dependents on Qiskit should switch their requirements to `qiskit`.
  • Loading branch information
jakelishman committed Nov 24, 2023
1 parent 5a5c9e3 commit 541143e
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 130 deletions.
5 changes: 2 additions & 3 deletions .azure/lint-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
./qiskit_pkg \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
Expand All @@ -38,7 +37,7 @@ jobs:
set -e
source test-job/bin/activate
echo "Running black, any errors reported can be fixed with 'tox -eblack'"
black --check qiskit test tools examples setup.py qiskit_pkg
black --check qiskit test tools examples setup.py
echo "Running rustfmt check, any errors reported can be fixed with 'cargo fmt'"
cargo fmt --check
displayName: "Formatting"
Expand All @@ -47,7 +46,7 @@ jobs:
set -e
source test-job/bin/activate
echo "Running ruff"
ruff qiskit test tools examples setup.py qiskit_pkg/setup.py
ruff qiskit test tools examples setup.py
echo "Running pylint"
pylint -rn qiskit test tools
echo "Running Cargo Clippy"
Expand Down
4 changes: 1 addition & 3 deletions .azure/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ jobs:
python -m pip install -U pip
python -m pip install -U build
python -m build --sdist .
python -m build --sdist qiskit_pkg
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
dist/qiskit*.tar.gz
dist/qiskit-*.tar.gz
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
displayName: "Install Terra from sdist"
Expand All @@ -92,7 +91,6 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
./qiskit_pkg \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
Expand Down
1 change: 0 additions & 1 deletion .azure/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
./qiskit_pkg \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
Expand Down
1 change: 0 additions & 1 deletion .azure/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
./qiskit_pkg \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: python -m pip install -c constraints.txt --upgrade pip setuptools wheel

- name: Build and install qiskit-terra
run: python -m pip install -c constraints.txt -e . ./qiskit_pkg
run: python -m pip install -c constraints.txt -e .
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Cinstrument-coverage"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements.txt -c constraints.txt
python -m pip install -U -r requirements-dev.txt -c constraints.txt
python -m pip install -c constraints.txt -e . ./qiskit_pkg
python -m pip install -c constraints.txt -e .
python -m pip install "qiskit-aer" "z3-solver" "cplex" -c constraints.txt
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
Expand Down
30 changes: 1 addition & 29 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
with:
packages-dir: wheelhouse/
sdist:
name: Build and publish terra sdist
name: Build and publish sdist
runs-on: ${{ matrix.os }}
needs: ["upload_shared_wheels"]
environment: release
Expand All @@ -190,31 +190,3 @@ jobs:
run: python -m build . --sdist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
metapackage:
name: Build and publish terra sdist
runs-on: ${{ matrix.os }}
needs: ["sdist"]
environment: release
permissions:
id-token: write
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.10'
- name: Install deps
run: pip install -U twine setuptools-rust wheel build
- name: Build packages
run: |
set -e
cd qiskit_pkg
python -m build .
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: qiskit_pkg/dist
1 change: 0 additions & 1 deletion qiskit_pkg/LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion qiskit_pkg/MANIFEST.in

This file was deleted.

1 change: 0 additions & 1 deletion qiskit_pkg/README.md

This file was deleted.

74 changes: 0 additions & 74 deletions qiskit_pkg/setup.py

This file was deleted.

29 changes: 29 additions & 0 deletions releasenotes/notes/terra-nullius-7ef598626d8118c1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
critical:
- |
You cannot upgrade in place to Qiskit 1.0. You must begin a new virtual environment.
From Qiskit 1.0, Qiskit is comprised of exactly one Python package: ``qiskit``. Previously,
as a legacy of the "component elements" of early Qiskit, the ``qiskit`` package was a
dependency-only "metapackage", and the core code of Qiskit was in a package called ``qiskit-terra``.
As Qiskit grew, the other elements split off into their own packages (such as ``qiskit-aer``)
until only the core was left in the metapackage. For Qiskit 1.0, we are removing the metapackage
entirely, and replacing it with the actual Qiskit code.
This means that you cannot upgrade an existing installation to Qiskit 1.0. Instead, you must
create a new Python virtual environment. Using the built-in ``venv`` module, you can do (Linux
and Mac):
.. code-block:: bash
# Create the new environment (only once).
python -m venv ~/qiskit-1.0-venv
# Activate the environment (every session).
source ~/qiskit-1.0-venv/bin/activate
# Install Qiskit (only once).
pip install 'qiskit>=1.0'
On Windows, replace ``source <venv>/bin/activate`` with ``source <venv>/Scripts/activate``.
If you are a library author, or have code that depends on Qiskit, you should update any old
dependencies on ``qiskit-terra`` to instead depend on ``qiskit``.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@


setup(
name="qiskit-terra",
name="qiskit",
version="1.0.0",
description="Software for developing quantum computing programs",
long_description=README,
Expand Down
5 changes: 3 additions & 2 deletions tools/deploy_translatable_strings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ rm -rf \
echo "+ 'cp' wanted files from source to target"
# Copy the new rendered files and add them to the commit.
cp -r "$SOURCE_PO_DIR/." "$TARGET_PO_DIR"
# Copy files necessary to build the Qiskit metapackage.
cp "$SOURCE_REPO_ROOT/qiskit_pkg/setup.py" "${TARGET_REPO_ROOT}"
# Copy files necessary to build the Qiskit package.
cp "$SOURCE_REPO_ROOT/setup.py" "${TARGET_REPO_ROOT}"
cp "$SOURCE_REPO_ROOT/pyproject.toml" "${TARGET_REPO_ROOT}"
cat "$SOURCE_REPO_ROOT/requirements-dev.txt" "$SOURCE_REPO_ROOT/requirements-optional.txt" \
> "${TARGET_REPO_ROOT}/requirements-dev.txt"
cp "$SOURCE_REPO_ROOT/constraints.txt" "${TARGET_REPO_ROOT}"
Expand Down
16 changes: 5 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ envlist = py38, py39, py310, py311, py312, lint-incr
isolated_build = true

[testenv]
# We pretend that we're not actually installing the package, because we need tox to let us have two
# packages ('qiskit' and 'qiskit-terra') under test at the same time. For that, we have to stuff
# them into 'deps'.
skip_install = true
install_command = pip install -c{toxinidir}/constraints.txt -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
Expand All @@ -22,16 +18,14 @@ deps =
setuptools_rust # This is work around for the bug of tox 3 (see #8606 for more details.)
-r{toxinidir}/requirements.txt
-r{toxinidir}/requirements-dev.txt
-e .
-e ./qiskit_pkg
commands =
stestr run {posargs}

[testenv:lint]
basepython = python3
commands =
ruff check qiskit test tools examples setup.py qiskit_pkg
black --check {posargs} qiskit test tools examples setup.py qiskit_pkg
ruff check qiskit test tools examples setup.py
black --check {posargs} qiskit test tools examples setup.py
pylint -rn qiskit test tools
# This line is commented out until #6649 merges. We can't run this currently
# via tox because tox doesn't support globbing
Expand All @@ -45,8 +39,8 @@ commands =
basepython = python3
allowlist_externals = git
commands =
ruff check qiskit test tools examples setup.py qiskit_pkg
black --check {posargs} qiskit test tools examples setup.py qiskit_pkg
ruff check qiskit test tools examples setup.py
black --check {posargs} qiskit test tools examples setup.py
-git fetch -q https://github.com/Qiskit/qiskit-terra.git :lint_incr_latest
python {toxinidir}/tools/pylint_incr.py -rn -j4 -sn --paths :/qiskit/*.py :/test/*.py :/tools/*.py
python {toxinidir}/tools/pylint_incr.py -rn -j4 -sn --disable='invalid-name,missing-module-docstring,redefined-outer-name' --paths :(glob,top)examples/python/*.py
Expand All @@ -59,7 +53,7 @@ commands =
skip_install = true
deps =
-r requirements-dev.txt
commands = black {posargs} qiskit test tools examples setup.py qiskit_pkg
commands = black {posargs} qiskit test tools examples setup.py

[testenv:coverage]
basepython = python3
Expand Down

0 comments on commit 541143e

Please sign in to comment.