Skip to content

Commit

Permalink
delay imports in command plugin (#4953)
Browse files Browse the repository at this point in the history
* delay imports in command plugin
* add news item
  • Loading branch information
dholth authored Aug 4, 2023
1 parent ff714fd commit afe931a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 10 deletions.
3 changes: 2 additions & 1 deletion conda_build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"index",
"inspect",
"metapackage",
"render" "skeleton",
"render",
"skeleton",
]
64 changes: 55 additions & 9 deletions conda_build/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,61 @@
# SPDX-License-Identifier: BSD-3-Clause
import conda.plugins

from .cli.main_build import execute as build
from .cli.main_convert import execute as convert
from .cli.main_debug import execute as debug
from .cli.main_develop import execute as develop
from .cli.main_index import execute as index
from .cli.main_inspect import execute as inspect
from .cli.main_metapackage import execute as metapackage
from .cli.main_render import execute as render
from .cli.main_skeleton import execute as skeleton

# lazy-import to avoid nasty import-time side effects when not using conda-build
def build(*args, **kwargs):
from .cli.main_build import execute

execute(*args, **kwargs)


def convert(*args, **kwargs):
from .cli.main_convert import execute

execute(*args, **kwargs)


def debug(*args, **kwargs):
from .cli.main_debug import execute

execute(*args, **kwargs)


def develop(*args, **kwargs):
from .cli.main_develop import execute

execute(*args, **kwargs)


def index(*args, **kwargs):
# deprecated! use conda-index!
from .cli.main_index import execute

execute(*args, **kwargs)


def inspect(*args, **kwargs):
from .cli.main_inspect import execute

execute(*args, **kwargs)


def metapackage(*args, **kwargs):
from .cli.main_metapackage import execute

execute(*args, **kwargs)


def render(*args, **kwargs):
from .cli.main_render import execute

execute(*args, **kwargs)


def skeleton(*args, **kwargs):
from .cli.main_skeleton import execute

execute(*args, **kwargs)


@conda.plugins.hookimpl
Expand Down
20 changes: 20 additions & 0 deletions news/4956-improve-command-plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* <news item>

### Bug fixes

* Delay imports in conda command plugin until the command is used, avoiding
import-time side effects. (#4949)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>

0 comments on commit afe931a

Please sign in to comment.