From 06f2814445e77035189bda6452f6f2c734ed8faf Mon Sep 17 00:00:00 2001 From: Simon van Lierde Date: Fri, 23 Oct 2026 18:47:46 +0000 Subject: [PATCH] docs: fix the Hatch scripts and nox mamba examples so they run - hatch tutorial: drop detached = true from the scripts table, where hatch rejects it, fix the build:check command name, and write the flag as TOML true in the prose - nox: install pytest with conda_install and the package with pip, since conda_install(".[tests]") cannot solve --- tests/run-tests-nox.md | 5 +++-- tutorials/develop-python-package-hatch.md | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/run-tests-nox.md b/tests/run-tests-nox.md index c9bc1e752..13d64c107 100644 --- a/tests/run-tests-nox.md +++ b/tests/run-tests-nox.md @@ -141,8 +141,9 @@ def test_mamba(session): """Nox function that installs dev requirements and runs tests on Python 3.9 through 3.12. """ - # Install dev requirements - session.conda_install(".[tests]") + # Install test dependencies from conda-forge, then your package with pip + session.conda_install("pytest", channel="conda-forge") + session.install(".") # Run tests using any parameters that you need session.run("pytest") ``` diff --git a/tutorials/develop-python-package-hatch.md b/tutorials/develop-python-package-hatch.md index 20a0ff484..e67da2255 100644 --- a/tutorials/develop-python-package-hatch.md +++ b/tutorials/develop-python-package-hatch.md @@ -97,7 +97,7 @@ detached = true ``` :::{admonition} Hatch will install your package in editable mode by default -Notice the `detached = True` flag at the bottom of the environment. By default, hatch will install your package in editable mode into any environment it creates. `detached=True` tells it not to install your package into the environment. +Notice the `detached = true` flag at the bottom of the environment. By default, hatch will install your package in editable mode into any environment it creates. `detached = true` tells it not to install your package into the environment. ::: @@ -106,7 +106,7 @@ Notice the `detached = True` flag at the bottom of the environment. By default, Hatch supports defining {term}`Script (Hatch)` commands that run in specific Hatch environments. -Above, you have defined a new environment called 'build' that Hatch will create as a virtual environment (venv). Because `detached = True` in that environment, Hatch won't install your package into it. +Above, you have defined a new environment called 'build' that Hatch will create as a virtual environment (venv). Because `detached = true` in that environment, Hatch won't install your package into it. You can then use that environment to run "scripts". The definition below tells Hatch to run the following scripts in the build environment. @@ -126,18 +126,17 @@ Below is the `build.scripts` table that defines 3 shell commands to be run: * `twine check dist/*` # use twine to check that your package's sdist (source distribution) is ok. ```toml -# This table installs the command hatch run install:check, which will build and check your package. +# This table installs the command hatch run build:check, which will build and check your package. [tool.hatch.envs.build.scripts] check = [ "pip check", "hatch build {args:--clean}", "twine check dist/*", ] -detached = true ``` :::{tip} -Hatch, by default, will install your package in editable mode into any virtual environment (venv) that it creates. If `detached=True` is set, then it will skip that step. +Hatch, by default, will install your package in editable mode into any virtual environment (venv) that it creates. If `detached = true` is set, then it will skip that step. ::: ### Running the build script