Skip to content

BLD Reduce generated build file path lengths to avoid Windows path length limitation #31212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sklearn/__check_build/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
py.extension_module(
'_check_build',
'_check_build.pyx',
cython_args: cython_args,
cython_gen.process('_check_build.pyx'),
install: true,
subdir: 'sklearn/__check_build',
)
3 changes: 1 addition & 2 deletions sklearn/_loss/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ _loss_pyx = custom_target(

py.extension_module(
'_loss',
_loss_pyx,
cython_gen.process(_loss_pyx),
dependencies: [openmp_dep],
cython_args: cython_args,
install: true,
subdir: 'sklearn/_loss',
)
5 changes: 2 additions & 3 deletions sklearn/cluster/_hdbscan/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cluster_hdbscan_extension_metadata = {
'_linkage': {'sources': ['_linkage.pyx', metrics_cython_tree]},
'_reachability': {'sources': ['_reachability.pyx']},
'_linkage': {'sources': [cython_gen.process('_linkage.pyx'), metrics_cython_tree]},
'_reachability': {'sources': [cython_gen.process('_reachability.pyx')]},
'_tree': {'sources': ['_tree.pyx']}
}

Expand All @@ -9,7 +9,6 @@ foreach ext_name, ext_dict : cluster_hdbscan_extension_metadata
ext_name,
ext_dict.get('sources'),
dependencies: [np_dep],
cython_args: cython_args,
subdir: 'sklearn/cluster/_hdbscan',
install: true
)
Expand Down
15 changes: 6 additions & 9 deletions sklearn/cluster/meson.build
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
cluster_extension_metadata = {
'_dbscan_inner':
{'sources': ['_dbscan_inner.pyx'], 'override_options': ['cython_language=cpp']},
{'sources': [cython_gen_cpp.process('_dbscan_inner.pyx')]},
'_hierarchical_fast':
{'sources': ['_hierarchical_fast.pyx', metrics_cython_tree],
'override_options': ['cython_language=cpp']},
{'sources': [cython_gen_cpp.process('_hierarchical_fast.pyx'), metrics_cython_tree]},
'_k_means_common':
{'sources': ['_k_means_common.pyx'], 'dependencies': [openmp_dep]},
{'sources': [cython_gen.process('_k_means_common.pyx')], 'dependencies': [openmp_dep]},
'_k_means_lloyd':
{'sources': ['_k_means_lloyd.pyx'], 'dependencies': [openmp_dep]},
{'sources': [cython_gen.process('_k_means_lloyd.pyx')], 'dependencies': [openmp_dep]},
'_k_means_elkan':
{'sources': ['_k_means_elkan.pyx'], 'dependencies': [openmp_dep]},
{'sources': [cython_gen.process('_k_means_elkan.pyx')], 'dependencies': [openmp_dep]},
'_k_means_minibatch':
{'sources': ['_k_means_minibatch.pyx'], 'dependencies': [openmp_dep]},
{'sources': [cython_gen.process('_k_means_minibatch.pyx')], 'dependencies': [openmp_dep]},
}

foreach ext_name, ext_dict : cluster_extension_metadata
py.extension_module(
ext_name,
[ext_dict.get('sources'), utils_cython_tree],
dependencies: [np_dep] + ext_dict.get('dependencies', []),
override_options : ext_dict.get('override_options', []),
cython_args: cython_args,
subdir: 'sklearn/cluster',
install: true
)
Expand Down
3 changes: 1 addition & 2 deletions sklearn/datasets/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
py.extension_module(
'_svmlight_format_fast',
'_svmlight_format_fast.pyx',
cython_gen.process('_svmlight_format_fast.pyx'),
dependencies: [np_dep],
cython_args: cython_args,
subdir: 'sklearn/datasets',
install: true
)
6 changes: 2 additions & 4 deletions sklearn/decomposition/meson.build
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
py.extension_module(
'_online_lda_fast',
['_online_lda_fast.pyx', utils_cython_tree],
cython_args: cython_args,
[cython_gen.process('_online_lda_fast.pyx'), utils_cython_tree],
subdir: 'sklearn/decomposition',
install: true
)

