Skip to content

Commit 3d5a759

Browse files
authored
Switch from tox to nox (#1436)
1 parent 19e71e9 commit 3d5a759

File tree

6 files changed

+138
-121
lines changed

6 files changed

+138
-121
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,54 @@ jobs:
1111
matrix:
1212
PYTHON:
1313
# Base builds
14-
- {VERSION: "3.7", TOXENV: "py37"}
15-
- {VERSION: "3.8", TOXENV: "py38"}
16-
- {VERSION: "3.9", TOXENV: "py39"}
17-
- {VERSION: "3.10", TOXENV: "py310"}
18-
- {VERSION: "3.11", TOXENV: "py311"}
19-
- {VERSION: "3.12", TOXENV: "py312"}
20-
- {VERSION: "3.13-dev", TOXENV: "py313"}
21-
- {VERSION: "pypy-3.9", TOXENV: "pypy3"}
22-
- {VERSION: "pypy-3.10", TOXENV: "pypy3"}
23-
- {VERSION: "3.11", TOXENV: "py311-useWheel", OS: "windows-2022" }
24-
# -cryptographyMain
25-
- {VERSION: "3.8", TOXENV: "py38-cryptographyMain"}
26-
- {VERSION: "3.9", TOXENV: "py39-cryptographyMain"}
27-
- {VERSION: "3.10", TOXENV: "py310-cryptographyMain"}
28-
- {VERSION: "3.11", TOXENV: "py311-cryptographyMain"}
29-
- {VERSION: "3.12", TOXENV: "py312-cryptographyMain"}
30-
- {VERSION: "3.13-dev", TOXENV: "py313-cryptographyMain"}
31-
- {VERSION: "pypy-3.9", TOXENV: "pypy3-cryptographyMain"}
32-
- {VERSION: "pypy-3.10", TOXENV: "pypy3-cryptographyMain"}
33-
# -cryptographyMinimum
34-
- {VERSION: "3.7", TOXENV: "py37-cryptographyMinimum"}
35-
- {VERSION: "3.8", TOXENV: "py38-cryptographyMinimum"}
36-
- {VERSION: "3.9", TOXENV: "py39-cryptographyMinimum"}
37-
- {VERSION: "3.10", TOXENV: "py310-cryptographyMinimum"}
38-
- {VERSION: "3.11", TOXENV: "py311-cryptographyMinimum"}
39-
- {VERSION: "3.12", TOXENV: "py312-cryptographyMinimum"}
40-
- {VERSION: "3.13-dev", TOXENV: "py313-cryptographyMinimum"}
41-
- {VERSION: "pypy-3.10", TOXENV: "pypy3-cryptographyMinimum"}
14+
- {VERSION: "3.7", NOXSESSION: "tests"}
15+
- {VERSION: "3.8", NOXSESSION: "tests"}
16+
- {VERSION: "3.9", NOXSESSION: "tests"}
17+
- {VERSION: "3.10", NOXSESSION: "tests"}
18+
- {VERSION: "3.11", NOXSESSION: "tests"}
19+
- {VERSION: "3.12", NOXSESSION: "tests"}
20+
- {VERSION: "3.13-dev", NOXSESSION: "tests"}
21+
- {VERSION: "pypy-3.9", NOXSESSION: "tests"}
22+
- {VERSION: "pypy-3.10", NOXSESSION: "tests"}
23+
- {VERSION: "3.11", NOXSESSION: "tests-wheel", OS: "windows-2022"}
24+
# -cryptography-main
25+
- {VERSION: "3.8", NOXSESSION: "tests-cryptography-main"}
26+
- {VERSION: "3.9", NOXSESSION: "tests-cryptography-main"}
27+
- {VERSION: "3.10", NOXSESSION: "tests-cryptography-main"}
28+
- {VERSION: "3.11", NOXSESSION: "tests-cryptography-main"}
29+
- {VERSION: "3.12", NOXSESSION: "tests-cryptography-main"}
30+
- {VERSION: "3.13-dev", NOXSESSION: "tests-cryptography-main"}
31+
- {VERSION: "pypy-3.9", NOXSESSION: "tests-cryptography-main"}
32+
- {VERSION: "pypy-3.10", NOXSESSION: "tests-cryptography-main"}
33+
# -cryptography-minimum
34+
- {VERSION: "3.7", NOXSESSION: "tests-cryptography-minimum"}
35+
- {VERSION: "3.8", NOXSESSION: "tests-cryptography-minimum"}
36+
- {VERSION: "3.9", NOXSESSION: "tests-cryptography-minimum"}
37+
- {VERSION: "3.10", NOXSESSION: "tests-cryptography-minimum"}
38+
- {VERSION: "3.11", NOXSESSION: "tests-cryptography-minimum"}
39+
- {VERSION: "3.12", NOXSESSION: "tests-cryptography-minimum"}
40+
- {VERSION: "3.13-dev", NOXSESSION: "tests-cryptography-minimum"}
41+
- {VERSION: "pypy-3.10", NOXSESSION: "tests-cryptography-minimum"}
4242
# Cryptography wheels
43-
- {VERSION: "3.9", TOXENV: "py39-cryptographyMinimum-useWheel"}
44-
- {VERSION: "3.9", TOXENV: "py39-useWheel"}
43+
- {VERSION: "3.9", NOXSESSION: "tests-cryptography-minimum-wheel"}
44+
- {VERSION: "3.9", NOXSESSION: "tests-wheel"}
4545
# Random order
46-
- {VERSION: "3.9", TOXENV: "py39-randomorder"}
46+
- {VERSION: "3.9", NOXSESSION: "tests-random-order"}
4747
# Meta
48-
- {VERSION: "3.9", TOXENV: "check-manifest"}
49-
- {VERSION: "3.11", TOXENV: "lint"}
50-
- {VERSION: "3.13", TOXENV: "py313-mypy"}
51-
- {VERSION: "3.9", TOXENV: "docs"}
52-
name: "${{ matrix.PYTHON.TOXENV }}${{ matrix.PYTHON.OS && format(' on {0}', matrix.PYTHON.OS) || '' }}"
48+
- {VERSION: "3.9", NOXSESSION: "check-manifest"}
49+
- {VERSION: "3.11", NOXSESSION: "lint"}
50+
- {VERSION: "3.13", NOXSESSION: "mypy"}
51+
- {VERSION: "3.9", NOXSESSION: "docs"}
5352
steps:
5453
- uses: actions/checkout@v4
5554
- name: Setup python
5655
uses: actions/setup-python@v5
5756
with:
5857
python-version: ${{ matrix.PYTHON.VERSION }}
59-
- run: python -m pip install tox
60-
- run: tox -v
58+
- run: python -m pip install nox
59+
- run: nox
6160
env:
62-
TOXENV: ${{ matrix.PYTHON.TOXENV }}
61+
NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }}
6362
- uses: ./.github/actions/upload-coverage
6463

