I'm afraid I don't really know what to provide here. I'm a bit lost. Google sends me in entirely irrelevant directions.
I've just upgraded to Python 3.5 and am now trying to get my current project working with it. Unfortunately, part of it is done in Cython, and I've had to spend the last three days trying to get Python to talk to MinGW. Now I've done that via this patch, but the compilation still fails.
This file compiled flawlessly previously, so presumably it's something about the way Cython is set up.
Here's the full text of the command I give and the error message:
>python setup.py build --compiler=mingw32
running build
running build_ext
building 'fx' extension
C:\mingw\bin\gcc.exe -mdll -O -Wall -IC:\Python35-32\lib\site-packages\numpy\core\include -IC:\Python35-32\include -IC:\Python35-32\include -c fx.c -o build\temp.win32-3.5\Release\fx.o
In file included from C:\Python35-32\include/Python.h:65:0,
from fx.c:12:
C:\Python35-32\include/pytime.h:113:5: warning: 'struct timeval' declared inside parameter list
_PyTime_round_t round);
^
C:\Python35-32\include/pytime.h:118:5: warning: 'struct timeval' declared inside parameter list
_PyTime_round_t round);
^
In file included from C:\Python35-32\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:1781:0,
from C:\Python35-32\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Python35-32\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from fx.c:250:
C:\Python35-32\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h:12:9: note: #pragma message: C:\Python35-32\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it by " \
^
writing build\temp.win32-3.5\Release\fx.cp35-win32.def
C:\mingw\bin\gcc.exe -shared -s build\temp.win32-3.5\Release\fx.o build\temp.win32-3.5\Release\fx.cp35-win32.def -LC:\Python35-32\libs -LC:\Python35-32\PCbuild\win32 -lpython35 -lvcruntime140 -o build\lib.win32-3.5\fx.cp35-win32.pyd
c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ld.exe: cannot find -lvcruntime140
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\mingw\\bin\\gcc.exe' failed with exit status 1
I've tried adding #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
to the beginning of the generated fx.c
and trying again, but that just produces different error messages along the lines of "that method does not exist" which suggests Cython depends on the deprecated API of which it speaks.
Here's setup.py:
from distutils.core import setup
from Cython.Build import cythonize
import numpy
setup(options={'build_ext': {'compiler': 'mingw32'},
"compiler_directives":{"language_level": "3"}},
ext_modules=cythonize("fx.pyx"),
include_dirs=[numpy.get_include()])
And finally, here's fx.pyx itself:
import pygame
cimport numpy
import numpy.random
import random
from libc.stdlib cimport abs
#I added this because some soverflo answer suggested it but it doesn't appear to help
numpy.import_array()
cpdef chromatic_aberration(surface,int intensity=5):
cdef int x,y,z,maxx,maxy
cdef numpy.ndarray[unsigned char,ndim=3] array
cdef numpy.ndarray[unsigned char,ndim=2] r,g,b
r=pygame.surfarray.pixels_red(surface)
g=pygame.surfarray.pixels_green(surface)
b=pygame.surfarray.pixels_blue(surface)
array=pygame.surfarray.pixels3d(surface)
maxx,maxy=surface.get_rect().bottomright
for x in range(maxx):
for y in range(maxy):
try:
pass
array[x,y,0]=r[x+intensity,y]
array[x,y,1]=g[x,y+intensity]
array[x,y,2]=b[x+intensity,y-intensity]
except IndexError:
pass
cpdef mapped_chromatic_aberration(surface, numpy.ndarray[int,ndim=2] intensitymap):
cdef int x,y,z,maxx,maxy,intensity
cdef numpy.ndarray[unsigned char,ndim=3] array
cdef numpy.ndarray[unsigned char,ndim=2] r,g,b
r=pygame.surfarray.pixels_red(surface)
g=pygame.surfarray.pixels_green(surface)
b=pygame.surfarray.pixels_blue(surface)
array=pygame.surfarray.pixels3d(surface)
maxx,maxy=surface.get_rect().bottomright
for x in range(maxx):
for y in range(maxy):
try:
pass
intensity=intensitymap[x,y]
array[x,y,0]=r[x+intensity,y]
array[x,y,1]=g[x,y+intensity]
array[x,y,2]=b[x+intensity,y-intensity]
except IndexError:
pass
cpdef random_chromatic_aberration(surface,int intensity=5):
mapped_chromatic_aberration(surface,numpy.random.random_integers(-intensity,intensity,surface.get_rect().bottomright))
cpdef chroma_warp(surface,int x, int y, int radius, int power):
cdef numpy.ndarray[int,ndim=2] warpmap
warpmap=numpy.zeros(surface.get_size(), dtype=numpy.int)
cdef int maxdist = radius ** 2
cdef int maxx, minx, maxy, miny, warpx, warpy
for xofst in range(-radius, radius):
for yofst in range(-radius, radius):
warpx=x+xofst
warpy=y+yofst
warpmap[warpx,warpy] = ((abs(xofst) + abs(yofst)) * power) // 100
mapped_chromatic_aberration(surface, warpmap)
def screenshake(surf,intensity=3):
surf.scroll(random.randint(-intensity,intensity),random.randint(-intensity,intensity))
I've also tried using build_ext
instead of build
, but that produced identical results.
I'm sorry for the "here's some text what's wrong with my program" style question but I seriously have no idea what the hell is going on. Can someone point me in the right direction?