google / google/python-fire

`fire.Fire()` not work with functions in cython compiled .pyd file

未关闭
#208 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
28.2k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

描述

Hi, i have a foo.py file compiled to foo.pyd by cython,
then use `fire.Fire()` to make it a cli like below,
instead output `1 2 3` i get `2 3 3`,
seems because cython treat functions as `PyObject` with first argument `self` after i checked the generated .c file.
any idea to make this work except wrap it one by one by another normal python function ? (not want to wrap because maybe many functions in foo.py later and bar.py will be compiled to bar.pyd called by another main.py, then the wrapper become cython function too...)

```python
# bar.py
from foo import * # import from foo.pyd not foo.py
fire.Fire()
```

```python
# foo.py
def test_fn(a=1, b=2, c=3):
print(a, b, c)
```

```c
// foo.c for foo.pyd
`static PyObject *__pyx_pw_19test_fn_3foo_1foo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { ...}`
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。