[ 
https://issues.apache.org/jira/browse/ARROW-2131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16373083#comment-16373083
 ] 

ASF GitHub Bot commented on ARROW-2131:
---------------------------------------

wesm closed pull request #1640: ARROW-2131: [Python] Prepend module path to 
PYTHONPATH when spawning subprocess
URL: https://github.com/apache/arrow/pull/1640
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/pyarrow/tests/test_serialization.py 
b/python/pyarrow/tests/test_serialization.py
index 0917172d2..feccebbde 100644
--- a/python/pyarrow/tests/test_serialization.py
+++ b/python/pyarrow/tests/test_serialization.py
@@ -580,6 +580,22 @@ 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.abspath(
+        os.path.dirname(os.path.dirname(pa.__file__)))
+
+    env['PYTHONPATH'] = sep.join((module_path, existing_pythonpath))
+    return env
+
+
 def test_deserialize_buffer_in_different_process():
     import tempfile
     import subprocess
@@ -589,9 +605,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():


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Serialization test fails on Windows when library has been built in 
> place / not installed
> -------------------------------------------------------------------------------------------------
>
>                 Key: ARROW-2131
>                 URL: https://issues.apache.org/jira/browse/ARROW-2131
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>            Reporter: Wes McKinney
>            Assignee: Wes McKinney
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> I am not sure why this doesn't come up in Appveyor:
> {code}
> ================================== FAILURES 
> ===================================
> ________________ test_deserialize_buffer_in_different_process 
> _________________
>     def test_deserialize_buffer_in_different_process():
>         import tempfile
>         import subprocess
>         f = tempfile.NamedTemporaryFile(delete=False)
>         b = pa.serialize(pa.frombuffer(b'hello')).to_buffer()
>         f.write(b.to_pybytes())
>         f.close()
>         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])
> pyarrow\tests\test_serialization.py:596:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
> _
> popenargs = (['C:\\Miniconda3\\envs\\pyarrow-dev\\python.exe', 
> 'C:\\Users\\wesm\\code\\arrow\\python\\pyarrow\\tests\\deserialize_buffer.py',
>  'C:\\Users\\wesm\\AppData\\Local\\Temp\\tmp1gi__att'],)
> kwargs = {}, retcode = 1
> cmd = ['C:\\Miniconda3\\envs\\pyarrow-dev\\python.exe', 
> 'C:\\Users\\wesm\\code\\arrow\\python\\pyarrow\\tests\\deserialize_buffer.py',
>  'C:\\Users\\wesm\\AppData\\Local\\Temp\\tmp1gi__att']
>     def check_call(*popenargs, **kwargs):
>         """Run command with arguments.  Wait for command to complete.  If
>         the exit code was zero then return, otherwise raise
>         CalledProcessError.  The CalledProcessError object will have the
>         return code in the returncode attribute.
>         The arguments are the same as for the call function.  Example:
>         check_call(["ls", "-l"])
>         """
>         retcode = call(*popenargs, **kwargs)
>         if retcode:
>             cmd = kwargs.get("args")
>             if cmd is None:
>                 cmd = popenargs[0]
> >           raise CalledProcessError(retcode, cmd)
> E           subprocess.CalledProcessError: Command 
> '['C:\\Miniconda3\\envs\\pyarrow-dev\\python.exe', 
> 'C:\\Users\\wesm\\code\\arrow\\python\\pyarrow\\tests\\deserialize_buffer.py',
>  'C:\\Users\\wesm\\AppData\\Local\\Temp\\tmp1gi__att']' returned non-zero 
> exit status 1.
> C:\Miniconda3\envs\pyarrow-dev\lib\subprocess.py:291: CalledProcessError
> ---------------------------- Captured stderr call 
> -----------------------------
> Traceback (most recent call last):
>   File "C:\Users\wesm\code\arrow\python\pyarrow\tests\deserialize_buffer.py", 
> line 22, in <module>
>     import pyarrow as pa
> ModuleNotFoundError: No module named 'pyarrow'
> =============== 1 failed, 15 passed, 4 skipped in 0.40 seconds 
> ================
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to