From 2dce0525568d717d90172858b81acb035fe48bae Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 21 Mar 2024 01:25:47 +0100 Subject: [PATCH] Cythonize parameterized --- param/{_utils.py => _utils.pyx} | 9 +-------- param/{parameterized.py => parameterized.pyx} | 17 ++--------------- param/{parameters.py => parameters.pyx} | 0 param/{reactive.py => reactive.pyx} | 0 pyproject.toml | 15 +++++++++++++-- 5 files changed, 16 insertions(+), 25 deletions(-) rename param/{_utils.py => _utils.pyx} (99%) rename param/{parameterized.py => parameterized.pyx} (99%) rename param/{parameters.py => parameters.pyx} (100%) rename param/{reactive.py => reactive.pyx} (100%) diff --git a/param/_utils.py b/param/_utils.pyx similarity index 99% rename from param/_utils.py rename to param/_utils.pyx index 4ca9b131b..86c38d623 100644 --- a/param/_utils.py +++ b/param/_utils.pyx @@ -533,7 +533,7 @@ def concrete_descendents(parentclass): Only non-abstract classes will be included. """ - return {c.__name__:c for c in descendents(parentclass) + return {c.__name__: c for c in descendents(parentclass) if not _is_abstract(c)} def _abbreviate_paths(pathspec,named_paths): @@ -582,13 +582,6 @@ def exceptions_summarized(): print(f"{etype.__name__}: {value}", file=sys.stderr) -def _in_ipython(): - try: - get_ipython() - return True - except NameError: - return False - _running_tasks = set() def async_executor(func): diff --git a/param/parameterized.py b/param/parameterized.pyx similarity index 99% rename from param/parameterized.py rename to param/parameterized.pyx index c4c4d3171..1f26e10b9 100644 --- a/param/parameterized.py +++ b/param/parameterized.pyx @@ -46,7 +46,6 @@ _deprecated, _deprecate_positional_args, _dict_update, - _in_ipython, _is_auto_name, _is_mutable_container, _recursive_repr, @@ -57,20 +56,8 @@ descendents, ) -# Ideally setting param_pager would be in __init__.py but param_pager is -# needed on import to create the Parameterized class, so it'd need to precede -# importing parameterized.py in __init__.py which would be a little weird. -if _in_ipython(): - # In case the optional ipython module is unavailable - try: - from .ipython import ParamPager, ipython_async_executor as async_executor - param_pager = ParamPager(metaclass=True) # Generates param description - except ImportError: - from ._utils import async_executor -else: - from ._utils import async_executor - param_pager = None - +from ._utils import async_executor +param_pager = None from inspect import getfullargspec diff --git a/param/parameters.py b/param/parameters.pyx similarity index 100% rename from param/parameters.py rename to param/parameters.pyx diff --git a/param/reactive.py b/param/reactive.pyx similarity index 100% rename from param/reactive.py rename to param/reactive.pyx diff --git a/pyproject.toml b/pyproject.toml index 37cc2fc77..450389f4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,15 @@ [build-system] -requires = ["hatchling", "hatch-vcs"] +requires = ["hatchling", "hatch-vcs", 'hatch-cython', 'cython'] build-backend = "hatchling.build" +[tool.hatch.build.targets.wheel.hooks.cython] +dependencies = ["hatch-cython", 'cython'] + +[tool.hatch.build.targets.wheel.hooks.cython.options] +includes = [] +directives = { boundscheck = false, nonecheck = false, language_level = 3, binding = true } +compile_py = false + [project] name = "param" dynamic = ["version"] @@ -92,6 +100,9 @@ Releases = "https://github.com/holoviz/param/releases" Source = "https://github.com/holoviz/param" HoloViz = "https://holoviz.org/" +[tool.setuptools] +packages = ["param", "numbergen"] + [tool.hatch.version] source = "vcs" @@ -100,8 +111,8 @@ include = [ "/param", "/numbergen", ] - [tool.hatch.build.targets.sdist] +packages = ["param", "numbergen"] include = [ "/param", "/numbergen",