Skip to content

Commit 56140e2

Browse files
chalmerloweohmayr
authored andcommitted
updates noxfile, setup.cfg, and pyproject.toml versions and nox sessions
1 parent 888126b commit 56140e2

3 files changed

Lines changed: 101 additions & 6 deletions

File tree

packages/google-crc32c/noxfile.py

Lines changed: 98 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,30 @@
2424

2525
HERE = os.path.dirname(__file__)
2626

27-
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"])
27+
# Constants
28+
DEFAULT_PYTHON_VERSION = "3.14"
29+
UNIT_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
30+
ALL_PYTHON = list(UNIT_TEST_PYTHON_VERSIONS)
31+
ALL_PYTHON.extend(["3.7"])
32+
33+
FLAKE8_VERSION = "flake8==6.1.0"
34+
BLACK_VERSION = "black[jupyter]==23.7.0"
35+
ISORT_VERSION = "isort==5.11.0"
36+
LINT_PATHS = ["src", "tests", "noxfile.py", "setup.py"]
37+
38+
nox.options.sessions = [
39+
"build_libcrc32c",
40+
"check",
41+
"lint",
42+
"blacken",
43+
"format",
44+
"lint_setup_py",
45+
"mypy",
46+
"prerelease_deps",
47+
"core_deps_from_source",
48+
]
49+
50+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
2851
def build_libcrc32c(session):
2952
session.env["PY_BIN"] = f"python{session.python}"
3053
session.env["REPO_ROOT"] = HERE
@@ -39,7 +62,7 @@ def build_libcrc32c(session):
3962
raise Exception("Unsupported")
4063

4164

42-
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"])
65+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
4366
def check(session):
4467
session.install("pytest")
4568
session.install("--no-index", f"--find-links={HERE}/wheels", "google-crc32c")
@@ -49,7 +72,7 @@ def check(session):
4972
session.run("python", f"{HERE}/scripts/check_crc32c_extension.py", *session.posargs)
5073

5174

52-
@nox.session(python="3.13")
75+
@nox.session(python=DEFAULT_PYTHON_VERSION)
5376
def mypy(session):
5477
"""Verify type hints are mypy compatible."""
5578
session.install(
@@ -58,4 +81,75 @@ def mypy(session):
5881
"types-setuptools",
5982
)
6083
session.env["MYPYPATH"] = "src"
61-
session.run("mypy", "src/google_crc32c/", "tests/")
84+
session.run("mypy", "src/google_crc32c/", "tests/")
85+
86+
87+
@nox.session(python=DEFAULT_PYTHON_VERSION)
88+
def lint(session):
89+
"""Run linters.
90+
91+
Returns a failure if the linters find linting errors or sufficiently
92+
serious code quality issues.
93+
"""
94+
session.install(FLAKE8_VERSION, BLACK_VERSION)
95+
session.run(
96+
"black",
97+
"--check",
98+
*LINT_PATHS,
99+
)
100+
session.run("flake8", *LINT_PATHS)
101+
102+
103+
@nox.session(python=DEFAULT_PYTHON_VERSION)
104+
def blacken(session):
105+
"""Run black. Format code to uniform standard."""
106+
session.install(BLACK_VERSION)
107+
session.run(
108+
"black",
109+
*LINT_PATHS,
110+
)
111+
112+
113+
@nox.session(python=DEFAULT_PYTHON_VERSION)
114+
def format(session):
115+
"""
116+
Run isort to sort imports. Then run black
117+
to format code to uniform standard.
118+
"""
119+
session.install(BLACK_VERSION, ISORT_VERSION)
120+
# Use the --fss option to sort imports using strict alphabetical order.
121+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
122+
session.run(
123+
"isort",
124+
"--fss",
125+
*LINT_PATHS,
126+
)
127+
session.run(
128+
"black",
129+
*LINT_PATHS,
130+
)
131+
132+
133+
@nox.session(python=DEFAULT_PYTHON_VERSION)
134+
def lint_setup_py(session):
135+
"""Verify that setup.py is valid (including RST check)."""
136+
session.install("docutils", "pygments", "setuptools")
137+
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
138+
139+
140+
@nox.session(python=DEFAULT_PYTHON_VERSION)
141+
def prerelease_deps(session):
142+
"""Run all tests with prerelease versions of dependencies installed."""
143+
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
144+
# Add prerelease deps tests
145+
session.skip("prerelease deps tests are not yet supported")
146+
147+
148+
@nox.session(python=DEFAULT_PYTHON_VERSION)
149+
def core_deps_from_source(session):
150+
"""Run all tests with core dependencies installed from source
151+
rather than pulling the dependencies from PyPI.
152+
"""
153+
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
154+
# Add core deps from source tests
155+
session.skip("Core deps from source tests are not yet supported")

packages/google-crc32c/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ name = "google-crc32c"
2121
version = "1.8.0"
2222
description = "A python wrapper of the C library 'Google CRC32C'"
2323
readme = "README.md"
24-
requires-python = ">=3.9"
24+
requires-python = ">=3.8"

packages/google-crc32c/setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ classifiers =
2929
Intended Audience :: Developers
3030
Operating System :: OS Independent
3131
Programming Language :: Python :: 3
32+
Programming Language :: Python :: 3.8
3233
Programming Language :: Python :: 3.9
3334
Programming Language :: Python :: 3.10
3435
Programming Language :: Python :: 3.11
@@ -38,7 +39,7 @@ classifiers =
3839

3940
[options]
4041
zip_safe = True
41-
python_requires = >=3.9
42+
python_requires = >=3.8
4243

4344
[options.extras_require]
4445
testing = pytest

0 commit comments

Comments
 (0)