Skip to content

Commit 4668ea3

Browse files
sfc-gh-stakedaankit-bhatnagar167
authored andcommitted
SNOW-88209: Build python connector with extension on Win and Mac
1 parent 1793b78 commit 4668ea3

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

cpp/ArrowIterator/CArrowChunkIterator.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <Python.h>
88
#include <vector>
9+
#include <arrow/python/platform.h>
910
#include <arrow/api.h>
1011
#include <arrow/python/pyarrow.h>
1112
#include "IColumnConverter.hpp"

cpp/ArrowIterator/FloatConverter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class FloatConverter : public IColumnConverter
1414
public:
1515
explicit FloatConverter(arrow::Array* array);
1616

17-
PyObject* toPyObject(long rowIndex) override;
17+
PyObject* toPyObject(int64_t rowIndex) override;
1818

1919
private:
2020
arrow::DoubleArray* m_array;

cpp/ArrowIterator/IColumnConverter.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define PC_ICOLUMNCONVERTER_HPP
66

77
#include <Python.h>
8+
#include <arrow/python/platform.h>
89
#include <arrow/api.h>
910

1011

setup.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,21 @@ def build_extension(self, ext):
6969

7070
ext.library_dirs.append(os.path.join(current_dir, self.build_lib, 'snowflake', 'connector'))
7171
ext.extra_link_args += self._get_arrow_lib_as_linker_input()
72-
ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']
72+
73+
if self._is_unix():
74+
ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']
7375

7476
build_ext.build_extension(self, ext)
7577

78+
def _is_unix(self):
79+
return platform.startswith('linux') or platform == 'darwin'
80+
7681
def _get_arrow_lib_dir(self):
7782
return pyarrow.get_library_dirs()[0]
7883

7984
def _copy_arrow_lib(self):
80-
arrow_lib = pyarrow.get_libraries() + \
81-
['arrow_flight', 'arrow_boost_regex', 'arrow_boost_system', 'arrow_boost_filesystem']
85+
arrow_lib = self._get_libs_to_copy()
86+
8287
for lib in arrow_lib:
8388
lib_pattern = self._get_pyarrow_lib_pattern(lib)
8489
source = glob.glob(lib_pattern)[0]
@@ -94,11 +99,22 @@ def _get_arrow_lib_as_linker_input(self):
9499

95100
return link_lib
96101

102+
def _get_libs_to_copy(self):
103+
if self._is_unix():
104+
return pyarrow.get_libraries() + \
105+
['arrow_flight', 'arrow_boost_regex', 'arrow_boost_system', 'arrow_boost_filesystem']
106+
elif platform == 'win32':
107+
return pyarrow.get_libraries() + ['arrow_flight']
108+
else:
109+
raise RuntimeError('Building on platform {} is not supported yet.'.format(platform))
110+
97111
def _get_pyarrow_lib_pattern(self, lib_name):
98112
if platform.startswith('linux'):
99113
return '{}/lib{}.so*'.format(self._get_arrow_lib_dir(), lib_name)
100114
elif platform == 'darwin':
101115
return '{}/lib{}*dylib'.format(self._get_arrow_lib_dir(), lib_name)
116+
elif platform == 'win32':
117+
return '{}\\{}.lib'.format(self._get_arrow_lib_dir(), lib_name)
102118
else:
103119
raise RuntimeError('Building on platform {} is not supported yet.'.format(platform))
104120

@@ -121,7 +137,8 @@ def _get_pyarrow_lib_pattern(self, lib_name):
121137
download_url='https://www.snowflake.com/',
122138
use_2to3=False,
123139

124-
python_requires='>=2.7.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
140+
# NOTE: Python 3.4 will be dropped within one month.
141+
python_requires='>=2.7.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
125142

126143
install_requires=[
127144
'azure-common',

0 commit comments

Comments
 (0)