ratal / mdfreader

Read Measurement Data Format (MDF) versions 3.x and 4.x file formats in python
Other
169 stars 74 forks source link

missing cython requirement #127

Closed danielhrisca closed 5 years ago

danielhrisca commented 6 years ago
>python.exe -m pip install mdfreader
Collecting mdfreader
  Downloading mdfreader-2.7.4.tar.gz (653kB)
    100% |████████████████████████████████| 655kB 655kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Daniel\AppData\Local\Temp\pip-build-i93z7xpm\mdfreader\setup.py", line 6, in <module>
        from Cython.Build import cythonize
    ModuleNotFoundError: No module named 'Cython'
ratal commented 6 years ago

I do not reproduce your issue. I will check later on windows. Are you sure your config is ok because looking at Cython tutorial, I have exact same line for cythonize import ?

danielhrisca commented 6 years ago

Try with a Python installation or virtualenv that does not have cython already installed

ratal commented 6 years ago

cython is normally a requirement for mdfreader but you want to propose it as an optionnal requirement ?

danielhrisca commented 6 years ago

Actually the problem is if you need cython during the installation, and cython is not already installed, you will get the error even though cython is included in the _installrequires

This probably helps: http://cython.readthedocs.io/en/latest/src/reference/compilation.html?highlight=compilation#distributing-cython-modules

ratal commented 6 years ago

Thanks Daniel for the tip. I think on linux, there is no issue installing cython and have correct compilation environment. But on windows, most difficult is probably to have suitable compilation environment rather than installing cython. Do you experiment and want to include it in asammdf for performance up ?

ratal commented 6 years ago

I modified setup.py to avoid error when cython is not installed, in last commit, thanks.

danielhrisca commented 6 years ago

It's a real pain in the ass to get the compilation working in Windows, this is why I normally rely on WinPython and https://www.lfd.uci.edu/~gohlke/pythonlibs/ , and I will just use numpy without custom cython or C extensions for asammdf.

Like I said the cython issue came when I had to use a stripped down Pyhon installation that did not have cython installed (WinPyhton 3.7.0 in this particular case)

ratal commented 6 years ago

Doing the same for windows but using anaconda. For big files (several Gb), I think cython is worth the pain for mdfreader. Should be ok now, closing but reopen if you face again this issue.

waltherg commented 6 years ago

@ratal I second the issue raised by @danielhrisca: the way you import numpy, Cython etc. at the top of your setup.py file is for lack of a better expression just plain wrong. These imports at the top of your setup.py break the usual way Python packages are installed - requirements of your package should be listed somewhere in your setup.py so that they're installed but you shouldn't import them in your setup.py the way you're doing it right now.

See the setup.py file of e.g. pandas which also relies heavily on numpy:

https://github.com/pandas-dev/pandas/blob/master/setup.py

ratal commented 6 years ago

Thanks, I remove all import in header and made sure it woudl install without cython, in dev branch

danielhrisca commented 6 years ago
daniel@daniel-VirtualBox:~$ pip3 install cython
Collecting cython
  Downloading https://files.pythonhosted.org/packages/19/eb/c4d9f3beafd5ac0615936860bcee41d93ca58f8734a16715da0037d2c468/Cython-0.28.2-cp36-cp36m-manylinux1_x86_64.whl (3.4MB)
    100% |████████████████████████████████| 3.4MB 398kB/s 
Installing collected packages: cython
Successfully installed cython-0.28.2
daniel@daniel-VirtualBox:~$ pip3 install https://github.com/ratal/mdfreader/archive/dev.zip
Collecting https://github.com/ratal/mdfreader/archive/dev.zip
  Downloading https://github.com/ratal/mdfreader/archive/dev.zip
     / 450kB 706kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 346, in get_provider
        module = sys.modules[moduleOrReq]
    KeyError: 'numpy'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-zkevh2nd-build/setup.py", line 9, in <module>
        numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1136, in resource_filename
        return get_provider(package_or_requirement).get_resource_filename(
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 348, in get_provider
        __import__(moduleOrReq)
    ModuleNotFoundError: No module named 'numpy'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-zkevh2nd-build/
AkbarAlam commented 6 years ago

I have tried to install and still have this problem. any solution?

ratal commented 6 years ago

Hi Daniel, I guess you have this error because there is no numpy installed in your virtual environment, completly virgin except Cython ? I looked a bit and coud not find any other way than just informing user he should install numpy. Normally pip should handle this depency but with this code, it is not possible I think; I need those include_dirs and if numpy is not installed I do not know how to request numpy install.

ratal commented 6 years ago

Hi Gourab, I guess your issue is the one described at the beginning of this thread. Did you try installing the git dev branch ?

danielhrisca commented 6 years ago

Hello Aymeric,

this happened on a fresh Ubuntu install. There must be a way to make this work, maybe you should have a deeper look at some other projects.

cristi-neagu commented 6 years ago

Could this work? https://packaging.python.org/guides/distributing-packages-using-setuptools/#install-requires

danielhrisca commented 6 years ago

@cristi-neagu https://github.com/ratal/mdfreader/blob/dev/setup.py#L76

cristi-neagu commented 6 years ago

I see it's already in here. Thanks

AkbarAlam commented 6 years ago

@ratal yeah . but getting this error error: Setup script exited with error: Unable to find vcvarsall.bat

ratal commented 6 years ago

Hi, I think this is different issue (here about how to install mdfreader without cython installed) You are trying to build dataRead cython (you probably installed) module but you are missing Microsoft Visual C++ Compiler for you installed Python version. Up to you, either install with (need proper compilation environment) or without cython (pure python)