Repository: mne-tools/mne-python

Issue:
Bug: mne import failure
Upgrading a stable version of mne-python (0.17.0) to the current developement version (0.18.dev0) leads to an error when importing the module mne. The upgrade was done via the pip install --upgrade command.

OS: Windows 10
conda --version: conda 4.6.3
python --version: Python 3.6.5 :: Anaconda, Inc.

# Creating a new mne environment with conda
```
(Anaconda Prompt)
 curl --remote-name https://raw.githubusercontent.com/mne-tools/mne-python/master/environment.yml
 conda env create -f environment.yml -n mne_dev

```
# pip-upgrade to developement version
```
(Anaconda Prompt)
conda activate mne_dev
pip install --upgrade --no-deps git+https://github.com/mne-tools/mne-python.git
```

# Error
```
(Anaconda Prompt)
python
>>> import mne
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda3\envs\mne_dev\lib\site-packages\mne\__init__.py", line 25, in <module>
    from .io.pick import (pick_types, pick_channels,
  File "C:\Anaconda3\envs\mne_dev\lib\site-packages\mne\io\__init__.py", line 24, in <module>
    from . import edf
  File "C:\Anaconda3\envs\mne_dev\lib\site-packages\mne\io\edf\__init__.py", line 7, in <module>
    from .edf import read_raw_edf, read_raw_bdf, read_raw_gdf, find_edf_events
  File "C:\Anaconda3\envs\mne_dev\lib\site-packages\mne\io\edf\edf.py", line 34, in <module>
    md5='12134a9be7e0bfa5941e95f8bfd330f7')
  File "C:\Anaconda3\envs\mne_dev\lib\site-packages\mne\io\edf\_utils.py", line 19, in _load_gdf_events_lut
    fname)
ValueError: File C:\Anaconda3\envs\mne_dev\lib\site-packages\mne\io\edf\gdf_encodes.txt is corrupted. mdf5 hashes don't match.
```

**Another try with a cloned git repository and "python setup.py develop" resulted in the same error.**

#### Expected results
A working mne-python environment

#### Actual results
Import of the module "mne" not possible

#### Additional information
mne.sys_info() not available due to import failure of mne



Discussion:
I cannot replicate the problem on my mac.

maybe @OlehKSS you can try to replicate on your windows machine?
@agramfort I replicated the steps mentioned above and got the same issue on my Windows 10 laptop
does it mean that appveyor is broken? https://ci.appveyor.com/project/mne-tools/mne-python/branch/master is green.

Can you check if there's anything wrong with the hasing function?
```py
import hashlib

FILE = 'C:\Anaconda3\envs\mne_dev\lib\site-packages\mne\io\edf\gdf_encodes.txt'
# FILE = '/home/sik/code/mne-python/mne/io/edf/gdf_encodes.txt'

def hashfunc(fname, block_size=1048576, hash_type="md5"):  # 2 ** 20
    """Calculate the hash for a file.

    Parameters
    ----------
    fname : str
        Filename.
    block_size : int
        Block size to use when reading.

    Returns
    -------
    hash_ : str
        The hexadecimal digest of the hash.
    """
    if hash_type == "md5":
        hasher = hashlib.md5()
    elif hash_type == "sha1":
        hasher = hashlib.sha1()
    with open(fname, 'rb') as fid:
        while True:
            data = fid.read(block_size)
            if not data:
                break
            hasher.update(data)
    return hasher.hexdigest()

print(hashfunc(FILE))

```
This is what I get
```
12134a9be7e0bfa5941e95f8bfd330f7
```
This is what I get
41696b162526f559dd7d139352eae178

can you compare the files you get on windows and on linux? can you confirm that the same file produces differents hashes on unix or win?
This is the file that I have on my system
[gdf_encodes.txt](https://github.com/mne-tools/mne-python/files/2864976/gdf_encodes.txt)

can you check that you have different hash on windows or linux?

>

The files have different line endings, on Windows they are CR-LF and on Unix LF
(yes the hashes are different, the Windows one is 41696b162526f559dd7d139352eae178 and Unix 12134a9be7e0bfa5941e95f8bfd330f7)

Resolving patch:
diff --git a/mne/io/edf/_utils.py b/mne/io/edf/_utils.py
--- a/mne/io/edf/_utils.py
+++ b/mne/io/edf/_utils.py
@@ -9,12 +9,18 @@
 #
 # License: BSD (3-clause)
 
+import os.path as op
 import re
+
 from ...utils import hashfunc
 
 
-def _load_gdf_events_lut(fname, md5):
-    if hashfunc(fname, hash_type='md5') != md5:
+def _load_gdf_events_lut():
+    fname = op.join(op.dirname(__file__), 'gdf_encodes.txt')
+    hash_ = hashfunc(fname, hash_type='md5')
+    # Linux or Windows line endings
+    if hash_ not in ('12134a9be7e0bfa5941e95f8bfd330f7',
+                     '41696b162526f559dd7d139352eae178'):
         raise ValueError("File %s is corrupted. mdf5 hashes don't match." %
                          fname)
 
diff --git a/mne/io/edf/edf.py b/mne/io/edf/edf.py
--- a/mne/io/edf/edf.py
+++ b/mne/io/edf/edf.py
@@ -16,7 +16,6 @@
 import re
 
 import numpy as np
-import os.path as op
 
 from ...utils import verbose, logger, warn
 from ..utils import _blk_read_lims
@@ -29,9 +28,7 @@
 from ._utils import _load_gdf_events_lut
 
 
-GDF_EVENT_ENCODES_FILE = op.join(op.dirname(__file__), 'gdf_encodes.txt')
-GDF_EVENTS_LUT = _load_gdf_events_lut(fname=GDF_EVENT_ENCODES_FILE,
-                                      md5='12134a9be7e0bfa5941e95f8bfd330f7')
+GDF_EVENTS_LUT = _load_gdf_events_lut()
 
 
 @deprecated('find_edf_events is deprecated in 0.18, and will be removed'


Test patch: