Back to home page

OSCL-LXR

 
 

    


0001 #
0002 # Licensed to the Apache Software Foundation (ASF) under one or more
0003 # contributor license agreements.  See the NOTICE file distributed with
0004 # this work for additional information regarding copyright ownership.
0005 # The ASF licenses this file to You under the Apache License, Version 2.0
0006 # (the "License"); you may not use this file except in compliance with
0007 # the License.  You may obtain a copy of the License at
0008 #
0009 #    http://www.apache.org/licenses/LICENSE-2.0
0010 #
0011 # Unless required by applicable law or agreed to in writing, software
0012 # distributed under the License is distributed on an "AS IS" BASIS,
0013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014 # See the License for the specific language governing permissions and
0015 # limitations under the License.
0016 #
0017 
0018 
0019 def require_minimum_pandas_version():
0020     """ Raise ImportError if minimum version of Pandas is not installed
0021     """
0022     # TODO(HyukjinKwon): Relocate and deduplicate the version specification.
0023     minimum_pandas_version = "0.23.2"
0024 
0025     from distutils.version import LooseVersion
0026     try:
0027         import pandas
0028         have_pandas = True
0029     except ImportError:
0030         have_pandas = False
0031     if not have_pandas:
0032         raise ImportError("Pandas >= %s must be installed; however, "
0033                           "it was not found." % minimum_pandas_version)
0034     if LooseVersion(pandas.__version__) < LooseVersion(minimum_pandas_version):
0035         raise ImportError("Pandas >= %s must be installed; however, "
0036                           "your version was %s." % (minimum_pandas_version, pandas.__version__))
0037 
0038 
0039 def require_minimum_pyarrow_version():
0040     """ Raise ImportError if minimum version of pyarrow is not installed
0041     """
0042     # TODO(HyukjinKwon): Relocate and deduplicate the version specification.
0043     minimum_pyarrow_version = "0.15.1"
0044 
0045     from distutils.version import LooseVersion
0046     import os
0047     try:
0048         import pyarrow
0049         have_arrow = True
0050     except ImportError:
0051         have_arrow = False
0052     if not have_arrow:
0053         raise ImportError("PyArrow >= %s must be installed; however, "
0054                           "it was not found." % minimum_pyarrow_version)
0055     if LooseVersion(pyarrow.__version__) < LooseVersion(minimum_pyarrow_version):
0056         raise ImportError("PyArrow >= %s must be installed; however, "
0057                           "your version was %s." % (minimum_pyarrow_version, pyarrow.__version__))
0058     if os.environ.get("ARROW_PRE_0_15_IPC_FORMAT", "0") == "1":
0059         raise RuntimeError("Arrow legacy IPC format is not supported in PySpark, "
0060                            "please unset ARROW_PRE_0_15_IPC_FORMAT")