From 21fe8ebfdd74ccc94c4f4262704a8a69e4aeca44 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Thu, 30 Mar 2017 15:24:51 -0400 Subject: [PATCH] Make pandas not a hard requirement, flake8 fixes Change-Id: If456bd85af664c4db8aea0203d7057a8b9aecd79 --- python/pyarrow/compat.py | 19 +++++++++++-------- python/setup.py | 21 +++++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/python/pyarrow/compat.py b/python/pyarrow/compat.py index 74d7ca2827bc..b9206aacbc9f 100644 --- a/python/pyarrow/compat.py +++ b/python/pyarrow/compat.py @@ -21,7 +21,6 @@ import itertools import numpy as np -import pandas as pd import sys import six @@ -31,6 +30,17 @@ PY26 = sys.version_info[:2] == (2, 6) PY2 = sys.version_info[0] == 2 +try: + import pandas as pd + if LooseVersion(pd.__version__) < '0.19.0': + pdapi = pd.core.common + from pandas.core.dtypes import DatetimeTZDtype + else: + from pandas.types.dtypes import DatetimeTZDtype + pdapi = pd.api.types + HAVE_PANDAS = True +except: + HAVE_PANDAS = False if PY26: import unittest2 as unittest @@ -117,13 +127,6 @@ def encode_file_path(path): return encoded_path -if LooseVersion(pd.__version__) < '0.19.0': - pdapi = pd.core.common - from pandas.core.dtypes import DatetimeTZDtype -else: - from pandas.types.dtypes import DatetimeTZDtype - pdapi = pd.api.types - integer_types = six.integer_types + (np.integer,) __all__ = [] diff --git a/python/setup.py b/python/setup.py index dae6cb2f078f..9ff091819c76 100644 --- a/python/setup.py +++ b/python/setup.py @@ -17,7 +17,6 @@ # specific language governing permissions and limitations # under the License. -import glob import os.path as osp import re import shutil @@ -83,16 +82,20 @@ def run(self): ('build-type=', None, 'build type (debug or release)'), ('with-parquet', None, 'build the Parquet extension'), ('with-jemalloc', None, 'build the jemalloc extension'), - ('bundle-arrow-cpp', None, 'bundle the Arrow C++ libraries')] + + ('bundle-arrow-cpp', None, + 'bundle the Arrow C++ libraries')] + _build_ext.user_options) def initialize_options(self): _build_ext.initialize_options(self) self.extra_cmake_args = os.environ.get('PYARROW_CMAKE_OPTIONS', '') self.build_type = os.environ.get('PYARROW_BUILD_TYPE', 'debug').lower() - self.with_parquet = strtobool(os.environ.get('PYARROW_WITH_PARQUET', '0')) - self.with_jemalloc = strtobool(os.environ.get('PYARROW_WITH_JEMALLOC', '0')) - self.bundle_arrow_cpp = strtobool(os.environ.get('PYARROW_BUNDLE_ARROW_CPP', '0')) + self.with_parquet = strtobool( + os.environ.get('PYARROW_WITH_PARQUET', '0')) + self.with_jemalloc = strtobool( + os.environ.get('PYARROW_WITH_JEMALLOC', '0')) + self.bundle_arrow_cpp = strtobool( + os.environ.get('PYARROW_BUNDLE_ARROW_CPP', '0')) CYTHON_MODULE_NAMES = [ 'array', @@ -300,8 +303,10 @@ def get_outputs(self): if not os.path.exists('../.git') and os.path.exists('../java/pom.xml'): import xml.etree.ElementTree as ET tree = ET.parse('../java/pom.xml') - version_tag = list(tree.getroot().findall('{http://maven.apache.org/POM/4.0.0}version'))[0] - os.environ["SETUPTOOLS_SCM_PRETEND_VERSION"] = version_tag.text.replace("-SNAPSHOT", "a0") + version_tag = list(tree.getroot().findall( + '{http://maven.apache.org/POM/4.0.0}version'))[0] + os.environ["SETUPTOOLS_SCM_PRETEND_VERSION"] = version_tag.text.replace( + "-SNAPSHOT", "a0") long_description = """Apache Arrow is a columnar in-memory analytics layer designed to accelerate big data. It houses a set of canonical in-memory @@ -321,7 +326,7 @@ def get_outputs(self): 'clean': clean, 'build_ext': build_ext }, - use_scm_version = {"root": "..", "relative_to": __file__}, + use_scm_version={"root": "..", "relative_to": __file__}, setup_requires=['setuptools_scm', 'cython >= 0.23'], install_requires=['numpy >= 1.9', 'six >= 1.0.0'], test_requires=['pytest'],