6564
linux-docker:
@@ -69,16 +68,16 @@ jobs:
6968
fail-fast: false
7069
matrix:
7170
TEST:
72-
# cryptographyMain used since there's no wheel
73-
- {CONTAINER: "ubuntu-rolling", TOXENV: "py313-cryptographyMain"}
74-
name: "${{ matrix.TEST.TOXENV }} on ${{ matrix.TEST.CONTAINER }}"
71+
# cryptography-main used since there's no wheel
72+
- {CONTAINER: "ubuntu-rolling", NOXSESSION: "tests-cryptography-main"}
73+
name: "${{ matrix.TEST.NOXSESSION }} on ${{ matrix.TEST.CONTAINER }}"
7574
steps:
7675
- uses: actions/checkout@v4
77-
- run: /venv/bin/pip install tox
78-
- run: /venv/bin/tox -v
76+
- run: /venv/bin/pip install nox
77+
- run: /venv/bin/nox
7978
env:
80-
TOXENV: ${{ matrix.TEST.TOXENV }}
8179
RUSTUP_HOME: /root/.rustup
80+
NOXSESSION: ${{ matrix.TEST.NOXSESSION }}
8281
- uses: ./.github/actions/upload-coverage
8382

8483
linux-downstream:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dist
44
*.pyc
55
*.pyo
66
__pycache__
7-
.tox
7+
.nox
88
doc/_build/
99
.coverage*
1010
.eggs

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include LICENSE MANIFEST.in *.rst tox.ini .coveragerc src/OpenSSL/py.typed
1+
include LICENSE MANIFEST.in *.rst noxfile.py .coveragerc src/OpenSSL/py.typed
22
exclude .readthedocs.yml mypy.ini
33
recursive-include tests *.py
44
recursive-include doc *

