Skip to content

Commit

Permalink
Release v0.17.0 (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
airwoodix authored Sep 25, 2023
1 parent a0940bd commit 9069fd8
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 19 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
poetry run examples/run_all.sh -c
- name: Install all dependencies
run: poetry install --sync
- name: Check version numbers consistency
run: poetry run poe version_check
- name: Check formatting
run: poetry run poe format_check
- name: Linting
Expand All @@ -62,8 +64,8 @@ jobs:
with:
name: html-coverage
path: htmlcov/
- name: Generate XML coverage report
run: poetry run coverage xml -o coverage.xml
# - name: Generate XML coverage report
# run: poetry run coverage xml -o coverage.xml
# - name: Read global coverage target
# id: coverage-target
# run: echo "fail-under=$(poetry run python scripts/read-target-coverage.py)" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ jobs:
body_path: ${{ github.workspace }}-CHANGELOG.txt
- name: Publish to PyPI
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_USERNAME: __token__
run: twine upload dist/qiskit*
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## qiskit-aqt-provider v0.17.0

* Merge community and AQT versions (#61)

## qiskit-aqt-provider v0.16.0

* Make the access token optional (alpine-quantum-technologies/qiskit-aqt-provider-rc#80)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Qiskit AQT Provider

[![Latest release](https://img.shields.io/pypi/v/qiskit-aqt-provider-rc.svg)](https://pypi.python.org/pypi/qiskit-aqt-provider-rc)
[![License](https://img.shields.io/pypi/l/qiskit-aqt-provider-rc.svg)](https://pypi.python.org/pypi/qiskit-aqt-provider-rc)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/qiskit-aqt-provider-rc.svg)](https://pypi.python.org/pypi/qiskit-aqt-provider-rc)
![Build Status](https://github.com/alpine-quantum-technologies/qiskit-aqt-provider-rc/actions/workflows/poetry.yml/badge.svg?branch=master)
[![Latest release](https://img.shields.io/pypi/v/qiskit-aqt-provider.svg)](https://pypi.python.org/pypi/qiskit-aqt-provider)
[![License](https://img.shields.io/pypi/l/qiskit-aqt-provider.svg)](https://pypi.python.org/pypi/qiskit-aqt-provider)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/qiskit-aqt-provider.svg)](https://pypi.python.org/pypi/qiskit-aqt-provider)
![Build Status](https://github.com/alpine-quantum-technologies/qiskit-aqt-provider/actions/workflows/poetry.yml/badge.svg?branch=master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
Expand All @@ -15,4 +15,4 @@ systems.

## Usage

See the [user guide](https://github.com/alpine-quantum-technologies/qiskit-aqt-provider-internal/blob/master/docs/guide.rst) and the [examples](https://github.com/alpine-quantum-technologies/qiskit-aqt-provider-internal/tree/master/examples).
See the [user guide](https://github.com/qiskit-community/qiskit-aqt-provider/blob/master/docs/guide.rst) and the [examples](https://github.com/qiskit-community/qiskit-aqt-provider/tree/master/examples).
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
author = "Qiskit and AQT development teams"

# The short X.Y version
version = "0.5.0"
version = "0.17.0"
# The full version, including alpha/beta/rc tags
release = "0.5.0"
release = "0.17.0"

extensions = [
"sphinx.ext.napoleon",
Expand Down
60 changes: 57 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[tool.poetry]
name = "qiskit-aqt-provider-rc"
version = "0.16.0"
name = "qiskit-aqt-provider"
version = "0.17.0"
description = "Qiskit provider for AQT backends"
authors = ["Qiskit Development Team", "Alpine Quantum Technologies GmbH"]
repository = "https://github.com/alpine-quantum-technologies/qiskit-aqt-provider-rc/"
repository = "https://github.com/qiskit-community/qiskit-aqt-provider"
readme = "README.md"
license = "Apache-2.0"
classifiers=[
Expand Down Expand Up @@ -74,9 +74,11 @@ pytest-sugar = "^0.9.6"
qiskit-experiments = "^0.4.0"
qiskit-sphinx-theme = ">=1.7.0"
qiskit-terra = {version = ">=0.23.2", extras = ["visualization"]}
rich = "^13.5.3"
ruff = "^0.0.291"
sphinx = "^6"
sympy = "^1.11.1"
tomlkit = "^0.12.1"
typer = "^0.7.0"
types-requests = "^2.28.11"
types-setuptools = "^65.7.0"
Expand Down Expand Up @@ -246,5 +248,6 @@ shell = "ruff check ."
lint = ["check_api_models", "ruff_check"]
format_check = ["black_check", "pyprojectfmt_check"]
generate-models = "./scripts/api_models.py generate"
docs = "sphinx-build -b html -W docs docs/_build"
all = ["format_check", "lint", "typecheck", "test", "docs"]
version_check = "./scripts/package_version.py --verbose check"
docs = "sphinx-build -j auto -b html -W docs docs/_build"
all = ["version_check", "format_check", "lint", "typecheck", "test", "docs"]
2 changes: 1 addition & 1 deletion qiskit_aqt_provider/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import Final

QISKIT_TERRA_VERSION: Final = importlib.metadata.version("qiskit-terra")
QISKIT_AQT_PROVIDER_VERSION: Final = importlib.metadata.version("qiskit-aqt-provider-rc")
QISKIT_AQT_PROVIDER_VERSION: Final = importlib.metadata.version("qiskit-aqt-provider")

__version__: Final = QISKIT_AQT_PROVIDER_VERSION

Expand Down
169 changes: 169 additions & 0 deletions scripts/package_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/usr/bin/env python3

# This code is part of Qiskit.
#
# (C) Copyright Alpine Quantum Technologies GmbH 2023
#
# 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.

"""Utility script to update/check version numbers scattered across multiple files."""

import os
import re
from dataclasses import dataclass
from pathlib import Path
from typing import Final, Optional

import tomlkit
import typer
from rich.console import Console

DOCS_VERSION_REGEX: Final = re.compile(r'(version|release)\s=\s"(\d+\.\d+\.\d+)"')


@dataclass(frozen=True)
class CommonArgs:
pyproject_path: Path
docs_conf_path: Path
verbose: bool


def get_args(ctx: typer.Context) -> CommonArgs:
"""Typed getter for the common arguments stored in the typer context."""
args = ctx.obj
assert isinstance(args, CommonArgs) # noqa: S101
return args


if os.environ.get("CI"):
console = Console(force_terminal=True, force_interactive=False)
else:
console = Console()


app = typer.Typer()


def check_consistency(
pyproject_path: Path,
docs_conf_path: Path,
*,
verbose: bool,
target_version: Optional[str],
) -> bool:
"""Check that version numbers are consistent.
Args:
pyproject_path: path to the pyproject.toml file.
docs_conf_path: path to the Sphinx documentation configuration module.
verbose: whether to show the detail of the found version numbers.
target_version: if set, pass only if the detected version numbers are also
consistent with this target version.
Returns:
Whether the detected version number are consistent.
"""
pyproject = tomlkit.parse(pyproject_path.read_text(encoding="utf-8"))
pyproject_version = str(pyproject["tool"]["poetry"]["version"]) # type: ignore[index]

docs_conf = docs_conf_path.read_text(encoding="utf-8")

docs_version, docs_release = "", ""
for line in docs_conf.splitlines():
result = DOCS_VERSION_REGEX.match(line.strip())
if result:
if result.group(1) == "version":
docs_version = result.group(2)
if result.group(1) == "release":
docs_release = result.group(2)

if docs_version and docs_release:
break

if verbose:
if target_version is not None:
console.print(f"Target version: {target_version}")
console.print(f"{pyproject_path}: {pyproject_version}")
console.print(f"{docs_conf_path} (version): {docs_version or '[red]not found'}")
console.print(f"{docs_conf_path} (release): {docs_release or '[red]not found'}")

consistent = pyproject_version == docs_version == docs_release
if target_version is not None:
consistent = consistent and (pyproject_version == target_version)

if consistent:
console.print("[bold green]PASS")
return True

console.print("[bold red]FAIL")
return False


def bump_versions(pyproject_path: Path, docs_conf_path: Path, new_version: str) -> None:
"""Update version number to match a new target.
Args:
pyproject_path: path to the pyproject.toml file.
docs_conf_path: path to the Sphinx documentation configuration module.
new_version: target version to update to.
"""
pyproject = tomlkit.parse(pyproject_path.read_text(encoding="utf-8"))
pyproject["tool"]["poetry"]["version"] = new_version # type: ignore[index]
pyproject_path.write_text(tomlkit.dumps(pyproject), encoding="utf-8")

docs_conf = docs_conf_path.read_text(encoding="utf-8")
docs_conf = re.sub(r"version\s=\s\"(.*)\"", f'version = "{new_version}"', docs_conf)
docs_conf = re.sub(r"release\s=\s\"(.*)\"", f'release = "{new_version}"', docs_conf)
docs_conf_path.write_text(docs_conf, encoding="utf-8")


@app.command()
def check(ctx: typer.Context) -> None:
"""Check whether the package version numbers are consistent."""
args = get_args(ctx)
if not check_consistency(
args.pyproject_path,
args.docs_conf_path,
verbose=args.verbose,
target_version=None,
):
raise typer.Exit(1)


@app.command()
def bump(ctx: typer.Context, new_version: str) -> None:
"""Update the package version."""
args = get_args(ctx)

bump_versions(args.pyproject_path, args.docs_conf_path, new_version)

if not check_consistency(
args.pyproject_path,
args.docs_conf_path,
verbose=args.verbose,
target_version=new_version,
):
raise typer.Exit(1)


@app.callback()
def common_args(
ctx: typer.Context,
pyproject_path: Path = typer.Option(Path("pyproject.toml")),
docs_conf_path: Path = typer.Option(Path("docs/conf.py")),
verbose: bool = False,
) -> None:
"""Command line arguments shared between multiple sub-commands."""
ctx.obj = CommonArgs(
pyproject_path=pyproject_path, docs_conf_path=docs_conf_path, verbose=verbose
)


if __name__ == "__main__":
app()

0 comments on commit 9069fd8

Please sign in to comment.