import os
import warnings


def custom_formatwarning(msg, category, *args, **kwargs):
    # ignore everything except the message
    return "{}: {}\n".format(category.__name__, msg)


warnings.formatwarning = custom_formatwarning
# Filter numpy version warnings because they are not relevant
warnings.filterwarnings("ignore", message="numpy.dtype size changed")


def get_execution_engine():
    # In the future, when there are multiple engines and different ways of
    # backing the DataFrame, there will have to be some changed logic here to
    # decide these things. In the meantime, we will use the currently supported
    # execution engine + backing (Pandas + Ray).
    if "MODIN_ENGINE" in os.environ:
        # .title allows variants like ray, RAY, Ray
        engine = os.environ["MODIN_ENGINE"].title()
    else:
        if "MODIN_DEBUG" in os.environ:
            engine = "Python"
        else:
            try:
                import ray

                engine = "Ray"
            except ImportError:
                try:
                    import dask
                    import distributed

                    engine = "Dask"
                except ImportError:
                    raise ImportError(
                        "Please `pip install modin[ray] or modin[dask] to install an engine"
                    )
                else:
                    if (
                        str(dask.__version__) < "2.1.0"
                        or str(distributed.__version__) < "2.3.2"
                    ):
                        raise ImportError(
                            "Please `pip install modin[dask] to install compatible Dask version."
                        )
            else:
                if ray.__version__ != "0.8.0":
                    raise ImportError(
                        "Please `pip install modin[ray] to install compatible Ray version."
                    )
    return engine


def get_partition_format():
    # See note above about engine + backing.
    return os.environ.get("MODIN_BACKEND", "Pandas").title()


__version__ = "0.6.3"
__execution_engine__ = get_execution_engine()
__partition_format__ = get_partition_format()

# We don't want these used outside of this file.
del get_execution_engine
del get_partition_format

@@ -3,16 +3,27 @@
 port os%0A
+import sys%0A
 import w
@@ -775,24 +775,22 @@
         
-engine =
+return
  os.envi
@@ -879,24 +879,22 @@
         
-engine =
+return
  %22Python
@@ -913,35 +913,58 @@
 se:%0A            
-try
+if sys.platform != %22win32%22
 :%0A              
@@ -969,19 +969,12 @@
     
-import ray%0A
+try:
 %0A   
@@ -990,23 +990,28 @@
     
-engine = %22Ray%22%0A
+    import ray%0A%0A    
     
@@ -1058,157 +1058,94 @@
     
-try:%0A                    import dask%0A                    import distributed%0A%0A                    engine = %22Dask%22%0A                except ImportError:%0A
+    pass%0A                else:%0A                    if ray.__version__ != %220.8.0%22:%0A    
     
@@ -1171,32 +1171,36 @@
 se ImportError(%0A
+    
                 
@@ -1242,46 +1242,50 @@
 ray%5D
- or modin%5Bdask%5D to install an engine%22%0A
+%60 to install compatible Ray version.%22%0A    
     
@@ -1314,39 +1314,41 @@
             
-else:%0A         
+    return %22Ray%22%0A
            i
@@ -1350,12 +1350,13 @@
     
-if (
+ try:
 %0A   
@@ -1372,145 +1372,88 @@
     
-        str(dask.__version__) %3C %222.1.0%22%0A                        or str(distributed.__version__) %3C %222.3.2%22%0A                    ):%0A        
+import dask%0A                import distributed%0A%0A            except ImportError:%0A
     
@@ -1499,32 +1499,24 @@
             
-        
 %22Please %60pip
@@ -1520,24 +1520,26 @@
 pip install 
+%7B%7D
 modin%5Bdask%5D 
@@ -1537,16 +1537,17 @@
 in%5Bdask%5D
+%60
  to inst
@@ -1554,32 +1554,103 @@
 all 
-compatible Dask version.
+an engine%22.format(%0A                        %22modin%5Bray%5D%60 or %60%22 if sys.platform != %22win32%22 else %22
 %22%0A  
@@ -1647,32 +1647,46 @@
 else %22%22%0A        
+            )%0A
                 
@@ -1728,34 +1728,141 @@
  if 
-ray.__version__ != %220.8.0%22
+(%0A                    str(dask.__version__) %3C %222.1.0%22%0A                    or str(distributed.__version__) %3C %222.3.2%22%0A                )
 :%0A  
@@ -1949,20 +1949,22 @@
 l modin%5B
-ray%5D
+dask%5D%60
  to inst
@@ -1970,35 +1970,36 @@
 tall compatible 
-Ray
+Dask
  version.%22%0A     
@@ -2011,24 +2011,36 @@
           )%0A
+            
     return e
@@ -2038,22 +2038,22 @@
  return 
-engine
+%22Dask%22
 %0A%0A%0Adef g

Restructure import attempt to only try Ray if on a non-windows machine (#945)