Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v6
- uses: prefix-dev/setup-pixi@v0.9.3
with:
pixi-version: v0.56.0
pixi-version: v0.62.2
cache: true
- name: Publish to PyPI
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v6
- uses: prefix-dev/setup-pixi@v0.9.3
with:
pixi-version: v0.56.0
pixi-version: v0.62.2
cache: true
- name: Test example
run: pixi run repo2wasm ${{ matrix.example_path }} --no-run
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v6
- uses: prefix-dev/setup-pixi@v0.9.3
with:
pixi-version: v0.56.0
pixi-version: v0.62.2
cache: true
- name: Test example
run: pixi run test
4 changes: 4 additions & 0 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 0.7.0

### Enhancements made

- Support configuration files in `.nblink`

## 0.6.0

### Enhancements made
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`repo2wasm` is a clone of [`jupyter-repo2docker`] targeting [WebAssembly](https://en.wikipedia.org/wiki/WebAssembly) (Wasm) environment. If [`jupyter-repo2docker`] is a wrapper around [Docker Engine](https://docs.docker.com/engine/), `repo2wasm` is a wrapper around [JupyterLite].

```{important}
```{hint}
Only programming languages already compiled to Wasm are supported, more details in the section "[](#supported-programming-languages)".
```

Expand Down
47 changes: 43 additions & 4 deletions docs/source/user-guide/supported-configuration-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,46 @@

# Supported configuration files

## Users
## Configuration file location

The supported configuration files are searched in the following directories:

- `.binder`
- `binder`
- `.` (root of the project)
- `.nblink`

### Root of project

![status: implemented](https://img.shields.io/badge/status-implemented-green)
![version: 0.3.0](https://img.shields.io/badge/version-0.3.0-blue)

### `binder` folder

![status: implemented](https://img.shields.io/badge/status-implemented-green)
![version: 0.3.0](https://img.shields.io/badge/version-0.3.0-blue)

The `binder` folder **must** be at the root of your project.

### `.binder` folder

![status: implemented](https://img.shields.io/badge/status-implemented-green)
![version: 0.3.0](https://img.shields.io/badge/version-0.3.0-blue)

The `.binder` folder **must** be at the root of your project.

### `.nblink` folder

![status: implemented](https://img.shields.io/badge/status-implemented-green)
![version: 0.7.0](https://img.shields.io/badge/version-0.7.0-blue)

The `.nblink` folder **must** be at the root of your project.

```{error}
The `.nblink` folder is not searched by `jupyter-repo2docker` used by [mybinder.org](https://mybinder.org).
```

## Configuration file for users

### `environment.yml`

Expand Down Expand Up @@ -43,7 +82,7 @@ More details in [repo2docker > User guide > install.R - Install R packages](http

More details in [repo2docker > User guide > Project.toml - Install a Julia environment](https://repo2docker.readthedocs.io/en/latest/configuration/research/#project-toml-install-a-julia-environment).

## Package Developers
## Configuration file for package developers

### `Pipfile` and/or `Pipfile.lock`

Expand All @@ -63,7 +102,7 @@ More details in [repo2docker > User guide > setup.py - Install Python packages](

More details in [repo2docker > User guide > DESCRIPTION - Install as an R package](https://repo2docker.readthedocs.io/en/latest/configuration/research/#description-install-as-an-r-package).

## System-wide configuration
## Configuration file for system-wide configuration

### `apt.txt`

Expand All @@ -89,7 +128,7 @@ More details in [repo2docker > User guide > default.nix - the nix package manage

More details in [repo2docker > User guide > Dockerfile - Advanced environments](https://repo2docker.readthedocs.io/en/latest/configuration/system/#dockerfile-advanced-environments).

## Post-build actions
## Configuration file for post-build actions

### `postBuild`

Expand Down
588 changes: 313 additions & 275 deletions pixi.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ description = "Build source into Python package"
cmd = "rm -rf dist; python -m build"

[tool.pixi.feature.release.tasks.upload]
description = "Upload package to PyPI"
description = "Upload package to PyPI"
cmd = "python3 -m twine upload --repository pypi dist/*"
depends-on = ["build"]

Expand Down
66 changes: 44 additions & 22 deletions src/repo2wasm/binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,61 @@

logger = logging.getLogger(__name__)

ALLOWED_BINDER_DIR = [".binder", "binder", "."]
# As documented in https://repo2docker.readthedocs.io/en/latest/specification/
ALLOWED_REPO2DOCKER_DIR = [".binder", "binder", "."]

ALLOWED_BINDER_CONFIGURATION_MAPPING = {
ALLOWED_REPO2DOCKER_CONFIGURATION_MAPPING = {
"environment.yml": CondaBuildPack,
"requirements.txt": RequirementsBuildPack,
"install.R": InstallBuildPack,
}

# As documented in https://notebook.link/docs/user-guide/enable-your-github-repository#define-the-environment
ALLOWED_NOTEBOOK_LINK_DIR = [".nblink", "."]

def find_configuration_file(path_to_repository):
for configuration_file in ALLOWED_BINDER_CONFIGURATION_MAPPING:
for binder_dir in ALLOWED_BINDER_DIR:
file_path = os.path.join(path_to_repository, binder_dir, configuration_file)
logger.debug("Searching for %s ...", file_path)
if os.path.isfile(file_path):
logger.debug("Found %s", file_path)
return file_path
ALLOWED_NOTEBOOK_LINK_CONFIGURATION_MAPPING = {
"environment.yml": CondaBuildPack,
}

raise RuntimeError("Configuration file not found.")
CONFIGURATION_PROVIDERS = {
"repo2docker": (ALLOWED_REPO2DOCKER_CONFIGURATION_MAPPING, ALLOWED_REPO2DOCKER_DIR),
"notebook.link": (
ALLOWED_NOTEBOOK_LINK_CONFIGURATION_MAPPING,
ALLOWED_NOTEBOOK_LINK_DIR,
),
}


def get_buildpack(path_to_repository, ide, output_dir, forgiving=False):
configuration_file_path = find_configuration_file(path_to_repository)
configuration_file_path = None
BuildPack = None

for provider, (
configuration_mapping,
allowed_dir,
) in CONFIGURATION_PROVIDERS.items():
logger.debug("Testing for %s as provider ...", provider)
for configuration_file in configuration_mapping:
for binder_dir in allowed_dir:
file_path = os.path.join(
path_to_repository, binder_dir, configuration_file
)
logger.debug("Searching for %s ...", file_path)
if os.path.isfile(file_path):
logger.debug("Found %s", file_path)
configuration_file_path = file_path
BuildPack = configuration_mapping[configuration_file]
break

if configuration_file_path is not None:
break

configuration_file = os.path.basename(configuration_file_path)
if configuration_file_path is not None:
break

for (
buildpack_configuration_file,
BuildPack,
) in ALLOWED_BINDER_CONFIGURATION_MAPPING.items():
if configuration_file == buildpack_configuration_file:
return BuildPack(
path_to_repository, configuration_file_path, ide, output_dir, forgiving
)
if configuration_file_path is None:
raise RuntimeError("Configuration file not found.")

raise RuntimeError("Build pack not found.")
return BuildPack(
path_to_repository, configuration_file_path, ide, output_dir, forgiving
)