noxfile.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import nox
2+
3+
nox.options.reuse_existing_virtualenvs = True
4+
nox.options.default_venv_backend = "uv|virtualenv"
5+
6+
MINIMUM_CRYPTOGRAPHY_VERSION = "41.0.5"
7+
8+
9+
@nox.session
10+
@nox.session(name="tests-cryptography-main")
11+
@nox.session(name="tests-cryptography-minimum")
12+
@nox.session(name="tests-wheel")
13+
@nox.session(name="tests-cryptography-minimum-wheel")
14+
@nox.session(name="tests-random-order")
15+
def tests(session: nox.Session) -> None:
16+
cryptography_version = None
17+
use_wheel = False
18+
random_order = False
19+
20+
if "cryptography-main" in session.name:
21+
cryptography_version = "main"
22+
elif "cryptography-minimum" in session.name:
23+
cryptography_version = "minimum"
24+
25+
if "wheel" in session.name:
26+
use_wheel = True
27+
28+
if "random-order" in session.name:
29+
random_order = True
30+
31+
session.env.update(
32+
{
33+
"PIP_NO_BINARY": "" if use_wheel else "cryptography",
34+
}
35+
)
36+
37+
deps = ["coverage>=4.2"]
38+
39+
if cryptography_version == "minimum":
40+
deps.append(f"cryptography=={MINIMUM_CRYPTOGRAPHY_VERSION}")
41+
42+
if random_order:
43+
deps.append("pytest-randomly")
44+
45+
session.install(*deps)
46+
session.install("-e", ".[test]")
47+
if cryptography_version == "main":
48+
session.install("git+https://github.com/pyca/cryptography.git")
49+
50+
session.run("openssl", "version", external=True)
51+
session.run("coverage", "run", "--parallel", "-m", "OpenSSL.debug")
52+
session.run(
53+
"coverage", "run", "--parallel", "-m", "pytest", "-v", *session.posargs
54+
)
55+
56+
57+
@nox.session
58+
def lint(session: nox.Session) -> None:
59+
session.install("ruff")
60+
session.run("ruff", "check", ".")
61+
session.run("ruff", "format", "--check", ".")
62+
63+
64+
@nox.session
65+
def mypy(session: nox.Session) -> None:
66+
session.install("-e", ".[test]")
67+
session.install("mypy")
68+
session.run("mypy", "src/", "tests/")
69+
70+
71+
@nox.session(name="check-manifest")
72+
def check_manifest(session: nox.Session) -> None:
73+
session.install("check-manifest")
74+
session.run("check-manifest")
75+
76+
77+
@nox.session
78+
def docs(session: nox.Session) -> None:
79+
session.install("-e", ".[docs]")
80+
session.run(
81+
"sphinx-build",
82+
"-W",
83+
"-b",
84+
"html",
85+
"doc",
86+
"doc/_build/html",
87+
*session.posargs,
88+
)

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ source = ["OpenSSL", "tests/"]
66
[tool.coverage.paths]
77
source = [
88
"src/OpenSSL",
9-
"*.tox/*/lib/python*/site-packages/OpenSSL",
10-
"*.tox/*/lib/pypy*/site-packages/OpenSSL",
11-
"*.tox/pypy/site-packages/OpenSSL",
12-
"*.tox\\*\\Lib\\site-packages\\OpenSSL",
9+
"*.nox/*/lib/python*/site-packages/OpenSSL",
10+
"*.nox/*/lib/pypy*/site-packages/OpenSSL",
11+
"*.nox/pypy/site-packages/OpenSSL",
12+
"*.nox\\*\\Lib\\site-packages\\OpenSSL",
1313
]
1414

1515
[tool.coverage.report]

tox.ini

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)