Switch from tox to nox
This commit is contained in:
parent
2449df5732
commit
ce80b7e0f3
|
@ -206,11 +206,10 @@ jobs:
|
|||
- name: Test python examples and tests
|
||||
shell: bash
|
||||
run: |
|
||||
python -m pip install -U pip tox
|
||||
python -m pip install -U pip nox
|
||||
cargo xtask test-py
|
||||
env:
|
||||
CARGO_TARGET_DIR: ${{ github.workspace }}
|
||||
TOX_TESTENV_PASSENV: "CARGO_BUILD_TARGET CARGO_TARGET_DIR"
|
||||
|
||||
- name: Test cross compilation
|
||||
if: ${{ matrix.platform.os == 'ubuntu-latest' && matrix.python-version == '3.9' }}
|
||||
|
|
|
@ -10,7 +10,7 @@ repository = "https://github.com/pyo3/pyo3"
|
|||
documentation = "https://docs.rs/crate/pyo3/"
|
||||
categories = ["api-bindings", "development-tools::ffi"]
|
||||
license = "Apache-2.0"
|
||||
exclude = ["/.gitignore", ".cargo/config", "/codecov.yml", "/Makefile", "/pyproject.toml", "/tox.ini"]
|
||||
exclude = ["/.gitignore", ".cargo/config", "/codecov.yml", "/Makefile", "/pyproject.toml", "/noxfile.py"]
|
||||
edition = "2018"
|
||||
links = "python"
|
||||
|
||||
|
|
5
Makefile
5
Makefile
|
@ -13,8 +13,8 @@ test: lint test_py
|
|||
cargo test --features="abi3 $(ALL_ADDITIVE_FEATURES)"
|
||||
|
||||
test_py:
|
||||
@for example in examples/*/tox.ini; do echo "-- Running tox for $$example --"; tox -e py -c $$example || exit 1; echo ""; done
|
||||
@for package in pytests/*/tox.ini; do echo "-- Running tox for $$package --"; tox -e py -c $$package || exit 1; echo ""; done
|
||||
@for example in examples/*/noxfile.py; do echo "-- Running nox for $$example --"; nox -f $$example/noxfile.py || exit 1; echo ""; done
|
||||
@for package in pytests/*/noxfile.py; do echo "-- Running nox for $$package --"; nox -f $$package/noxfile.py || exit 1; echo ""; done
|
||||
|
||||
fmt_py:
|
||||
black . --check
|
||||
|
@ -35,7 +35,6 @@ coverage:
|
|||
bash -c "\
|
||||
set -a\
|
||||
source <(cargo llvm-cov show-env)\
|
||||
export TOX_TESTENV_PASSENV=*\
|
||||
make test_py\
|
||||
"
|
||||
cargo llvm-cov $(COVERAGE_PACKAGES) --no-run --summary-only
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# PyO3 Examples
|
||||
|
||||
These example crates are a collection of toy extension modules built with PyO3. They are all tested using `tox` in PyO3's CI.
|
||||
These example crates are a collection of toy extension modules built with PyO3. They are all tested using `nox` in PyO3's CI.
|
||||
|
||||
Below is a brief description of each of these:
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ maturin develop
|
|||
pytest
|
||||
```
|
||||
|
||||
Alternatively, install tox and run the tests inside an isolated environment:
|
||||
Alternatively, install nox and run the tests inside an isolated environment:
|
||||
|
||||
```shell
|
||||
tox -e py
|
||||
nox
|
||||
```
|
||||
|
||||
## Copying this example
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[template]
|
||||
ignore = [".tox"]
|
||||
ignore = [".tox", ".nox"]
|
||||
|
||||
[hooks]
|
||||
pre = [".template/pre-script.rhai"]
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import nox
|
||||
|
||||
|
||||
@nox.session
|
||||
def python(session):
|
||||
session.install("-rrequirements-dev.txt")
|
||||
session.install(".")
|
||||
session.run("pytest")
|
|
@ -1,10 +0,0 @@
|
|||
[tox]
|
||||
# can't install from sdist because local pyo3 repo can't be included in the sdist
|
||||
skipsdist = true
|
||||
|
||||
[testenv]
|
||||
description = Run the unit tests under {basepython}
|
||||
deps = -rrequirements-dev.txt
|
||||
commands =
|
||||
python -m pip install .
|
||||
pytest {posargs}
|
|
@ -17,10 +17,10 @@ pip install -r requirements-dev.txt
|
|||
maturin develop && pytest
|
||||
```
|
||||
|
||||
Alternatively, install tox and run the tests inside an isolated environment:
|
||||
Alternatively, install nox and run the tests inside an isolated environment:
|
||||
|
||||
```shell
|
||||
tox -e py
|
||||
nox
|
||||
```
|
||||
|
||||
## Copying this example
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[template]
|
||||
ignore = [".tox"]
|
||||
ignore = [".tox", ".nox"]
|
||||
|
||||
[hooks]
|
||||
pre = [".template/pre-script.rhai"]
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import nox
|
||||
|
||||
|
||||
@nox.session
|
||||
def python(session):
|
||||
session.install("-rrequirements-dev.txt")
|
||||
session.install(".")
|
||||
session.run("pytest")
|
|
@ -1,10 +0,0 @@
|
|||
[tox]
|
||||
# can't install from sdist because local pyo3 repo can't be included in the sdist
|
||||
skipsdist = true
|
||||
|
||||
[testenv]
|
||||
description = Run the unit tests under {basepython}
|
||||
deps = -rrequirements-dev.txt
|
||||
commands =
|
||||
python -m pip install .
|
||||
pytest {posargs}
|
|
@ -17,10 +17,10 @@ pip install -r requirements-dev.txt
|
|||
python setup.py develop && pytest
|
||||
```
|
||||
|
||||
Alternatively, install tox and run the tests inside an isolated environment:
|
||||
Alternatively, install nox and run the tests inside an isolated environment:
|
||||
|
||||
```shell
|
||||
tox -e py
|
||||
nox
|
||||
```
|
||||
|
||||
## Copying this example
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[template]
|
||||
ignore = [".tox"]
|
||||
ignore = [".tox", ".nox"]
|
||||
|
||||
[hooks]
|
||||
pre = [".template/pre-script.rhai"]
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import nox
|
||||
|
||||
|
||||
@nox.session
|
||||
def python(session):
|
||||
session.install("-rrequirements-dev.txt")
|
||||
session.install("-e", ".")
|
||||
session.run("pytest")
|
|
@ -1,5 +0,0 @@
|
|||
[testenv]
|
||||
usedevelop = true
|
||||
description = Run the unit tests under {basepython}
|
||||
deps = -rrequirements-dev.txt
|
||||
commands = pytest {posargs}
|
|
@ -35,10 +35,10 @@ pytest -v tests
|
|||
|
||||
## Testing
|
||||
|
||||
To test install tox globally and run
|
||||
To test install nox globally and run
|
||||
|
||||
```shell
|
||||
tox -e py
|
||||
nox
|
||||
```
|
||||
|
||||
## Copying this example
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[template]
|
||||
ignore = [".tox"]
|
||||
ignore = [".tox", ".nox"]
|
||||
|
||||
[hooks]
|
||||
pre = [".template/pre-script.rhai"]
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import nox
|
||||
|
||||
|
||||
@nox.session
|
||||
def python(session):
|
||||
session.install("-rrequirements-dev.txt")
|
||||
session.install("-e", ".")
|
||||
session.run("pytest")
|
|
@ -1,5 +0,0 @@
|
|||
[testenv]
|
||||
usedevelop = true
|
||||
description = Run the unit tests under {basepython}
|
||||
deps = -rrequirements-dev.txt
|
||||
commands = pytest {posargs}
|
|
@ -56,7 +56,7 @@ We are using `pytest-benchmark` to benchmark four word count functions:
|
|||
3. Rust sequential version
|
||||
4. Rust sequential version executed twice with two Python threads
|
||||
|
||||
The benchmark script can be found [here](https://github.com/PyO3/pyo3/blob/main/examples/word-count/tests/test_word_count.py), and we can run `tox` in the `word-count` folder to benchmark these functions.
|
||||
The benchmark script can be found [here](https://github.com/PyO3/pyo3/blob/main/examples/word-count/tests/test_word_count.py), and we can run `nox` in the `word-count` folder to benchmark these functions.
|
||||
|
||||
While the results of the benchmark of course depend on your machine, the relative results should be similar to this (mid 2020):
|
||||
```ignore
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import nox
|
||||
|
||||
|
||||
@nox.session(python=["3.7", "3.8", "3.9", "3.10"])
|
||||
def test(session):
|
||||
session.run("cargo", "test", external=True)
|
|
@ -9,10 +9,11 @@ exclude = '''
|
|||
| \.git # root of the project
|
||||
| \.mypy_cache
|
||||
| \.tox
|
||||
| \.nox
|
||||
| \.venv
|
||||
| venv
|
||||
| target
|
||||
| dist
|
||||
)/
|
||||
)
|
||||
'''
|
||||
'''
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# PyO3 Python tests
|
||||
|
||||
These crates are a collection of test extension modules built with PyO3. They are all tested using `tox` in PyO3's CI.
|
||||
These crates are a collection of test extension modules built with PyO3. They are all tested using `nox` in PyO3's CI.
|
||||
|
||||
Below is a brief description of each of these:
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ python setup.py develop
|
|||
pytest
|
||||
```
|
||||
|
||||
Or with tox:
|
||||
Or with nox:
|
||||
|
||||
```shell
|
||||
tox -e py
|
||||
nox
|
||||
```
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import nox
|
||||
|
||||
|
||||
@nox.session
|
||||
def python(session):
|
||||
session.install("-rrequirements-dev.txt")
|
||||
session.install("-e", ".")
|
||||
session.run("pytest", "--benchmark-sort=name")
|
|
@ -1,8 +0,0 @@
|
|||
[testenv]
|
||||
usedevelop = True
|
||||
description = Run the unit tests under {basepython}
|
||||
deps = -rrequirements-dev.txt
|
||||
commands = pytest --benchmark-sort=name {posargs}
|
||||
# Use recreate so that tox always rebuilds, otherwise changes to Rust are not
|
||||
# picked up.
|
||||
recreate = True
|
|
@ -12,8 +12,8 @@ maturin develop
|
|||
pytest
|
||||
```
|
||||
|
||||
Alternatively, install tox and run the tests inside an isolated environment:
|
||||
Alternatively, install nox and run the tests inside an isolated environment:
|
||||
|
||||
```shell
|
||||
tox -e py
|
||||
nox
|
||||
```
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import nox
|
||||
|
||||
|
||||
@nox.session
|
||||
def python(session):
|
||||
session.install("-rrequirements-dev.txt")
|
||||
session.install(".")
|
||||
session.run("pytest")
|
|
@ -1,10 +0,0 @@
|
|||
[tox]
|
||||
# can't install from sdist because local pyo3 repo can't be included in the sdist
|
||||
skipsdist = true
|
||||
|
||||
[testenv]
|
||||
description = Run the unit tests under {basepython}
|
||||
deps = -rrequirements-dev.txt
|
||||
commands =
|
||||
python -m pip install .
|
||||
pytest {posargs}
|
14
tox.ini
14
tox.ini
|
@ -1,14 +0,0 @@
|
|||
[tox]
|
||||
envlist = py37,
|
||||
py38,
|
||||
py39,
|
||||
py310,
|
||||
minversion = 3.7.0
|
||||
skip_missing_interpreters = true
|
||||
|
||||
[testenv]
|
||||
description = Run the unit tests under {basepython}
|
||||
skip_install = True
|
||||
usedevelop = True
|
||||
whitelist_externals = cargo
|
||||
commands = cargo test
|
|
@ -58,14 +58,22 @@ fn run_python_tests<'a>(
|
|||
) -> Result<()> {
|
||||
for entry in std::fs::read_dir("pytests")? {
|
||||
let path = entry?.path();
|
||||
if path.is_dir() && path.join("tox.ini").exists() {
|
||||
run(Command::new("tox").arg("-c").arg(path).envs(env))?;
|
||||
if path.is_dir() && path.join("noxfile.py").exists() {
|
||||
run(Command::new("nox")
|
||||
.arg("--non-interactive")
|
||||
.arg("-f")
|
||||
.arg(path.join("noxfile.py"))
|
||||
.envs(env))?;
|
||||
}
|
||||
}
|
||||
for entry in std::fs::read_dir("examples")? {
|
||||
let path = entry?.path();
|
||||
if path.is_dir() && path.join("tox.ini").exists() {
|
||||
run(Command::new("tox").arg("-c").arg(path).envs(env))?;
|
||||
if path.is_dir() && path.join("noxfile.py").exists() {
|
||||
run(Command::new("nox")
|
||||
.arg("--non-interactive")
|
||||
.arg("-f")
|
||||
.arg(path.join("noxfile.py"))
|
||||
.envs(env))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -81,7 +89,6 @@ fn get_coverage_env() -> Result<HashMap<String, String>> {
|
|||
env.insert(key.to_owned(), value.trim_matches('"').to_owned());
|
||||
}
|
||||
|
||||
env.insert("TOX_TESTENV_PASSENV".to_owned(), "*".to_owned());
|
||||
env.insert("RUSTUP_TOOLCHAIN".to_owned(), "nightly".to_owned());
|
||||
|
||||
Ok(env)
|
||||
|
|
Loading…
Reference in New Issue