@@ -70,7 +70,8 @@ pyarrow_srcs = files(
7070 ' src/arrow/python/util.cc' ,
7171)
7272
73- # TODO: these are optional components so should detect if needed
73+ # TODO: These are required, but the CMake configuration checks for the
74+ # C++ options to be defined (???)
7475# if needs_csv
7576pyarrow_srcs += files (' src/arrow/python/csv.cc' )
7677#endif
@@ -80,166 +81,182 @@ pyarrow_srcs += files('src/arrow/python/filesystem.cc')
8081
8182subdir (' src/arrow/python' )
8283
83- arrow_python_lib = library (
84- ' arrow_python' ,
85- sources : pyarrow_srcs,
86- include_directories : [' src' ],
87- dependencies : [arrow_dep, numpy_dep, cython_generated_dep, py.dependency ()],
88- cpp_args : cc.get_supported_arguments(
89- [' -DARROW_PYTHON_EXPORTING' , ' /DARROW_PYTHON_EXPORTING' ],
90- ),
91- override_options : [' b_lundef=false' ],
92- install : true ,
93- install_dir : py.get_install_dir() / ' pyarrow' ,
94- )
84+ cython_modules = {
85+ ' lib' : {},
86+ ' _compute' : {},
87+ ' _csv' : {},
88+ ' _feather' : {},
89+ ' _fs' : {},
90+ ' _json' : {},
91+ ' _pyarrow_cpp_tests' : {},
92+ }
9593
9694arrow_compute_dep = dependency (' arrow-compute' )
9795arrow_csv_dep = dependency (' arrow-csv' )
9896arrow_fs_dep = dependency (' arrow-filesystem' )
9997arrow_json_dep = dependency (' arrow-json' )
10098
101- cython_modules = {
102- ' lib' : {},
103- ' _compute' : {' dependencies' : [arrow_compute_dep]},
104- ' _csv' : {' dependencies' : [arrow_csv_dep]},
105- ' _feather' : {},
106- ' _fs' : {' dependencies' : [arrow_fs_dep]},
107- ' _json' : {' dependencies' : [arrow_json_dep]},
108- ' _pyarrow_cpp_tests' : {},
109- }
99+ libpyarrow_deps = [
100+ arrow_dep,
101+ arrow_compute_dep,
102+ arrow_csv_dep,
103+ arrow_fs_dep,
104+ arrow_json_dep,
105+ ]
110106
111- # enforce module dependencies
112107needs_substrait = get_option (' substrait' ).enabled()
113108needs_dataset = get_option (' dataset' ).enabled() or needs_substrait
114109needs_acero = get_option (' acero' ).enabled() or needs_dataset
110+ needs_flight = get_option (' flight' ).enabled()
111+
112+ if needs_acero
113+ arrow_acero_dep = dependency (' arrow-acero' )
114+ libpyarrow_deps += [arrow_acero_dep]
115+ cython_modules += {' _acero' : {' dependencies' : arrow_acero_dep}}
116+ endif
115117
116118if get_option (' azure' ).enabled()
117119 cython_modules += {' _azurefs' : {}}
118120endif
119121
120- if get_option (' gcs' ).enabled()
121- cython_modules += {' _gcsfs' : {}}
122+ if get_option (' cuda' ).enabled()
123+ arrow_cuda_dep = dependency (' arrow-cuda' )
124+ libpyarrow_deps += [arrow_cuda_dep]
125+ cython_modules += {' _cuda' : {' dependencies' : arrow_cuda_dep}}
122126endif
123127
124- if get_option (' s3' ).enabled()
125- cython_modules += {' _s3fs' : {}}
128+ if needs_dataset
129+ arrow_dataset_dep = dependency (' arrow-dataset' )
130+ libpyarrow_deps += [arrow_dataset_dep]
131+ cython_modules += {' _dataset' : {' dependencies' : arrow_dataset_dep}}
132+ endif
133+
134+ if needs_flight
135+ arrow_flight_dep = dependency (' arrow-flight' )
136+ libpyarrow_deps += [arrow_flight_dep]
137+ cython_modules += {' _flight' : {' dependencies' : arrow_flight_dep}}
138+ endif
139+
140+ if get_option (' gandiva' ).enabled()
141+ gandiva_dep = dependency (' gandiva' )
142+ libpyarrow_deps += [gandiva_dep]
143+ cython_modules += {' gandiva' : {' dependencies' : gandiva_dep}}
144+ endif
145+
146+ if get_option (' gcs' ).enabled()
147+ cython_modules += {' _gcsfs' : {}}
126148endif
127149
128150if get_option (' hdfs' ).enabled()
129151 cython_modules += {' _hdfs' : {}}
130152endif
131153
132- if get_option (' cuda' ).enabled()
133- cuda_dep = dependency (' arrow-cuda' )
134- cython_modules += {' _cuda' : {' dependencies' : cuda_dep}}
154+ if get_option (' orc' ).enabled()
155+ cython_modules += {' _orc' : {}}
156+
157+ if needs_dataset
158+ cython_modules += {' _dataset_orc' : {' dependencies' : arrow_dataset_dep}}
159+ endif
135160endif
136161
137- if needs_acero
138- acero_dep = dependency (' arrow-acero' )
139- cython_modules += {' _acero' : {' dependencies' : acero_dep}}
162+ if get_option (' s3' ).enabled()
163+ cython_modules += {' _s3fs' : {}}
140164endif
141165
142- if needs_dataset
143- dataset_dep = dependency (' arrow-dataset' )
144- cython_modules += {' _dataset' : {' dependencies' : dataset_dep}}
166+ if needs_substrait
167+ arrow_substrait_dep = dependency (' arrow-substrait' )
168+ libpyarrow_deps += [arrow_substrait_dep]
169+ cython_modules += {' _substrait' : {' dependencies' : arrow_substrait_dep}}
170+ endif
171+
172+ needs_parquet = get_option (' parquet' ).enabled()
173+ needs_parquet_encryption = get_option (' parquet_require_encryption' ).enabled()
174+ if needs_parquet_encryption and not needs_parquet
175+ warning (
176+ '''
177+ Building PyArrow with Parquet Encryption is requested, but Parquet
178+ itself is not enabled. Ignoring the Parquet Encryption setting.,
179+ ''' ,
180+ )
181+ needs_parquet_encryption = false
145182endif
146183
147- if get_option ( ' parquet ' ).enabled()
184+ if needs_parquet
148185 parquet_dep = dependency (' parquet' )
186+ libpyarrow_deps += [parquet_dep]
149187 cython_modules += {' _parquet' : {' dependencies' : parquet_dep}}
150188
151- if get_option (' parquet_require_encryption' ).enabled()
152- arrow_encryption_lib = library (
153- ' arrow_python_parquet_encryption' ,
154- sources : [' src/arrow/python/parquet_encryption.cc' ],
155- include_directories : [' src' ],
156- link_with : [arrow_python_lib],
157- dependencies : [parquet_dep, py.dependency ()],
158- cpp_args : cc.get_supported_arguments(
159- [
160- ' -DARROW_PYTHON_PARQUET_ENCRYPTION_EXPORTING' ,
161- ' /DARROW_PYTHON_PARQUET_ENCRYPTION_EXPORTING' ,
162- ],
163- ),
164- override_options : [' b_lundef=false' ],
165- install : true ,
166- install_dir : py.get_install_dir() / ' pyarrow' ,
167- )
168-
169- pyarrow_encryption_dep = declare_dependency (
170- link_with : arrow_encryption_lib,
171- )
172-
173- cython_modules += {
174- ' _parquet_encryption' : {
175- ' dependencies' : [parquet_dep, pyarrow_encryption_dep],
176- },
177- }
189+ if needs_parquet_encryption
190+ cython_modules += {' _parquet_encryption' : {' dependencies' : parquet_dep}}
178191 endif
179192
180193 if needs_dataset
181194 cython_modules += {
182- ' _dataset_parquet' : {' dependencies' : [dataset_dep, parquet_dep]},
195+ ' _dataset_parquet' : {
196+ ' dependencies' : [parquet_dep, arrow_dataset_dep],
197+ },
183198 }
184199
185- if get_option ( ' parquet_require_encryption ' ).enabled()
200+ if needs_parquet_encryption
186201 cython_modules += {
187202 ' _dataset_parquet_encryption' : {
188- ' dependencies' : [dataset_dep, parquet_dep ],
203+ ' dependencies' : [parquet_dep, arrow_dataset_dep ],
189204 },
190205 }
191206 endif
192207 endif
193208endif
194209
195- if get_option (' parquet_require_encryption' ).enabled() and not get_option (
196- ' parquet' ,
197- ).enabled()
198- warning (
199- ' Building PyArrow with Parquet Encryption is requested, but Parquet itself is not enabled. Ignoring the Parquet Encryption setting.' ,
200- )
201- endif
202-
203- if get_option (' orc' ).enabled()
204- cython_modules += {' _orc' : {}}
205-
206- if needs_dataset
207- cython_modules += {' _dataset_orc' : {' dependencies' : [dataset_dep]}}
208- endif
209- endif
210-
211- if get_option (' flight' ).enabled()
212- flight_dep = dependency (' arrow-flight' )
210+ arrow_python_lib = py.extension_module(
211+ ' arrow_python' ,
212+ sources : pyarrow_srcs,
213+ include_directories : [' src' ],
214+ dependencies : libpyarrow_deps + [
215+ numpy_dep,
216+ cython_generated_dep,
217+ py.dependency (),
218+ ],
219+ cpp_args : cc.get_supported_arguments(
220+ [' -DARROW_PYTHON_EXPORTING' , ' /DARROW_PYTHON_EXPORTING' ],
221+ ),
222+ install : true ,
223+ install_dir : py.get_install_dir() / ' pyarrow' ,
224+ gnu_symbol_visibility : ' inlineshidden' ,
225+ )
213226
214- flight_lib = library (
227+ if needs_flight
228+ flight_lib = py.extension_module(
215229 ' arrow_flight_lib' ,
216230 sources : [' src/arrow/python/flight.cc' ],
217231 link_with : [arrow_python_lib],
218- dependencies : [flight_dep , py.dependency ()],
232+ dependencies : [arrow_flight_dep , py.dependency ()],
219233 include_directories : [' src' ],
220234 cpp_args : cc.get_supported_arguments(
221235 [' -DARROW_PYFLIGHT_EXPORTING' , ' /DARROW_PYFLIGHT_EXPORTING' ],
222236 ),
223- override_options : [' b_lundef=false' ],
224237 install : true ,
225238 install_dir : py.get_install_dir() / ' pyarrow' ,
239+ gnu_symbol_visibility : ' inlineshidden' ,
226240 )
227-
228- pyarrow_flight_dep = declare_dependency (
229- link_with : flight_lib,
230- dependencies : [flight_dep],
231- )
232- cython_modules += {' _flight' : {' dependencies' : pyarrow_flight_dep}}
233- endif
234-
235- if needs_substrait
236- substrait_dep = dependency (' arrow-substrait' )
237- cython_modules += {' _substrait' : {' dependencies' : substrait_dep}}
238241endif
239242
240- if get_option (' gandiva' ).enabled()
241- gandiva_dep = dependency (' gandiva' )
242- cython_modules += {' gandiva' : {' dependencies' : gandiva_dep}}
243+ if needs_parquet_encryption
244+ arrow_encryption_lib = py.extension_module(
245+ ' arrow_python_parquet_encryption' ,
246+ sources : [' src/arrow/python/parquet_encryption.cc' ],
247+ include_directories : [' src' ],
248+ link_with : [arrow_python_lib],
249+ dependencies : [parquet_dep, py.dependency ()],
250+ cpp_args : cc.get_supported_arguments(
251+ [
252+ ' -DARROW_PYTHON_PARQUET_ENCRYPTION_EXPORTING' ,
253+ ' /DARROW_PYTHON_PARQUET_ENCRYPTION_EXPORTING' ,
254+ ],
255+ ),
256+ install : true ,
257+ install_dir : py.get_install_dir() / ' pyarrow' ,
258+ gnu_symbol_visibility : ' inlineshidden' ,
259+ )
243260endif
244261
245262foreach key, val : cython_modules
@@ -363,7 +380,6 @@ py.install_sources(
363380 ),
364381 subdir : ' pyarrow/include/arrow/python' ,
365382)
366-
367383#if arrow_dep.found()
368384# arrow_header_dir = arrow_dep.get_variable(
369385# CMake has a local variable for ARROW_INCLUDE_DIR which is not
0 commit comments