Closed certik closed 3 years ago
I don't see an error, just a warning. So I don't know what the issue is.
Can you try pythran -v dprod.py
?
Sure, here is the output:
$ pythran -v dprod.py
INFO: sys file exists: /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythran.cfg
INFO: platform file exists: /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythran-darwin.cfg
WARNING: user file does not exist: /Users/certik/.pythranrc
INFO: pythranrc section [pythran] is valid and options are correct
INFO: pythranrc section [typing] is valid and options are correct
INFO: pythranrc section [compiler] is valid and options are correct
WARNING:root:No pythran specification, nothing will be exported
running build_ext
new_compiler returns <class 'distutils.unixccompiler.UnixCCompiler'>
building 'dprod' extension
C compiler: arm64-apple-darwin20.0.0-clang++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/certik/miniforge3/envs/pythran/include -arch arm64 -fPIC -O2 -isystem /Users/certik/miniforge3/envs/pythran/include -arch arm64 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/certik/miniforge3/envs/pythran/include -D_FORTIFY_SOURCE=2 -isystem /Users/certik/miniforge3/envs/pythran/include
creating /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpjtcdjtic/var
creating /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpjtcdjtic/var/folders
creating /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpjtcdjtic/var/folders/43
creating /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpjtcdjtic/var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc
creating /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpjtcdjtic/var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T
compile options: '-DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DPYTHRAN_BLAS_BLAS -I/Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran -I/Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/numpy/core/include -I/Users/certik/miniforge3/envs/pythran/include -I/Users/certik/miniforge3/envs/pythran/include/python3.10 -c'
extra options: '-std=c++11 -fno-math-errno -Wno-unused-function -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -isystem /Users/certik/miniforge3/envs/pythran/include'
arm64-apple-darwin20.0.0-clang++: /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpew0u0njj.cpp
In file included from /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpew0u0njj.cpp:1:
In file included from /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythonic/core.hpp:36:
In file included from /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythonic/types/slice.hpp:5:
In file included from /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythonic/types/NoneType.hpp:8:
In file included from /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythonic/builtins/bool_.hpp:7:
In file included from /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythonic/types/tuple.hpp:13:
In file included from /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythonic/types/ndarray.hpp:1303:
In file included from /Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythonic/types/numpy_operators.hpp:15:
/Users/certik/miniforge3/envs/pythran/lib/python3.10/site-packages/pythran/pythonic/operator_/lshift.hpp:22:15: warning: converting the result of '<<' to a boolean; did you mean '(a << b) != 0'? [-Wint-in-bool-context]
lshift, <<, (a <= (std::numeric_limits<decltype(b)>::max() >> b)))
^
1 warning generated.
arm64-apple-darwin20.0.0-clang++ -bundle -undefined dynamic_lookup -Wl,-rpath,/Users/certik/miniforge3/envs/pythran/lib -L/Users/certik/miniforge3/envs/pythran/lib -Wl,-rpath,/Users/certik/miniforge3/envs/pythran/lib -L/Users/certik/miniforge3/envs/pythran/lib -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/certik/miniforge3/envs/pythran/lib -L/Users/certik/miniforge3/envs/pythran/lib -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/certik/miniforge3/envs/pythran/include -D_FORTIFY_SOURCE=2 -isystem /Users/certik/miniforge3/envs/pythran/include /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpjtcdjtic/var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmpew0u0njj.o -L/Users/certik/miniforge3/envs/pythran/lib -lcblas -lblas -lcblas -lblas -o /var/folders/43/nspmtcpj5r589x58n_spl6jm000fsc/T/tmppi73t_lo/dprod.cpython-310-darwin.so -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/certik/miniforge3/envs/pythran/lib -L/Users/certik/miniforge3/envs/pythran/lib
ld: warning: -pie being ignored. It is only used when linking a main executable
INFO: Generated module: dprod
INFO:pythran:Generated module: dprod
INFO: Output: /Users/certik/dprod.cpython-310-darwin.so
INFO:pythran:Output: /Users/certik/dprod.cpython-310-darwin.so
So it seems to work? I assumed it didn't based on the error, but it seems it does work:
$ python
Python 3.10.0 | packaged by conda-forge | (default, Oct 12 2021, 21:22:54) [Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dprod
>>> dprod.__file__
'/Users/certik/dprod.cpython-310-darwin.so'
This looks fine... at least for the second run. The 'critical' in the first run are less encouraging.
Please note this warning:
WARNING:root:No pythran specification, nothing will be exported
In order to do something useful with your module, you need a pythran export
line (see https://pythran.readthedocs.io/en/latest/MANUAL.html#concerning-pythran-specifications)
Ah, adding #pythran export dprod(int list, int list)
fixed the problem, now it doesn't complain and it seems to work:
$ python
Python 3.10.0 | packaged by conda-forge | (default, Oct 12 2021, 21:22:54) [Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import a
>>> a.dprod.__doc__
'Supported prototypes:\n\n - dprod(int list, int list)'
>>> a.dprod([1,2], [3,4])
11
So I think this issue is fixed. But I think pythran should return more user friendly error that I forgot to add type annotation.
Well, we already have a warning, I don't know what could be done differently?
It seems if I forget to put in a type annotation, it should not fail in C++ as it does above? I thought it indicated there is some bug somewhere. If not, then this issue can be closed.
Closing the issue as we now both have a decent error message and a solution to the original problem :-)
Using the example from the tutorial using pythran 0.10.0 from conda-forge on Apple M1:
I get:
It doesn't show the actual error. But if I execute the command by hand, I get:
I don't see an error, just a warning. So I don't know what the issue is.