google / google/python-fire

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

Abierto
#208 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
28.2k
Forks
1.5k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.