From 8585a6085a978c3ea2ab325060784b1489b7d1e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20Sz=C5=B1cs?= Date: Mon, 23 Sep 2019 19:07:51 +0200 Subject: [PATCH] py2 compat --- python/pyarrow/fs.py | 2 ++ python/pyarrow/tests/conftest.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/python/pyarrow/fs.py b/python/pyarrow/fs.py index 23291203818d8..a8d9e02c61001 100644 --- a/python/pyarrow/fs.py +++ b/python/pyarrow/fs.py @@ -30,3 +30,5 @@ from pyarrow._s3 import S3FileSystem, initialize_s3, finalize_s3 # noqa except ImportError: pass +else: + pass # initialize_s3? diff --git a/python/pyarrow/tests/conftest.py b/python/pyarrow/tests/conftest.py index ace175458a2b0..1fb57ffffb27b 100644 --- a/python/pyarrow/tests/conftest.py +++ b/python/pyarrow/tests/conftest.py @@ -230,6 +230,22 @@ def datadir(): return pathlib.Path(__file__).parent / 'data' +try: + from tempfile import TemporaryDirectory +except ImportError: + import shutil + + class TemporaryDirectory(object): + """Temporary directory implementation for python 2""" + + def __enter__(self): + self.tmp = tempfile.mkdtemp() + return self.tmp + + def __exit__(self, exc_type, exc_value, traceback): + shutil.rmtree(self.tmp) + + @pytest.fixture(scope='module') @pytest.mark.s3 def minio_server(): @@ -244,7 +260,7 @@ def minio_server(): }) try: - with tempfile.TemporaryDirectory() as tempdir: + with TemporaryDirectory() as tempdir: args = ['minio', '--compat', 'server', '--quiet', '--address', address, tempdir] with subprocess.Popen(args, env=env) as proc: