google / google/python-fire

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

Đang mở
#208 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
28.2k
Fork
1.5k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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) { ...}`
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.