py.extension_module(
'_cdnmf_fast',
'_cdnmf_fast.pyx',
cython_gen.process('_cdnmf_fast.pyx'),
dependencies: [np_dep],
cython_args: cython_args,
subdir: 'sklearn/decomposition',
install: true
)
16 changes: 8 additions & 8 deletions sklearn/ensemble/_hist_gradient_boosting/meson.build
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
hist_gradient_boosting_extension_metadata = {
'_gradient_boosting': {'sources': ['_gradient_boosting.pyx'], 'dependencies': [openmp_dep]},
'histogram': {'sources': ['histogram.pyx'], 'dependencies': [openmp_dep]},
'splitting': {'sources': ['splitting.pyx'], 'dependencies': [openmp_dep]},
'_binning': {'sources': ['_binning.pyx'], 'dependencies': [openmp_dep]},
'_predictor': {'sources': ['_predictor.pyx'], 'dependencies': [openmp_dep]},
'_bitset': {'sources': ['_bitset.pyx']},
'common': {'sources': ['common.pyx']},
'_gradient_boosting': {'sources': [cython_gen.process('_gradient_boosting.pyx')],
'dependencies': [openmp_dep]},
'histogram': {'sources': [cython_gen.process('histogram.pyx')], 'dependencies': [openmp_dep]},
'splitting': {'sources': [cython_gen.process('splitting.pyx')], 'dependencies': [openmp_dep]},
'_binning': {'sources': [cython_gen.process('_binning.pyx')], 'dependencies': [openmp_dep]},
'_predictor': {'sources': [cython_gen.process('_predictor.pyx')], 'dependencies': [openmp_dep]},
'_bitset': {'sources': [cython_gen.process('_bitset.pyx')]},
'common': {'sources': [cython_gen.process('common.pyx')]},
}

foreach ext_name, ext_dict : hist_gradient_boosting_extension_metadata
py.extension_module(
ext_name,
ext_dict.get('sources'),
dependencies: ext_dict.get('dependencies', []),
cython_args: cython_args,
subdir: 'sklearn/ensemble/_hist_gradient_boosting',
install: true
)
Expand Down
3 changes: 1 addition & 2 deletions sklearn/ensemble/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
py.extension_module(
'_gradient_boosting',
['_gradient_boosting.pyx'] + utils_cython_tree,
[cython_gen.process('_gradient_boosting.pyx')] + utils_cython_tree,
dependencies: [np_dep],
cython_args: cython_args,
subdir: 'sklearn/ensemble',
install: true
)
Expand Down
4 changes: 1 addition & 3 deletions sklearn/feature_extraction/meson.build
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
py.extension_module(
'_hashing_fast',
['_hashing_fast.pyx', utils_cython_tree],
[cython_gen_cpp.process('_hashing_fast.pyx'), utils_cython_tree],
dependencies: [np_dep],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
subdir: 'sklearn/feature_extraction',
install: true
)
6 changes: 2 additions & 4 deletions sklearn/linear_model/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ linear_model_cython_tree = [

py.extension_module(
'_cd_fast',
['_cd_fast.pyx', utils_cython_tree],
cython_args: cython_args,
[cython_gen.process('_cd_fast.pyx'), utils_cython_tree],
subdir: 'sklearn/linear_model',
install: true
)
Expand All @@ -26,8 +25,7 @@ foreach name: name_list
)
py.extension_module(
name,
pyx,
cython_args: cython_args,
cython_gen.process(pyx),
subdir: 'sklearn/linear_model',
install: true
)
Expand Down
6 changes: 2 additions & 4 deletions sklearn/manifold/meson.build
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
py.extension_module(
'_utils',
['_utils.pyx', utils_cython_tree],
cython_args: cython_args,
[cython_gen.process('_utils.pyx'), utils_cython_tree],
subdir: 'sklearn/manifold',
install: true
)

py.extension_module(
'_barnes_hut_tsne',
'_barnes_hut_tsne.pyx',
cython_gen.process('_barnes_hut_tsne.pyx'),
dependencies: [np_dep, openmp_dep],
cython_args: cython_args,
subdir: 'sklearn/manifold',
install: true
)
13 changes: 13 additions & 0 deletions sklearn/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,19 @@ scikit_learn_cython_args = [
]
cython_args += scikit_learn_cython_args

cython_program = find_program(cython.cmd_array()[0])

cython_gen = generator(cython_program,
arguments : cython_args + ['@INPUT@', '--output-file', '@OUTPUT@'],
output : '@BASENAME@.c',
)

cython_gen_cpp = generator(cython_program,
arguments : cython_args + ['--cplus', '@INPUT@', '--output-file', '@OUTPUT@'],
output : '@BASENAME@.cpp',
)


