Skip to content

Commit

Permalink
feat: Drop support for Python 3.8, update dependencies (#1782)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: jselig-rigetti <97701976+jselig-rigetti@users.noreply.github.com>
  • Loading branch information
MarquessV and jselig-rigetti authored Jun 5, 2024
1 parent c78c5a9 commit c68174a
Show file tree
Hide file tree
Showing 120 changed files with 3,431 additions and 3,962 deletions.
53 changes: 34 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
Expand All @@ -33,10 +33,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
Expand All @@ -52,10 +52,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
Expand All @@ -71,10 +71,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
Expand All @@ -85,12 +85,27 @@ jobs:
. scripts/ci_install_deps
poetry run make check-types
check-dependencies:

name: Check dependencies for vulnerabilities
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v5
- name: Install OSV scanner
run: |
go install github.com/google/osv-scanner/cmd/osv-scanner@latest
- name: Run OSV scanner
run: |
osv-scanner --lockfile=./poetry.lock
test-doctest:
name: Run Doctests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-beta.1"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -118,7 +133,7 @@ jobs:
pull-requests: write # allows coverage bot to comment
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-beta.1"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -147,19 +162,19 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

check-docker-image:
name: Check types
name: Check docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: .venv
key: poetry-${{ hashFiles('poetry.lock') }}
- name: Check types
- name: Check wheel installation
run: |
sudo apt update
pip wheel . -w wheels
Expand All @@ -179,7 +194,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-beta.1"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
20 changes: 8 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,14 @@ poetry install

### Style Guidelines

We use [Black](https://black.readthedocs.io/en/stable/index.html) and `flake8` to automatically
lint the code and enforce style requirements as part of the CI pipeline. You can run these style
tests yourself locally by running `make check-style` (to check for violations of the `flake8` rules)
and `make check-format` (to see if `black` would reformat the code) in the top-level directory of
the repository. If you aren't presented with any errors, then that means your code is good enough
for the linter (`flake8`) and formatter (`black`). If `make check-format` fails, it will present
you with a diff, which you can resolve by running `make format`. Black is very opinionated, but
saves a lot of time by removing the need for style nitpicks in PR review. We only deviate from its
default behavior in one category: we choose to use a line length of 100 rather than the Black
default of 88 (this is configured in the [`pyproject.toml`](pyproject.toml) file). As for `flake8`,
we ignore a couple of its rules (all for good reasons), and the specific configuration can be
found in the [`.flake8`](.flake8) file.
We use [ruff](https://docs.astral.sh/ruff/) to enforce lint and formatting requirements as part of CI. You can run these
tests yourself locally by running `make check-style` (to check for violations of the linting rules)
and `make check-format` (to see if `ruff` would reformat the code) in the top-level directory of
the repository. If you aren't presented with any errors, then that means your code satisfies all
the linting and formatting requirements. If `make check-format` fails, it will present you with a
diff, which you can resolve by running `make format`. The ruff formatter is opinionated, but
saves a lot of time by removing the need for style nitpicks in PR review. The configuration for
`ruff` can be found in `pyproject.toml`.

In addition to linting and formatting, we use type hints for all parameters and return values,
following the [PEP 484 syntax][pep-484]. This is enforced as part of the CI via the command
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# use multi-stage builds to independently pull dependency versions
ARG quilc_version=1.20.0
ARG qvm_version=1.17.1
ARG python_version=3.8
ARG python_version=3.9

# use multi-stage builds to independently pull dependency versions
FROM rigetti/quilc:$quilc_version as quilc
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# use multi-stage builds to independently pull dependency versions
ARG quilc_version=1.20.0
ARG qvm_version=1.17.1
ARG python_version=3.8
ARG python_version=3.9

# use multi-stage builds to independently pull dependency versions
FROM rigetti/quilc:$quilc_version as quilc
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ check-all: check-format check-types check-style

.PHONY: check-format
check-format:
black --check --diff pyquil
ruff format --check --diff pyquil

.PHONY: check-types
check-types:
mypy pyquil

.PHONY: check-style
check-style:
flake8 pyquil
ruff check pyquil

.PHONY: clean
clean:
Expand Down Expand Up @@ -55,7 +55,7 @@ docker: Dockerfile

.PHONY: format
format:
black $(if $(format_file), $(format_file), pyquil)
ruff format $(if $(format_file), $(format_file), pyquil)

.PHONY: info
info:
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#

# You can set these variables from the command line.
SPHINXOPTS = -W # treat warnings as errors
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build
Expand Down
24 changes: 17 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import os
import subprocess

import sphinx_rtd_theme
from sphinx.ext.doctest import doctest
from pyquil import __version__

import subprocess
import os
from pyquil import __version__

project = "pyQuil"
copyright = "2021, Rigetti Computing"
Expand All @@ -37,7 +38,7 @@
"sphinx.ext.viewcode",
"sphinxcontrib.jquery",
"nbsphinx",
"recommonmark",
"myst_parser",
]

templates_path = ["_templates"]
Expand Down Expand Up @@ -119,7 +120,6 @@

dirname = os.path.dirname(__file__)


def builder_inited_handler(app):
import pandoc

Expand All @@ -129,16 +129,26 @@ def builder_inited_handler(app):
input = pandoc.read(source=None, file=infile, format="markdown")
pandoc.write(input, file=outfile, format="rst")

subprocess.call(
result = subprocess.run(
[
"sphinx-apidoc",
"--module-first",
"--force",
"--append-syspath",
"--separate",
f"--output-dir={dirname}/apidocs",
f"{dirname}/../../pyquil",
]
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
if result.returncode == 0:
print("sphinx-apidoc ran successfully.")
else:
print(f"sphinx-apidoc failed with return code {result.returncode}.")
print("STDOUT:", result.stdout)
print("STDERR:", result.stderr)


def setup(app):
Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ If you would like to stay up to date with the latest changes and bug fixes, you

.. note::

pyQuil requires Python 3.8 or later.
pyQuil requires Python 3.9 or later.

.. testcode:: verify-min-version
:hide:
Expand All @@ -58,7 +58,7 @@ If you would like to stay up to date with the latest changes and bug fixes, you
.. testoutput:: verify-min-version
:hide:

^3.8...
^3.9...

.. note::

Expand Down
5 changes: 0 additions & 5 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,3 @@ ignore_errors = True
# Ignore errors in the conftest.py file
[mypy-conftest]
ignore_errors = True

# Ignore errors in the pyquil/parser.py file
# TODO(notmgsk): Add types
[mypy-pyquil.parser]
ignore_errors = True
Loading

0 comments on commit c68174a

Please sign in to comment.