Re: cython3: Cannot start!

2018-12-24 Thread Paulo da Silva
Às 14:07 de 24/12/18, Stefan Behnel escreveu:
> Paulo da Silva schrieb am 22.12.18 um 19:26:
...

> 
> Ubuntu 18.04 ships Cython 0.26, which has a funny bug that you hit above.
> It switches the language-level too late, so that the first token (or word)
> in the file is parsed with Py2 syntax. In your case, that's the print
> statement, which is really parsed as (Py2) statement here, not as (Py3)
> function. In normal cases, the language level does not matter for the first
> statement in the source (because, why would you have a print() there?), so
> it took us a while to find this bug.
> 
> pip-installing Cython will get you the latest release, where this bug is
> resolved.
> 

Thank you Stefan for the clarification.
Regards.
Paulo

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: cython3: Cannot start!

2018-12-24 Thread Stefan Behnel
Paulo da Silva schrieb am 22.12.18 um 19:26:
> Sorry if this is OT.
> 
> I decided to give cython a try and cannot run a very simple program!
> 
> 1. I am using kubuntu 18.04 and installe cython3 (not cython).
> 
> 2. My program tp.pyx:
> 
> # cython: language_level=3
> print("Test",2)
> 
> 3. setup.py
> from distutils.core import setup
> from Cython.Build import cythonize
> 
> setup(
> ext_modules = cythonize("tp.pyx")
> )
> 
> 4. Running it:
> python3 setup.py build_ext --inplace
> python3 -c 'import tp'
> 
> 5. output:
> ('Test', 2)
> 
> This is wrong for python3! It should output
> Test 2
> 
> It seems that it is parsing tp.pyx as a python2 script!
> 
> I tried to change the print to python2
> print "Test",2
> 
> and it recognizes the syntax and outputs
> Test 2
> 
> So, how can I tell cython to use python3?

Ubuntu 18.04 ships Cython 0.26, which has a funny bug that you hit above.
It switches the language-level too late, so that the first token (or word)
in the file is parsed with Py2 syntax. In your case, that's the print
statement, which is really parsed as (Py2) statement here, not as (Py3)
function. In normal cases, the language level does not matter for the first
statement in the source (because, why would you have a print() there?), so
it took us a while to find this bug.

pip-installing Cython will get you the latest release, where this bug is
resolved.

Stefan

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: cython3: Cannot start! [RESOLVED]

2018-12-22 Thread Paulo da Silva
Às 19:48 de 22/12/18, MRAB escreveu:
> On 2018-12-22 18:26, Paulo da Silva wrote:
...


> Well, I've just tried this on Raspbian with the same files (for Python 3):
> 
> python3 -m pip install cython
> python3 setup.py build_ext --inplace
> python3 -c 'import tp'
> 
> and it printed:
> 
> Test 2

OK. I uninstalled the distributed cython3 and installed it using pip3.
Now it works!

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: cython3: Cannot start!

2018-12-22 Thread MRAB

On 2018-12-22 18:26, Paulo da Silva wrote:

Hi!
Sorry if this is OT.

I decided to give cython a try and cannot run a very simple program!

1. I am using kubuntu 18.04 and installe cython3 (not cython).

2. My program tp.pyx:

# cython: language_level=3
print("Test",2)

3. setup.py
from distutils.core import setup
from Cython.Build import cythonize

setup(
 ext_modules = cythonize("tp.pyx")
)

4. Running it:
python3 setup.py build_ext --inplace
python3 -c 'import tp'

5. output:
('Test', 2)

This is wrong for python3! It should output
Test 2

It seems that it is parsing tp.pyx as a python2 script!

I tried to change the print to python2
print "Test",2

and it recognizes the syntax and outputs
Test 2

So, how can I tell cython to use python3?

Thanks for any help/comments


Well, I've just tried this on Raspbian with the same files (for Python 3):

python3 -m pip install cython
python3 setup.py build_ext --inplace
python3 -c 'import tp'

and it printed:

Test 2
--
https://mail.python.org/mailman/listinfo/python-list


cython3: Cannot start!

2018-12-22 Thread Paulo da Silva
Hi!
Sorry if this is OT.

I decided to give cython a try and cannot run a very simple program!

1. I am using kubuntu 18.04 and installe cython3 (not cython).

2. My program tp.pyx:

# cython: language_level=3
print("Test",2)

3. setup.py
from distutils.core import setup
from Cython.Build import cythonize

setup(
ext_modules = cythonize("tp.pyx")
)

4. Running it:
python3 setup.py build_ext --inplace
python3 -c 'import tp'

5. output:
('Test', 2)

This is wrong for python3! It should output
Test 2

It seems that it is parsing tp.pyx as a python2 script!

I tried to change the print to python2
print "Test",2

and it recognizes the syntax and outputs
Test 2

So, how can I tell cython to use python3?

Thanks for any help/comments
-- 
https://mail.python.org/mailman/listinfo/python-list