# Write file in Meson build dir to be able to figure out from Python code
# whether scikit-learn was built with Meson. Adapted from pandas
# _version_meson.py.
Expand Down
28 changes: 7 additions & 21 deletions sklearn/metrics/_pairwise_distances_reduction/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ _datasets_pair_pyx = custom_target(
)
_datasets_pair = py.extension_module(
'_datasets_pair',
_datasets_pair_pyx,
cython_gen_cpp.process(_datasets_pair_pyx),
dependencies: [np_dep],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
subdir: 'sklearn/metrics/_pairwise_distances_reduction',
install: true
)
Expand All @@ -65,10 +63,8 @@ _base_pyx = custom_target(
)
_base = py.extension_module(
'_base',
_base_pyx,
cython_gen_cpp.process(_base_pyx),
dependencies: [np_dep, openmp_dep],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
subdir: 'sklearn/metrics/_pairwise_distances_reduction',
install: true
)
Expand All @@ -93,10 +89,8 @@ _middle_term_computer_pyx = custom_target(
)
_middle_term_computer = py.extension_module(
'_middle_term_computer',
_middle_term_computer_pyx,
cython_gen_cpp.process(_middle_term_computer_pyx),
dependencies: [np_dep],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
subdir: 'sklearn/metrics/_pairwise_distances_reduction',
install: true
)
Expand All @@ -121,10 +115,8 @@ _argkmin_pyx = custom_target(
)
_argkmin = py.extension_module(
'_argkmin',
_argkmin_pyx,
cython_gen_cpp.process(_argkmin_pyx),
dependencies: [np_dep, openmp_dep],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
subdir: 'sklearn/metrics/_pairwise_distances_reduction',
install: true
)
Expand All @@ -149,10 +141,8 @@ _radius_neighbors_pyx = custom_target(
)
_radius_neighbors = py.extension_module(
'_radius_neighbors',
_radius_neighbors_pyx,
cython_gen_cpp.process(_radius_neighbors_pyx),
dependencies: [np_dep, openmp_dep],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
subdir: 'sklearn/metrics/_pairwise_distances_reduction',
install: true
)
Expand All @@ -171,10 +161,8 @@ _argkmin_classmode_pyx = custom_target(
)
_argkmin_classmode = py.extension_module(
'_argkmin_classmode',
_argkmin_classmode_pyx,
cython_gen_cpp.process(_argkmin_classmode_pyx),
dependencies: [np_dep, openmp_dep],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
# XXX: for some reason -fno-sized-deallocation is needed otherwise there is
# an error with undefined symbol _ZdlPv at import time in manylinux wheels.
# See https://github.com/scikit-learn/scikit-learn/issues/28596 for more details.
Expand All @@ -198,10 +186,8 @@ _radius_neighbors_classmode_pyx = custom_target(
)
_radius_neighbors_classmode = py.extension_module(
'_radius_neighbors_classmode',
_radius_neighbors_classmode_pyx,
cython_gen_cpp.process(_radius_neighbors_classmode_pyx),
dependencies: [np_dep, openmp_dep],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
subdir: 'sklearn/metrics/_pairwise_distances_reduction',
install: true
)
3 changes: 1 addition & 2 deletions sklearn/metrics/cluster/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
py.extension_module(
'_expected_mutual_info_fast',
'_expected_mutual_info_fast.pyx',
cython_args: cython_args,
cython_gen.process('_expected_mutual_info_fast.pyx'),
subdir: 'sklearn/metrics/cluster',
install: true
)
6 changes: 2 additions & 4 deletions sklearn/metrics/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,16 @@ _dist_metrics_pyx = custom_target(

_dist_metrics = py.extension_module(
'_dist_metrics',
_dist_metrics_pyx,
cython_gen.process(_dist_metrics_pyx),
dependencies: [np_dep],
cython_args: cython_args,
subdir: 'sklearn/metrics',
install: true
)

py.extension_module(
'_pairwise_fast',
['_pairwise_fast.pyx', metrics_cython_tree],
[cython_gen.process('_pairwise_fast.pyx'), metrics_cython_tree],
dependencies: [openmp_dep],
cython_args: cython_args,
subdir: 'sklearn/metrics',
install: true
)
Expand Down
9 changes: 3 additions & 6 deletions sklearn/neighbors/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ foreach name: name_list
)
py.extension_module(
name,
pyx,
cython_gen.process(pyx),
dependencies: [np_dep],
cython_args: cython_args,
subdir: 'sklearn/neighbors',
install: true
)
endforeach

neighbors_extension_metadata = {
'_partition_nodes':
{'sources': ['_partition_nodes.pyx'],
'override_options': ['cython_language=cpp'], 'dependencies': [np_dep]},
{'sources': [cython_gen_cpp.process('_partition_nodes.pyx')],
'dependencies': [np_dep]},
'_quad_tree': {'sources': ['_quad_tree.pyx'], 'dependencies': [np_dep]},
}

Expand All @@ -48,8 +47,6 @@ foreach ext_name, ext_dict : neighbors_extension_metadata
ext_name,
[ext_dict.get('sources'), utils_cython_tree],
dependencies: ext_dict.get('dependencies'),
override_options : ext_dict.get('override_options', []),
cython_args: cython_args,
subdir: 'sklearn/neighbors',
install: true
)
Expand Down
7 changes: 2 additions & 5 deletions sklearn/preprocessing/meson.build
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
py.extension_module(
'_csr_polynomial_expansion',
['_csr_polynomial_expansion.pyx', utils_cython_tree],
cython_args: cython_args,
[cython_gen.process('_csr_polynomial_expansion.pyx'), utils_cython_tree],
subdir: 'sklearn/preprocessing',
install: true
)

py.extension_module(
'_target_encoder_fast',
['_target_encoder_fast.pyx', utils_cython_tree],
override_options: ['cython_language=cpp'],
cython_args: cython_args,
[cython_gen_cpp.process('_target_encoder_fast.pyx'), utils_cython_tree],
subdir: 'sklearn/preprocessing',
install: true
)
Loading