Skip to content

Commit fec9afa

Browse files
authored
[ci] restore aarch64 linux builds (fixes #6509) (#6527)
1 parent 1886bf5 commit fec9afa

File tree

3 files changed

+139
-135
lines changed

3 files changed

+139
-135
lines changed

.ci/test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ elif [[ $TASK == "bdist" ]]; then
191191
PLATFORM="manylinux2014_$ARCH"
192192
fi
193193
sh ./build-python.sh bdist_wheel --integrated-opencl || exit 1
194+
# rename wheel, to fix scikit-build-core choosing the platform 'linux_aarch64' instead of
195+
# a manylinux tag
194196
mv \
195197
./dist/*.whl \
196198
./dist/tmp.whl || exit 1

.vsts-ci.yml

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -182,71 +182,71 @@ jobs:
182182
inputs:
183183
filePath: $(Build.SourcesDirectory)/.ci/test.sh
184184
targetType: 'filePath'
185-
# ###########################################
186-
# - job: QEMU_multiarch
187-
# ###########################################
188-
# variables:
189-
# BUILD_DIRECTORY: /LightGBM
190-
# COMPILER: gcc
191-
# PRODUCES_ARTIFACTS: 'true'
192-
# pool:
193-
# vmImage: ubuntu-22.04
194-
# timeoutInMinutes: 180
195-
# strategy:
196-
# matrix:
197-
# bdist:
198-
# TASK: bdist
199-
# ARCH: aarch64
200-
# steps:
201-
# - script: |
202-
# sudo apt-get update
203-
# sudo apt-get install --no-install-recommends -y \
204-
# binfmt-support \
205-
# qemu \
206-
# qemu-user \
207-
# qemu-user-static
208-
# displayName: 'Install QEMU'
209-
# - script: |
210-
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
211-
# displayName: 'Enable Docker multi-architecture support'
212-
# - script: |
213-
# git clean -d -f -x
214-
# displayName: 'Clean source directory'
215-
# - script: |
216-
# cat > docker-script.sh <<EOF
217-
# export CONDA=\$HOME/miniforge
218-
# export PATH=\$CONDA/bin:/opt/rh/llvm-toolset-7.0/root/usr/bin:\$PATH
219-
# export LD_LIBRARY_PATH=/opt/rh/llvm-toolset-7.0/root/usr/lib64:\$LD_LIBRARY_PATH
220-
# \$BUILD_DIRECTORY/.ci/setup.sh || exit 1
221-
# \$BUILD_DIRECTORY/.ci/test.sh || exit 1
222-
# EOF
223-
# IMAGE_URI="lightgbm/vsts-agent:manylinux2014_aarch64"
224-
# docker pull "${IMAGE_URI}" || exit 1
225-
# PLATFORM=$(docker inspect --format='{{.Os}}/{{.Architecture}}' "${IMAGE_URI}") || exit 1
226-
# echo "detected image platform: ${PLATFORM}"
227-
# docker run \
228-
# --platform "${PLATFORM}" \
229-
# --rm \
230-
# --env AZURE=true \
231-
# --env BUILD_ARTIFACTSTAGINGDIRECTORY=$BUILD_ARTIFACTSTAGINGDIRECTORY \
232-
# --env BUILD_DIRECTORY=$BUILD_DIRECTORY \
233-
# --env COMPILER=$COMPILER \
234-
# --env METHOD=$METHOD \
235-
# --env OS_NAME=linux \
236-
# --env PRODUCES_ARTIFACTS=$PRODUCES_ARTIFACTS \
237-
# --env PYTHON_VERSION=$PYTHON_VERSION \
238-
# --env TASK=$TASK \
239-
# -v "$(Build.SourcesDirectory)":"$BUILD_DIRECTORY" \
240-
# -v "$(Build.ArtifactStagingDirectory)":"$(Build.ArtifactStagingDirectory)" \
241-
# "${IMAGE_URI}" \
242-
# /bin/bash $BUILD_DIRECTORY/docker-script.sh
243-
# displayName: 'Setup and run tests'
244-
# - task: PublishBuildArtifacts@1
245-
# condition: and(succeeded(), in(variables['TASK'], 'bdist'), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
246-
# inputs:
247-
# pathtoPublish: '$(Build.ArtifactStagingDirectory)'
248-
# artifactName: PackageAssets
249-
# artifactType: container
185+
###########################################
186+
- job: QEMU_multiarch
187+
###########################################
188+
variables:
189+
BUILD_DIRECTORY: /LightGBM
190+
COMPILER: gcc
191+
PRODUCES_ARTIFACTS: 'true'
192+
pool:
193+
vmImage: ubuntu-22.04
194+
timeoutInMinutes: 180
195+
strategy:
196+
matrix:
197+
bdist:
198+
TASK: bdist
199+
ARCH: aarch64
200+
steps:
201+
- script: |
202+
sudo apt-get update
203+
sudo apt-get install --no-install-recommends -y \
204+
binfmt-support \
205+
qemu \
206+
qemu-user \
207+
qemu-user-static
208+
displayName: 'Install QEMU'
209+
- script: |
210+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
211+
displayName: 'Enable Docker multi-architecture support'
212+
- script: |
213+
git clean -d -f -x
214+
displayName: 'Clean source directory'
215+
- script: |
216+
cat > docker-script.sh <<EOF
217+
export CONDA=\$HOME/miniforge
218+
export PATH=\$CONDA/bin:/opt/rh/llvm-toolset-7.0/root/usr/bin:\$PATH
219+
export LD_LIBRARY_PATH=/opt/rh/llvm-toolset-7.0/root/usr/lib64:\$LD_LIBRARY_PATH
220+
\$BUILD_DIRECTORY/.ci/setup.sh || exit 1
221+
\$BUILD_DIRECTORY/.ci/test.sh || exit 1
222+
EOF
223+
IMAGE_URI="lightgbm/vsts-agent:manylinux2014_aarch64"
224+
docker pull "${IMAGE_URI}" || exit 1
225+
PLATFORM=$(docker inspect --format='{{.Os}}/{{.Architecture}}' "${IMAGE_URI}") || exit 1
226+
echo "detected image platform: ${PLATFORM}"
227+
docker run \
228+
--platform "${PLATFORM}" \
229+
--rm \
230+
--env AZURE=true \
231+
--env BUILD_ARTIFACTSTAGINGDIRECTORY=$BUILD_ARTIFACTSTAGINGDIRECTORY \
232+
--env BUILD_DIRECTORY=$BUILD_DIRECTORY \
233+
--env COMPILER=$COMPILER \
234+
--env METHOD=$METHOD \
235+
--env OS_NAME=linux \
236+
--env PRODUCES_ARTIFACTS=$PRODUCES_ARTIFACTS \
237+
--env PYTHON_VERSION=$PYTHON_VERSION \
238+
--env TASK=$TASK \
239+
-v "$(Build.SourcesDirectory)":"$BUILD_DIRECTORY" \
240+
-v "$(Build.ArtifactStagingDirectory)":"$(Build.ArtifactStagingDirectory)" \
241+
"${IMAGE_URI}" \
242+
/bin/bash $BUILD_DIRECTORY/docker-script.sh
243+
displayName: 'Setup and run tests'
244+
- task: PublishBuildArtifacts@1
245+
condition: and(succeeded(), in(variables['TASK'], 'bdist'), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
246+
inputs:
247+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
248+
artifactName: PackageAssets
249+
artifactType: container
250250
###########################################
251251
- job: macOS
252252
###########################################
@@ -376,7 +376,7 @@ jobs:
376376
dependsOn:
377377
- Linux
378378
- Linux_latest
379-
# - QEMU_multiarch
379+
- QEMU_multiarch
380380
- macOS
381381
- Windows
382382
- R_artifact

python-package/lightgbm/compat.py

Lines changed: 71 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,8 @@
33

44
from typing import Any, List
55

6-
"""pandas"""
7-
try:
8-
from pandas import DataFrame as pd_DataFrame
9-
from pandas import Series as pd_Series
10-
from pandas import concat
11-
12-
try:
13-
from pandas import CategoricalDtype as pd_CategoricalDtype
14-
except ImportError:
15-
from pandas.api.types import CategoricalDtype as pd_CategoricalDtype
16-
PANDAS_INSTALLED = True
17-
except ImportError:
18-
PANDAS_INSTALLED = False
19-
20-
class pd_Series: # type: ignore
21-
"""Dummy class for pandas.Series."""
22-
23-
def __init__(self, *args: Any, **kwargs: Any):
24-
pass
25-
26-
class pd_DataFrame: # type: ignore
27-
"""Dummy class for pandas.DataFrame."""
28-
29-
def __init__(self, *args: Any, **kwargs: Any):
30-
pass
31-
32-
class pd_CategoricalDtype: # type: ignore
33-
"""Dummy class for pandas.CategoricalDtype."""
34-
35-
def __init__(self, *args: Any, **kwargs: Any):
36-
pass
37-
38-
concat = None
39-
40-
"""matplotlib"""
41-
try:
42-
import matplotlib # noqa: F401
43-
44-
MATPLOTLIB_INSTALLED = True
45-
except ImportError:
46-
MATPLOTLIB_INSTALLED = False
47-
48-
"""graphviz"""
49-
try:
50-
import graphviz # noqa: F401
51-
52-
GRAPHVIZ_INSTALLED = True
53-
except ImportError:
54-
GRAPHVIZ_INSTALLED = False
55-
56-
"""datatable"""
57-
try:
58-
import datatable
59-
60-
if hasattr(datatable, "Frame"):
61-
dt_DataTable = datatable.Frame
62-
else:
63-
dt_DataTable = datatable.DataTable
64-
DATATABLE_INSTALLED = True
65-
except ImportError:
66-
DATATABLE_INSTALLED = False
67-
68-
class dt_DataTable: # type: ignore
69-
"""Dummy class for datatable.DataTable."""
70-
71-
def __init__(self, *args: Any, **kwargs: Any):
72-
pass
73-
74-
6+
# scikit-learn is intentionally imported first here,
7+
# see https://github.com/microsoft/LightGBM/issues/6509
758
"""sklearn"""
769
try:
7710
from sklearn.base import BaseEstimator, ClassifierMixin, RegressorMixin
@@ -141,6 +74,75 @@ class _LGBMRegressorBase: # type: ignore
14174
_LGBMCheckClassificationTargets = None
14275
_LGBMComputeSampleWeight = None
14376

77+
"""pandas"""
78+
try:
79+
from pandas import DataFrame as pd_DataFrame
80+
from pandas import Series as pd_Series
81+
from pandas import concat
82+
83+
try:
84+
from pandas import CategoricalDtype as pd_CategoricalDtype
85+
except ImportError:
86+
from pandas.api.types import CategoricalDtype as pd_CategoricalDtype
87+
PANDAS_INSTALLED = True
88+
except ImportError:
89+
PANDAS_INSTALLED = False
90+
91+
class pd_Series: # type: ignore
92+
"""Dummy class for pandas.Series."""
93+
94+
def __init__(self, *args: Any, **kwargs: Any):
95+
pass
96+
97+
class pd_DataFrame: # type: ignore
98+
"""Dummy class for pandas.DataFrame."""
99+
100+
def __init__(self, *args: Any, **kwargs: Any):
101+
pass
102+
103+
class pd_CategoricalDtype: # type: ignore
104+
"""Dummy class for pandas.CategoricalDtype."""
105+
106+
def __init__(self, *args: Any, **kwargs: Any):
107+
pass
108+
109+
concat = None
110+
111+
"""matplotlib"""
112+
try:
113+
import matplotlib # noqa: F401
114+
115+
MATPLOTLIB_INSTALLED = True
116+
except ImportError:
117+
MATPLOTLIB_INSTALLED = False
118+
119+
"""graphviz"""
120+
try:
121+
import graphviz # noqa: F401
122+
123+
GRAPHVIZ_INSTALLED = True
124+
except ImportError:
125+
GRAPHVIZ_INSTALLED = False
126+
127+
"""datatable"""
128+
try:
129+
import datatable
130+
131+
if hasattr(datatable, "Frame"):
132+
dt_DataTable = datatable.Frame
133+
else:
134+
dt_DataTable = datatable.DataTable
135+
DATATABLE_INSTALLED = True
136+
except ImportError:
137+
DATATABLE_INSTALLED = False
138+
139+
class dt_DataTable: # type: ignore
140+
"""Dummy class for datatable.DataTable."""
141+
142+
def __init__(self, *args: Any, **kwargs: Any):
143+
pass
144+
145+
144146
"""dask"""
145147
try:
146148
from dask import delayed

0 commit comments

Comments
 (0)