From faa247af18e25de81dae301bb2a3a7a1218b5125 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Wed, 21 Feb 2018 16:37:15 -0500 Subject: [PATCH 1/2] Prepend development module path when spawning subprocess in test_serialization.py --- python/pyarrow/tests/test_serialization.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/python/pyarrow/tests/test_serialization.py b/python/pyarrow/tests/test_serialization.py index 0917172d22c..ed2fb00e1d0 100644 --- a/python/pyarrow/tests/test_serialization.py +++ b/python/pyarrow/tests/test_serialization.py @@ -580,6 +580,21 @@ def deserialize_regex(serialized, q): p.join() +def _get_modified_env_with_pythonpath(): + # Prepend pyarrow root directory to PYTHONPATH + env = os.environ.copy() + existing_pythonpath = env.get('PYTHONPATH', '') + if sys.platform == 'win32': + sep = ';' + else: + sep = ':' + + module_path, _ = os.path.split(pa.__path__[0]) + + env['PYTHONPATH'] = sep.join((module_path, existing_pythonpath)) + return env + + def test_deserialize_buffer_in_different_process(): import tempfile import subprocess @@ -589,9 +604,12 @@ def test_deserialize_buffer_in_different_process(): f.write(b.to_pybytes()) f.close() + subprocess_env = _get_modified_env_with_pythonpath() + dir_path = os.path.dirname(os.path.realpath(__file__)) python_file = os.path.join(dir_path, 'deserialize_buffer.py') - subprocess.check_call([sys.executable, python_file, f.name]) + subprocess.check_call([sys.executable, python_file, f.name], + env=subprocess_env) def test_set_pickle(): From 460ded1bc934d24d9dad25174b944af14b0ca153 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Wed, 21 Feb 2018 17:30:43 -0500 Subject: [PATCH 2/2] Use more idiomatic option for getting module parent directory Change-Id: I329012253d0500a8297f55e267f93604320312de --- python/pyarrow/tests/test_serialization.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/pyarrow/tests/test_serialization.py b/python/pyarrow/tests/test_serialization.py index ed2fb00e1d0..feccebbde36 100644 --- a/python/pyarrow/tests/test_serialization.py +++ b/python/pyarrow/tests/test_serialization.py @@ -589,9 +589,10 @@ def _get_modified_env_with_pythonpath(): else: sep = ':' - module_path, _ = os.path.split(pa.__path__[0]) + module_path = os.path.abspath( + os.path.dirname(os.path.dirname(pa.__file__))) - env['PYTHONPATH'] = sep.join((module_path, existing_pythonpath)) + env['PYTHONPATH'] = sep.join((module_path, existing_pythonpath)) return env