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

Add dependencies to pyproject.toml #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
30 changes: 11 additions & 19 deletions condacolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@
from typing import Dict, AnyStr
from urllib.request import urlopen
from distutils.spawn import find_executable
from IPython.display import display

import ipywidgets as widgets
from IPython.display import display
from IPython import get_ipython

try:
import ipywidgets as widgets
HAS_IPYWIDGETS = True
except ImportError:
HAS_IPYWIDGETS = False

try:
import google.colab
Expand All @@ -46,17 +42,16 @@

PREFIX = "/opt/conda"

if HAS_IPYWIDGETS:
restart_kernel_button = widgets.Button(description="Restart kernel now...")
restart_button_output = widgets.Output(layout={'border': '1px solid black'})
else:
restart_kernel_button = restart_button_output = None

restart_kernel_button = widgets.Button(description="Restart kernel now...")
restart_button_output = widgets.Output(layout={'border': '1px solid black'})


def _on_button_clicked(b):
with restart_button_output:
get_ipython().kernel.do_shutdown(True)
print("Kernel restarted!")
restart_kernel_button.close()
with restart_button_output:
get_ipython().kernel.do_shutdown(True)
print("Kernel restarted!")
restart_kernel_button.close()

def _run_subprocess(command, logs_filename):
"""
Expand Down Expand Up @@ -212,14 +207,11 @@ def install_from_url(
print("🔁 Restarting kernel...")
get_ipython().kernel.do_shutdown(True)

elif HAS_IPYWIDGETS:
else:
print("🔁 Please restart kernel...")
restart_kernel_button.on_click(_on_button_clicked)
display(restart_kernel_button, restart_button_output)

else:
print("🔁 Please restart kernel by clicking on Runtime > Restart runtime.")

def install_mambaforge(
prefix: os.PathLike = PREFIX, env: Dict[AnyStr, AnyStr] = None, run_checks: bool = True, restart_kernel: bool = True,
):
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ repository = "https://github.com/jaimergp/condacolab"

[tool.poetry.dependencies]
python = "^3.7"
"ruamel.yaml" = ">=0.11.14,<0.17"
ipython = ">=4"
ipywidgets = "^7.4"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down