Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation process for development #8

Open
2 tasks
horw opened this issue Jan 3, 2025 · 3 comments · May be fixed by #9
Open
2 tasks

Installation process for development #8

horw opened this issue Jan 3, 2025 · 3 comments · May be fixed by #9
Labels
documentation Improvements or additions to documentation

Comments

@horw
Copy link

horw commented Jan 3, 2025

Problem

Hello!
I found that installing echo_kernel for development isn't straightforward. I followed the steps described in the contributions section but still encountered some issues. I'll try to summarize them and share the steps I followed. Perhaps then we can update the README, as it seems the current instructions might be outdated.

Suggested Improvement

  • update libs
  • move to hatch
@horw horw added the documentation Improvements or additions to documentation label Jan 3, 2025
@horw
Copy link
Author

horw commented Jan 18, 2025

Jupyter-packaging was outdated; nowadays, Jupyter uses Hatch.

https://github.com/jupyter/jupyter-packaging

UPD:
I understand why Jupyter is starting to use it, mainly because it supports shared data, which makes it super easy to share JavaScript, HTML, etc., files.

@horw
Copy link
Author

horw commented Jan 18, 2025

There is also another section, [tool.jupyter-releaser.hooks], which seems important if you want to perform a release. The question is, why do we also need to release to Jupyter, instead of just making it possible to install from PyPI? What are the benefits of adding it there as well?"

https://jupyter-releaser.readthedocs.io/en/latest/get_started/making_release_from_repo.html#prep-release

@horw
Copy link
Author

horw commented Jan 19, 2025

When an extension is being used, the method _get_labextension_metadata is called. This method requires the _jupyter_labextension_paths method. Without it, the extension will not be imported successfully.

Therefore, you need to include some code like this in your __init__.py file:

import json
from pathlib import Path

__version__ = "0.1.0"

HERE = Path(__file__).parent.resolve()

with (HERE / "labextension" / "package.json").open() as fid:
    data = json.load(fid)

def _jupyter_labextension_paths():
    return [{
        "src": "labextension",
        "dest": data["name"]
    }]

Here is the _get_labextension_metadata code for reference:

for package in package_candidates:
    try:
        m = importlib.import_module(package)
        if hasattr(m, "_jupyter_labextension_paths"):
            return m, m._jupyter_labextension_paths()
    except Exception as exc:
        errors.append(exc)

msg = f"There is no labextension in {module}. Errors encountered: {errors}"
raise ModuleNotFoundError(msg)

Note

have not found any docs about it ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant