Skip to content

Commit

Permalink
fix: R kernel environment variables fix (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
renan-r-santos authored Apr 13, 2024
1 parent 667aa52 commit 37c350f
Show file tree
Hide file tree
Showing 17 changed files with 213 additions and 175 deletions.
2 changes: 1 addition & 1 deletion kernels/pixi-kernel-bash/kernel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"argv": [
"pixi",
"run",
"--manifest-path=",
"--manifest-path={manifest-path}",
"python",
"-m",
"bash_kernel",
Expand Down
7 changes: 6 additions & 1 deletion kernels/pixi-kernel-ir/kernel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"argv": [
"pixi",
"run",
"--manifest-path=",
"--manifest-path={manifest-path}",
"R",
"--slave",
"-e",
Expand All @@ -12,6 +12,11 @@
],
"display_name": "Pixi - R",
"language": "R",
"env": {
"R_LIBS": "{manifest-path-parent}/.pixi/envs/default/lib/R/library",
"R_LIBS_SITE": "{manifest-path-parent}/.pixi/envs/default/lib/R/library",
"R_LIBS_USER": "{manifest-path-parent}/.pixi/envs/default/lib/R/library"
},
"metadata": {
"pixi-kernel": {
"package-name": "r-irkernel"
Expand Down
2 changes: 1 addition & 1 deletion kernels/pixi-kernel-python3/kernel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"argv": [
"pixi",
"run",
"--manifest-path=",
"--manifest-path={manifest-path}",
"python",
"-m",
"ipykernel_launcher",
Expand Down
2 changes: 1 addition & 1 deletion kernels/pixi-kernel-xcpp11/kernel.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"argv": [
"pixi",
"run",
"--manifest-path=",
"--manifest-path={manifest-path}",
"xcpp",
"-f",
"{connection_file}",
Expand Down
2 changes: 1 addition & 1 deletion kernels/pixi-kernel-xcpp14/kernel.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"argv": [
"pixi",
"run",
"--manifest-path=",
"--manifest-path={manifest-path}",
"xcpp",
"-f",
"{connection_file}",
Expand Down
2 changes: 1 addition & 1 deletion kernels/pixi-kernel-xcpp17/kernel.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"argv": [
"pixi",
"run",
"--manifest-path=",
"--manifest-path={manifest-path}",
"xcpp",
"-f",
"{connection_file}",
Expand Down
82 changes: 41 additions & 41 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ msgspec = ">=0.18"
[feature.dev.pypi-dependencies]
pixi-kernel = { path = ".", editable = true }

[feature.dev.tasks]
update-lock = "scripts/update-lock.sh"


# Testing
[feature.test.dependencies]
Expand All @@ -32,19 +35,24 @@ unit = "COVERAGE_FILE=.coverage.$(python -c 'import platform; print(platform.sys
bash-kernel = { cwd = "tests/integration/bash_kernel", cmd = "PYDEVD_DISABLE_FILE_VALIDATION=1 pixi run --locked --manifest-path=pixi.toml python kernel.py" }
ipykernel = { cwd = "tests/integration/ipykernel", cmd = "PYDEVD_DISABLE_FILE_VALIDATION=1 pixi run --locked --manifest-path=pixi.toml python kernel.py" }
r-irkernel = { cwd = "tests/integration/r-irkernel", cmd = "pixi run --locked --manifest-path=pixi.toml python kernel.py" }
xeus-cling = { cwd = "tests/integration/xeus-cling", cmd = "pixi run --locked --manifest-path=pixi.toml python kernel.py" }

# Combined
test = { depends_on = ["unit", "ipykernel", "r-irkernel"] }
coverage = "coverage combine && coverage html && coverage xml"

# Integration tests for platform-specific kernels
[feature.test.target.linux-64.tasks]
xeus-cling = { cwd = "tests/integration/xeus-cling", cmd = "pixi run --locked --manifest-path=pixi.toml python kernel.py" }
test = { depends_on = ["unit", "ipykernel", "r-irkernel", "xeus-cling"] }
test = { depends_on = ["unit", "bash-kernel", "ipykernel", "r-irkernel", "xeus-cling"] }

[feature.test.target.linux-aarch64.tasks]
xeus-cling = { cwd = "tests/integration/xeus-cling", cmd = "pixi run --locked --manifest-path=pixi.toml python kernel.py" }
test = { depends_on = ["unit", "ipykernel", "r-irkernel", "xeus-cling"] }
test = { depends_on = ["unit", "bash-kernel", "ipykernel", "r-irkernel", "xeus-cling"] }

[feature.test.target.osx-64.tasks]
test = { depends_on = ["unit", "bash-kernel", "ipykernel", "r-irkernel"] }

[feature.test.target.osx-arm64.tasks]
test = { depends_on = ["unit", "bash-kernel", "ipykernel", "r-irkernel"] }


# Linting and formatting
Expand Down Expand Up @@ -99,13 +107,7 @@ test-py312 = { depends_on = ["install", "test"] }


[environments]
default = { features = [
"base",
"build",
"dev",
"ruff",
"test",
], solve-group = "pixi-kernel" }
default = { features = ["base", "build", "dev", "ruff", "test"], solve-group = "pixi-kernel" }
build = { features = ["build"], solve-group = "pixi-kernel" }
ruff = { features = ["ruff"], solve-group = "pixi-kernel" }
test = { features = ["test"], solve-group = "pixi-kernel" }
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "pixi-kernel"
version = "0.2.0"
description = "Python Jupyter kernel using Pixi for reproducible notebooks"
description = "Jupyter kernels using Pixi for reproducible notebooks"
license = { text = "MIT" }
authors = [
{ name = "Renan Rodrigues dos Santos", email = "renan.engmec@gmail.com" },
Expand Down Expand Up @@ -72,9 +72,6 @@ branch = true
[tool.coverage.paths]
source = ["src/", ".pixi/envs/**/lib/python*/site-packages/"]

[tool.coverage.report]
fail_under = 65

[tool.hatch.build.targets.wheel.shared-data]
"kernels" = "share/jupyter/kernels"

Expand Down
23 changes: 23 additions & 0 deletions scripts/update-lock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e


# Delete rattler cache
rm -rf $HOME/.cache/rattler/cache

# Update lock files
project_paths=(
"."
"tests/integration/bash_kernel"
"tests/integration/ipykernel"
"tests/integration/r-irkernel"
"tests/integration/xeus-cling"
)
for path in "${project_paths[@]}"; do
echo "Updating lock file in ${path}"
(
cd ${path}
rm -rf .pixi pixi.lock
pixi install --manifest-path=pixi.toml
)
done
4 changes: 2 additions & 2 deletions src/pixi_kernel/pixi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def find_project_manifest(
package_name: str,
kernel_display_name: str,
logger: Logger,
) -> str:
) -> Path:
# Ensure Pixi is in PATH
if shutil.which("pixi") is None:
raise RuntimeError(PIXI_NOT_FOUND.format(kernel_display_name=kernel_display_name))
Expand Down Expand Up @@ -102,6 +102,6 @@ def find_project_manifest(
package_name=package_name,
)
)
return str(dir / project_filename)
return dir / project_filename

raise RuntimeError(PIXI_MANIFEST_NOT_FOUND.format(cwd=cwd))
Loading

0 comments on commit 37c350f

Please sign in to comment.