From 4e28ca1e4a2559fcdebc7d22afe176c54cbf3326 Mon Sep 17 00:00:00 2001 From: Joe Marshall Date: Wed, 2 Nov 2022 15:05:28 +0000 Subject: [PATCH 1/2] added skipping of dependencies --- micropip/_micropip.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/micropip/_micropip.py b/micropip/_micropip.py index 0548245..74a7317 100644 --- a/micropip/_micropip.py +++ b/micropip/_micropip.py @@ -288,6 +288,7 @@ class Transaction: deps: bool pre: bool fetch_kwargs: dict[str, str] + skip_deps: list[str] locked: dict[str, PackageMetadata] = field(default_factory=dict) wheels: list[WheelInfo] = field(default_factory=list) @@ -346,6 +347,9 @@ async def add_requirement_inner( See PEP 508 for a description of the requirements. https://www.python.org/dev/peps/pep-0508 """ + if req.name in self.skip_deps: + # don't install any dependencies we've been told to ignore + return for e in req.extras: self.ctx_extras.append({"extra": e}) @@ -443,6 +447,7 @@ async def install( deps: bool = True, credentials: str | None = None, pre: bool = False, + skip_deps: list[str]=[], ) -> None: """Install the given package and all of its dependencies. @@ -514,6 +519,11 @@ async def install( If ``True``, include pre-release and development versions. By default, micropip only finds stable versions. + skip_deps: ``Optional[list[str]]`` + + This parameter specifies a list of packages which should not be installed + if they are in the dependency tree. + Returns ------- ``Future`` @@ -544,6 +554,7 @@ async def install( deps=deps, pre=pre, fetch_kwargs=fetch_kwargs, + skip_deps=skip_deps ) await transaction.gather_requirements(requirements) From 688b7a463ef055d7c4e7aab3b93f6c0ca89eb8f2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 2 Nov 2022 15:09:45 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- micropip/_micropip.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/micropip/_micropip.py b/micropip/_micropip.py index 74a7317..b27e0c5 100644 --- a/micropip/_micropip.py +++ b/micropip/_micropip.py @@ -447,7 +447,7 @@ async def install( deps: bool = True, credentials: str | None = None, pre: bool = False, - skip_deps: list[str]=[], + skip_deps: list[str] = [], ) -> None: """Install the given package and all of its dependencies. @@ -521,7 +521,7 @@ async def install( skip_deps: ``Optional[list[str]]`` - This parameter specifies a list of packages which should not be installed + This parameter specifies a list of packages which should not be installed if they are in the dependency tree. Returns @@ -554,7 +554,7 @@ async def install( deps=deps, pre=pre, fetch_kwargs=fetch_kwargs, - skip_deps=skip_deps + skip_deps=skip_deps, ) await transaction.gather_requirements(requirements)