diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5972a8..fce84ff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,7 +56,7 @@ uv run tox run -e type_check 1. Bump 1. Increment version in `pyproject.toml` - 2. Update all Pixi lock files by running `uv sync` + 2. Update all lock files by running `uv sync -U` and `pixi update` 3. Commit with message "chore: Bump version number to X.Y.Z" 4. Push commit to GitHub 5. Check [CI](https://github.com/renan-r-santos/pixi-kernel/actions/workflows/ci.yml) to ensure diff --git a/src/pixi_kernel/errors.py b/src/pixi_kernel/errors.py index def307a..3a7f550 100644 --- a/src/pixi_kernel/errors.py +++ b/src/pixi_kernel/errors.py @@ -31,7 +31,8 @@ PIXI_KERNEL_NOT_FOUND = """ To run the {kernel_name} kernel, you need to add the {required_package} package to your project dependencies. You can do this by running 'pixi add {required_package}' -in your project directory and restarting your kernel. +in your project directory and restarting your kernel. Make sure the prefix {prefix} +points to the correct Pixi environment. If you continue to face issues, report them at https://github.com/renan-r-santos/pixi-kernel/issues """ diff --git a/src/pixi_kernel/pixi.py b/src/pixi_kernel/pixi.py index 2ead5f6..c98855f 100644 --- a/src/pixi_kernel/pixi.py +++ b/src/pixi_kernel/pixi.py @@ -1,5 +1,6 @@ from __future__ import annotations +import logging import os import shutil import subprocess @@ -12,6 +13,8 @@ MINIMUM_PIXI_VERSION = "0.30.0" +logger = logging.getLogger(__name__) + class PixiInfo(BaseModel): environments: list[Environment] = Field(alias="environments_info") @@ -75,6 +78,8 @@ def ensure_readiness(*, cwd: Path, required_package: str, kernel_name: str) -> E capture_output=True, text=True, ) + logger.info(f"pixi info stdout: {result.stdout}") + logger.info(f"pixi info stderr: {result.stderr}") if result.returncode != 0: raise RuntimeError(f"Failed to run 'pixi info': {result.stderr}") @@ -108,7 +113,9 @@ def ensure_readiness(*, cwd: Path, required_package: str, kernel_name: str) -> E if required_package not in dependencies: raise RuntimeError( PIXI_KERNEL_NOT_FOUND.format( - kernel_name=kernel_name, required_package=required_package + kernel_name=kernel_name, + required_package=required_package, + prefix=default_environment.prefix, ) ) diff --git a/src/pixi_kernel/provisioner.py b/src/pixi_kernel/provisioner.py index 0d462b7..63fcf57 100644 --- a/src/pixi_kernel/provisioner.py +++ b/src/pixi_kernel/provisioner.py @@ -29,6 +29,7 @@ async def pre_launch(self, **kwargs: Any) -> dict[str, Any]: raise ValueError("Pixi Kernel metadata is missing the 'required-package' key") cwd = Path(kwargs.get("cwd", Path.cwd())) + logger.info(f"JupyterLab provided the following kwargs: {kwargs}") logger.info(f"The current working directory is {cwd}") environment = ensure_readiness( diff --git a/tests/unit/test_pixi.py b/tests/unit/test_pixi.py index 7be7c8d..166b946 100644 --- a/tests/unit/test_pixi.py +++ b/tests/unit/test_pixi.py @@ -103,6 +103,7 @@ def test_missing_ipykernel(): PIXI_KERNEL_NOT_FOUND.format( required_package=required_package, kernel_name=kernel_name, + prefix="envs/default", ) ) with pytest.raises(RuntimeError, match=message):