Skip to content
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

To use the cython extension with windows ... #7

Closed
gitoops opened this issue Nov 11, 2016 · 8 comments
Closed

To use the cython extension with windows ... #7

gitoops opened this issue Nov 11, 2016 · 8 comments

Comments

@gitoops
Copy link

gitoops commented Nov 11, 2016

I had to do the following modifications:

  1. Install the msvc for python https://www.microsoft.com/en-us/download/details.aspx?id=44266
  2. Adjust the setup.py a) to not use stdlibc++, b) to use cythonize (from Cython.Build import cythonize and in kwargs change ext_module to 'ext_modules': cythonize(extensions), c) import numpy and add include_dirs=[numpy.get_include()], in extensions:
from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
import os.path
import warnings
import numpy

classifiers = [
    'Programming Language :: Python :: 2',
    'Programming Language :: Python :: 3',
    'Intended Audience :: Science/Research',
    'License :: OSI Approved :: MIT License',
    'Topic :: Scientific/Engineering'
]

extensions = [Extension(
        'fastdtw._fastdtw',
        [os.path.join('fastdtw', "_fastdtw.pyx")],
        language="c++",
        include_dirs=[numpy.get_include()],
#       if you want to debug from MSVC IDE uncomment the following
#        extra_compile_args=["-Zi", "/Od"],
#        extra_link_args=["-debug"],

#        libraries=["stdc++","stdc"]
    )]

kwargs = {
    'name': 'fastdtw',
    'version': '0.3.0',
    'author': 'Kazuaki Tanida',
    'url': 'https://github.com/slaypni/fastdtw',
    'description': 'Dynamic Time Warping (DTW) algorithm with an O(N) time and memory complexity.',
    'license': 'MIT',
    'keywords': ['dtw'],
    'install_requires': ['numpy'],
    'packages': find_packages(),
    'ext_modules':  cythonize(extensions),
    'test_suite': 'tests',
    'setup_requires': ['pytest-runner'],
    'tests_require': ['pytest'],
    'classifiers': classifiers
}

try:
    setup(**kwargs)
except SystemExit:
    del kwargs['ext_modules']
    warnings.warn('compilation failed. Installing pure python package')
    setup(**kwargs)
  1. Modify the cpx to use the INFINITY definition from numpy:
#from libc.math cimport INFINITY,pow, fabs
from libc.math cimport pow, fabs
from numpy.math cimport INFINITY

Thank you for your great work!

Jan

@gitoops gitoops changed the title To use that great extension with windows ... To use the cython extension with windows ... Nov 11, 2016
@slaypni
Copy link
Owner

slaypni commented Nov 12, 2016

@gitoops Thank you for pointing it out!

I made PR #8 which might solve this problem by fixing some of what you mentioned. Could you see it to find if it works?

@gitoops
Copy link
Author

gitoops commented Nov 28, 2016

I tried but unfortunately it doesen't compile out of the box´, falls back to install the pure python version.

Additionally I found with the version I compiled for Windows deviations depending on order of vectors: fastdtw(A,B) different to fastdtw(B,A). I would expect it should be the same. The pure python gives the correct solution independent of the order A,B or B,A.
The test was with vectors of length 120, y values betwen 0 and 1000.
Do you see the same issue with linux? Any idea what the problem causes?

Kind regards
Jan

@gitoops
Copy link
Author

gitoops commented Nov 30, 2016

Okay, increasing the radius improved the precision and the distance A->B becomes B->A.

@shuffle2
Copy link

shuffle2 commented Apr 6, 2018

Current master is still broken on windows/cython. The reason is that stdc++ library does not exist. The module seems to compile and work fine if just removing this library reference. @slaypni please do that (I would, but don't know the "correct way" to do it within setup.py :) )

@slaypni
Copy link
Owner

slaypni commented Apr 10, 2018

@shuffle2 I am also not good at writing setup.py.😭PR is welcome!

@Seanny123
Copy link

Seems to be fixed on Windows 10. I think you can close this issue.

@slaypni
Copy link
Owner

slaypni commented Nov 5, 2018

@Seanny123 Thx!

@slaypni slaypni closed this as completed Nov 5, 2018
@shuffle2
Copy link

shuffle2 commented Nov 5, 2019

Well, it's not fixed (how would it be with no changes?). I still had to remove stdc++ reference from setup.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants