-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I tried to compile a single file my_wiggle_falloff.pyx based on wiggle_falloff.pyx, and it pops up an error relative cimport beyong main package is not allowed. Below is the setup.py. Is it possible to compile a single file rather than the whole package? #1895
Comments
You probably need to set the include dir to the Animation Nodes header and import using a path relative to the Animation Nodes module. See the Cython section of the developer guide for extensions: |
Thanks Omar!Will try! |
Hi Omar, extensions = [ ] setup(name='my_wiggle_falloff',
Hi Omar, extensions = [ ] setup(name='my_wiggle_falloff', |
Can you provide a more complete version of what you are trying to do so that I can test it locally? |
from setuptools import setup, Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
extensions = [
Extension(
"my_wiggle_falloff",["my_wiggle_falloff.pyx"],
"include_dirs", ["C:/Users/UPC/Documents/Downloads/animation_nodes_headers"],
),
]
setup(name='my_wiggle_falloff',
ext_modules=cythonize(extensions),
)
import bpy
from bpy.props import *
from ... base_types import AnimationNode
from ... data_structures cimport BaseFalloff
from ... algorithms.perlin_noise cimport perlinNoise1D
class WiggleFalloffNode():
def execute(self, seed, evolution, speed, offset, amplitude, octaves, persistance):
evolution *= max(speed, 0) / 10
return WiggleFalloff(seed, evolution, offset, amplitude, octaves, persistance)
cdef class WiggleFalloff(BaseFalloff):
cdef:
double evolution
double offset, amplitude
double persistance
int octaves
def __cinit__(self, float seed, float evolution,
float offset, float amplitude,
int octaves, float persistance):
self.evolution = seed * 341312 + evolution
self.amplitude = amplitude
self.persistance = persistance
self.offset = offset
self.octaves = min(max(octaves, 0), 100)
self.clamped = False
self.dataType = "NONE"
cdef float evaluate(self, void *object, Py_ssize_t index):
cdef double x = self.evolution + index * 1127
cdef double noise = perlinNoise1D(x, self.persistance, self.octaves)
return <float>(self.amplitude * noise + self.offset) |
You should probably set the include path in the cythonize function as follows: from Cython.Build import cythonize
from Cython.Distutils import build_ext
from setuptools import setup, Extension
extensions = [
Extension(
"my_wiggle_falloff", ["my_wiggle_falloff.pyx"]
),
]
setup(
name = "my_wiggle_falloff",
ext_modules = cythonize(extensions,
include_path = ["/path/to/animation_nodes_headers", "."],
compiler_directives = {"language_level" : "3"}),
) And use absolute imports relative to the from animation_nodes.data_structures cimport BaseFalloff
from animation_nodes.algorithms.perlin_noise cimport perlinNoise1D |
It worked well now. Thanks a lot Omar! Your supports are always great! |
Hi Omar, although the compilation is ok, when call my_wiggle_falloff, it will generate below errors:animation_nodes.data_structures.meshes,mesh_data.Mesh size changed ,may indicate binary incompatibility, expect 88 from c header, got 80 from pyobject. not sure why? |
This likely means that your headers are older/newer than your compiled files. Make sure both the headers and the compiled objects are of the same version. |
Thanks Omar again. |
I tried to compile a single file my_wiggle_falloff.pyx based on wiggle_falloff.pyx, and it pops up an error relative cimport beyong main package is not allowed. Below is the setup.py. Is it possible to compile a single file rather than the whole package?
extensions = [
Extension(
"my_wiggle_falloff",["my_wiggle_falloff.pyx"],
),
]
setup(name='my_wiggle_falloff',
ext_modules=cythonize(extensions),
include_dirs=["."],
cmdclass={'build_ext': build_ext},
)
The text was updated successfully, but these errors were encountered: