Skip to content

Commit

Permalink
Merge #3210
Browse files Browse the repository at this point in the history
3210: Drop the xtask helper as it is superseded by Nox. r=davidhewitt a=adamreichold

While the xtask code base is better engineered than our slightly messy Nox manifest, all functionality is available via Nox including some that is not available via xtask. Finally, only the Nox sessions are used in the CI by now so that xtask does not see regular automated usage.

Co-authored-by: Adam Reichold <[email protected]>
  • Loading branch information
bors[bot] and adamreichold authored Jun 5, 2023
2 parents e1f028f + 1fad391 commit 4ca3364
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 525 deletions.
4 changes: 1 addition & 3 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[alias]
xtask = "run --package xtask --"

[target.'cfg(feature = "cargo-clippy")']
rustflags = [
# Lints to enforce in CI
Expand All @@ -11,6 +8,7 @@ rustflags = [
"-Dclippy::filter_map_next",
"-Dclippy::flat_map_option",
"-Dclippy::let_unit_value",
"-Dclippy::manual_assert",
"-Dclippy::manual_ok_or",
"-Dclippy::todo",
"-Dclippy::unnecessary_wraps",
Expand Down
4 changes: 2 additions & 2 deletions .netlify/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ mv target/guide netlify_build/main/

## Build public docs

cargo xtask doc
nox -s docs
mv target/doc netlify_build/main/doc/

echo "<meta http-equiv=refresh content=0;url=pyo3/>" > netlify_build/main/doc/index.html

## Build internal docs

echo "<div class='internal-banner' style='position:fixed; z-index: 99999; color:red;border:3px solid red;margin-left: auto; margin-right: auto; width: 430px;left:0;right: 0;'><div style='display: flex; align-items: center; justify-content: center;'> ⚠️ Internal Docs ⚠️ Not Public API 👉 <a href='https://pyo3.rs/main/doc/pyo3/index.html' style='color:red;text-decoration:underline;'>Official Docs Here</a></div></div>" > netlify_build/banner.html
RUSTDOCFLAGS="--html-before-content netlify_build/banner.html" cargo xtask doc --internal
RUSTDOCFLAGS="--html-before-content netlify_build/banner.html" nox -s docs -- nightly internal
rm netlify_build/banner.html

mkdir -p netlify_build/internal
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ members = [
"pyo3-macros-backend",
"pytests",
"examples",
"xtask"
]

[package.metadata.docs.rs]
Expand Down
10 changes: 6 additions & 4 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ There are some specific areas of focus where help is currently needed for the do
You can build the docs (including all features) with

```shell
cargo xtask doc --open
nox -s docs -- open
```

#### Doctests
Expand Down Expand Up @@ -95,8 +95,10 @@ Tests run with all supported Python versions with the latest stable Rust compile
If you are adding a new feature, you should add it to the `full` feature in our *Cargo.toml** so that it is tested in CI.

You can run these tests yourself with
```cargo xtask ci```
See [its documentation](https://github.com/PyO3/pyo3/tree/main/xtask#readme) for more commands you can run.
```nox```
and
```nox -l```
lists further commands you can run.

### Documenting changes

Expand Down Expand Up @@ -145,7 +147,7 @@ You can view what code is and isn't covered by PyO3's tests. We aim to have 100%

- First, generate a `lcov.info` file with
```shell
cargo xtask coverage
nox -s coverage
```
You can install an IDE plugin to view the coverage. For example, if you use VSCode:
- Add the [coverage-gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) plugin.
Expand Down
46 changes: 40 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import subprocess
import sys
import tempfile
import time
from functools import lru_cache
from glob import glob
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Tuple

import nox

nox.options.sessions = ["test", "clippy", "fmt"]
nox.options.sessions = ["test", "clippy", "fmt", "docs"]


PYO3_DIR = Path(__file__).parent
Expand Down Expand Up @@ -165,13 +164,9 @@ def _check(env: Dict[str, str]) -> None:
@nox.session(venv_backend="none")
def publish(session: nox.Session) -> None:
_run_cargo_publish(session, package="pyo3-build-config")
time.sleep(10)
_run_cargo_publish(session, package="pyo3-macros-backend")
time.sleep(10)
_run_cargo_publish(session, package="pyo3-macros")
time.sleep(10)
_run_cargo_publish(session, package="pyo3-ffi")
time.sleep(10)
_run_cargo_publish(session, package="pyo3")


Expand Down Expand Up @@ -293,6 +288,45 @@ def test_emscripten(session: nox.Session):
)


@nox.session(venv_backend="none")
def docs(session: nox.Session) -> None:
rustdoc_flags = ["-Dwarnings"]
toolchain_flags = []
cargo_flags = []

if "open" in session.posargs:
cargo_flags.append("--open")

if "nightly" in session.posargs:
rustdoc_flags.append("--cfg docsrs")
toolchain_flags.append("+nightly")
cargo_flags.extend(["-Z", "unstable-options", "-Z", "rustdoc-scrape-examples"])

if "nightly" in session.posargs and "internal" in session.posargs:
rustdoc_flags.append("--Z unstable-options")
rustdoc_flags.append("--document-hidden-items")
cargo_flags.append("--document-private-items")
else:
cargo_flags.extend(["--exclude=pyo3-macros", "--exclude=pyo3-macros-backend"])

rustdoc_flags.append(session.env.get("RUSTDOCFLAGS", ""))
session.env["RUSTDOCFLAGS"] = " ".join(rustdoc_flags)

_run(
session,
"cargo",
*toolchain_flags,
"doc",
"--lib",
"--no-default-features",
"--features=full",
"--no-deps",
"--workspace",
*cargo_flags,
external=True,
)


@nox.session(name="build-guide", venv_backend="none")
def build_guide(session: nox.Session):
_run(session, "mdbook", "build", "-d", "../target/guide", "guide", *session.posargs)
Expand Down
15 changes: 0 additions & 15 deletions xtask/Cargo.toml

This file was deleted.

23 changes: 0 additions & 23 deletions xtask/README.md

This file was deleted.

Loading

0 comments on commit 4ca3364

Please sign in to comment.