From fdbfa83761b7481b9bf2d728c2cf84edf5463a47 2024-10-17 12:41:37 From: akumor Date: 2024-10-17 12:41:37 Subject: [PATCH] Add line magic for uv --- diff --git a/IPython/core/magics/packaging.py b/IPython/core/magics/packaging.py index 09d4117..ed1c127 100644 --- a/IPython/core/magics/packaging.py +++ b/IPython/core/magics/packaging.py @@ -162,3 +162,20 @@ class PackagingMagics(Magics): """ micromamba = _get_conda_like_executable("micromamba") self._run_command(micromamba, line) + + @line_magic + def uv(self, line): + """Run the uv package manager within the current kernel. + + Usage: + %uv pip install [pkgs] + """ + python = sys.executable + if sys.platform == "win32": + python = '"' + python + '"' + else: + python = shlex.quote(python) + + self.shell.system(" ".join([python, "-m", "uv", line])) + + print("Note: you may need to restart the kernel to use updated packages.")