You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/19 08:27:45 UTC

[GitHub] [arrow] raulcd commented on a diff in pull request #13552: ARROW-18054: [Python][CI] Enable Cython tests on windows wheels

raulcd commented on code in PR #13552:
URL: https://github.com/apache/arrow/pull/13552#discussion_r999113417


##########
python/pyarrow/tests/test_cython.py:
##########
@@ -123,18 +123,31 @@ def test_cython_api(tmpdir):
         # pyarrow imported first.
         code = """if 1:
             import sys
+            import os
+
+            try:
+                # Add dll directory was added on python 3.8
+                # and is required in order to find extra DLLs
+                # only for win32
+                for dir in {library_dirs}:
+                    os.add_dll_directory(dir)
+            except AttributeError:
+                pass
 
             mod = __import__({mod_name!r})
             arr = mod.make_null_array(5)
             assert mod.get_array_length(arr) == 5
             assert arr.null_count == 5
-        """.format(mod_name='pyarrow_cython_example')
+        """.format(mod_name='pyarrow_cython_example',
+                   library_dirs=pa.get_library_dirs())
 
-        if sys.platform == 'win32':
+        if sys.platform == 'win32' and not \
+                getattr(os, 'add_dll_directory', False):
+            # Python 3.8 onwards don't check extension module DLLs on path
+            # we have to use os.add_dll_directory instead.

Review Comment:
   oops, you are completely right.



##########
python/pyarrow/tests/test_cython.py:
##########
@@ -123,18 +123,31 @@ def test_cython_api(tmpdir):
         # pyarrow imported first.
         code = """if 1:
             import sys
+            import os
+
+            try:
+                # Add dll directory was added on python 3.8
+                # and is required in order to find extra DLLs
+                # only for win32
+                for dir in {library_dirs}:
+                    os.add_dll_directory(dir)
+            except AttributeError:
+                pass
 
             mod = __import__({mod_name!r})
             arr = mod.make_null_array(5)
             assert mod.get_array_length(arr) == 5
             assert arr.null_count == 5
-        """.format(mod_name='pyarrow_cython_example')
+        """.format(mod_name='pyarrow_cython_example',
+                   library_dirs=pa.get_library_dirs())
 
-        if sys.platform == 'win32':
+        if sys.platform == 'win32' and not \
+                getattr(os, 'add_dll_directory', False):
+            # Python 3.8 onwards don't check extension module DLLs on path
+            # we have to use os.add_dll_directory instead.
             delim, var = ';', 'PATH'

Review Comment:
   thanks done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org