google / google/python-fire

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

Aberta
#208 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
28.2k
Forks
1.5k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.