Skip to content

Commit 1443548

Browse files
authored
[ci] raise floors on CI dependencies (#6375)
1 parent c906cfd commit 1443548

File tree

5 files changed

+137
-41
lines changed

5 files changed

+137
-41
lines changed

.ci/conda-envs/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# conda-envs
2+
3+
This directory contains files used to create `conda` environments for development
4+
and testing of LightGBM.
5+
6+
The `.txt` files here are intended to be used with `conda create --file`.
7+
8+
For details on that, see the `conda` docs:
9+
10+
* `conda create` docs ([link](https://conda.io/projects/conda/en/latest/commands/create.html))
11+
* "Managing Environments" ([link](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html))

.ci/conda-envs/ci-core-py37.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# [description]
2+
#
3+
# Similar to ci-core.txt, but specific to Python 3.7.
4+
#
5+
# Unlike ci-core.txt, this includes a Python version and uses
6+
# `=` and `<=` pins to make solves faster and prevent against
7+
# issues like https://github.com/microsoft/LightGBM/pull/6370.
8+
#
9+
# [usage]
10+
#
11+
# conda create \
12+
# --name test-env \
13+
# --file ./.ci/conda-envs/ci-core-py37.txt
14+
#
15+
16+
# python
17+
python=3.7.*
18+
19+
# direct imports
20+
cffi=1.15.*
21+
# older versions of Dask are incompatible with pandas>=2.0, but not all conda packages' metadata accurately reflects that
22+
#
23+
# ref: https://github.com/microsoft/LightGBM/issues/6030
24+
dask=2022.2.*
25+
distributed=2022.2.*
26+
joblib=1.3.*
27+
matplotlib-base=3.5.*
28+
numpy=1.21.*
29+
pandas=1.3.*
30+
pyarrow=9.0.*
31+
# python-graphviz 0.20.2 is not compatible with Python 3.7
32+
# ref: https://github.com/microsoft/LightGBM/pull/6370
33+
python-graphviz=0.20.1
34+
scikit-learn=1.0.*
35+
scipy=1.7.*
36+
37+
# testing-only dependencies
38+
cloudpickle=2.2.*
39+
pluggy=1.0.*
40+
psutil=5.9.3
41+
pytest=7.4.*
42+
43+
# other recursive dependencies, just
44+
# pinned here to help speed up solves
45+
bokeh=2.4.*
46+
fsspec=2023.1.*
47+
msgpack-python=1.0.*
48+
pluggy=1.0.*
49+
pytz=2024.1
50+
setuptools=59.8.*
51+
snappy=1.1.*
52+
tomli=2.0.*
53+
tornado=6.1.*
54+
wheel=0.42.*
55+
zict=2.2.*
56+
zipp=3.15.*

.ci/conda-envs/ci-core.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# [description]
2+
#
3+
# Core dependencies used across most LightGBM continuous integration (CI) jobs.
4+
#
5+
# 'python' constraint is intentionally omitted, so this file can be reused across
6+
# Python versions.
7+
#
8+
# These floors are not the oldest versions LightGBM supports... they're here just to make conda
9+
# solves faster, and should generally be the latest versions that work for all CI jobs using this.
10+
#
11+
# [usage]
12+
#
13+
# conda create \
14+
# --name test-env \
15+
# --file ./.ci/conda-envs/ci-core.txt \
16+
# python=3.10
17+
#
18+
19+
# direct imports
20+
cffi>=1.16
21+
dask>=2023.5.0
22+
joblib>=1.3.2
23+
matplotlib-base>=3.7.3
24+
numpy>=1.24.4
25+
pandas>2.0
26+
pyarrow>=6.0
27+
python-graphviz>=0.20.3
28+
scikit-learn>=1.3.2
29+
scipy>=1.1
30+
31+
# testing-only dependencies
32+
cloudpickle>=3.0.0
33+
psutil>=5.9.8
34+
pytest>=8.1.1
35+
36+
# other recursive dependencies, just
37+
# pinned here to help speed up solves
38+
pluggy>=1.4.0
39+
setuptools>=69.2
40+
wheel>=0.43

.ci/test.sh

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ if [[ "$TASK" == "cpp-tests" ]]; then
4646
exit 0
4747
fi
4848

49+
# including python=version[build=*cpython] to ensure that conda doesn't fall back to pypy
4950
CONDA_PYTHON_REQUIREMENT="python=$PYTHON_VERSION[build=*cpython]"
5051

5152
if [[ $TASK == "if-else" ]]; then
@@ -78,10 +79,10 @@ if [[ $TASK == "lint" ]]; then
7879
${CONDA_PYTHON_REQUIREMENT} \
7980
'cmakelint>=1.4.2' \
8081
'cpplint>=1.6.0' \
81-
'matplotlib>=3.8.3' \
82+
'matplotlib-base>=3.8.3' \
8283
'mypy>=1.8.0' \
8384
'pre-commit>=3.6.0' \
84-
'pyarrow>=14.0' \
85+
'pyarrow>=6.0' \
8586
'r-lintr>=3.1'
8687
source activate $CONDA_ENV
8788
echo "Linting Python code"
@@ -127,28 +128,18 @@ if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then
127128
exit 0
128129
fi
129130

130-
# older versions of Dask are incompatible with pandas>=2.0, but not all conda packages' metadata accurately reflects that
131-
#
132-
# ref: https://github.com/microsoft/LightGBM/issues/6030
133-
CONSTRAINED_DEPENDENCIES="'dask>=2023.5.0' 'distributed>=2023.5.0' 'pandas>=2.0' python-graphviz"
134131
if [[ $PYTHON_VERSION == "3.7" ]]; then
135-
CONSTRAINED_DEPENDENCIES="'dask' 'distributed' 'python-graphviz<0.20.2' 'pandas<2.0'"
132+
CONDA_REQUIREMENT_FILES="--file ${BUILD_DIRECTORY}/.ci/conda-envs/ci-core-py37.txt"
133+
else
134+
CONDA_REQUIREMENT_FILES="--file ${BUILD_DIRECTORY}/.ci/conda-envs/ci-core.txt"
136135
fi
137136

138-
# including python=version[build=*cpython] to ensure that conda doesn't fall back to pypy
139-
mamba create -q -y -n $CONDA_ENV \
140-
${CONSTRAINED_DEPENDENCIES} \
141-
cffi \
142-
cloudpickle \
143-
joblib \
144-
matplotlib \
145-
numpy \
146-
psutil \
147-
pyarrow \
148-
pytest \
137+
mamba create \
138+
-y \
139+
-n $CONDA_ENV \
140+
${CONDA_REQUIREMENT_FILES} \
149141
${CONDA_PYTHON_REQUIREMENT} \
150-
scikit-learn \
151-
scipy || exit 1
142+
|| exit 1
152143

153144
source activate $CONDA_ENV
154145

@@ -310,10 +301,10 @@ matplotlib.use\(\"Agg\"\)\
310301
' plot_example.py # prevent interactive window mode
311302
sed -i'.bak' 's/graph.render(view=True)/graph.render(view=False)/' plot_example.py
312303
# requirements for examples
313-
mamba install -q -y -n $CONDA_ENV \
314-
h5py \
315-
ipywidgets \
316-
notebook
304+
mamba install -y -n $CONDA_ENV \
305+
'h5py>=3.10' \
306+
'ipywidgets>=8.1.2' \
307+
'notebook>=7.1.2'
317308
for f in *.py **/*.py; do python $f || exit 1; done # run all examples
318309
cd $BUILD_DIRECTORY/examples/python-guide/notebooks
319310
sed -i'.bak' 's/INTERACTIVE = False/assert False, \\"Interactive mode disabled\\"/' interactive_plot_example.ipynb
@@ -325,7 +316,7 @@ matplotlib.use\(\"Agg\"\)\
325316
dask \
326317
distributed \
327318
joblib \
328-
matplotlib \
319+
matplotlib-base \
329320
psutil \
330321
pyarrow \
331322
python-graphviz \

.ci/test_windows.ps1

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,21 @@ conda config --set always_yes yes --set changeps1 no
4646
# ref:
4747
# * https://stackoverflow.com/a/62897729/3986677
4848
# * https://github.com/microsoft/LightGBM/issues/5899
49-
conda install brotlipy
49+
conda install "brotlipy>=0.7"
5050

5151
conda update -q -y conda
52-
conda create -q -y -n $env:CONDA_ENV `
53-
cffi `
54-
cloudpickle `
55-
joblib `
56-
matplotlib `
57-
numpy `
58-
pandas `
59-
psutil `
60-
pyarrow `
61-
pytest `
62-
"python=$env:PYTHON_VERSION[build=*cpython]" `
63-
python-graphviz `
64-
scikit-learn `
65-
scipy ; Check-Output $?
52+
53+
if ($env:PYTHON_VERSION -eq "3.7") {
54+
$env:CONDA_REQUIREMENT_FILE = "$env:BUILD_SOURCESDIRECTORY/.ci/conda-envs/ci-core-py37.txt"
55+
} else {
56+
$env:CONDA_REQUIREMENT_FILE = "$env:BUILD_SOURCESDIRECTORY/.ci/conda-envs/ci-core.txt"
57+
}
58+
59+
conda create `
60+
-y `
61+
-n $env:CONDA_ENV `
62+
--file $env:CONDA_REQUIREMENT_FILE `
63+
"python=$env:PYTHON_VERSION[build=*cpython]" ; Check-Output $?
6664

6765
if ($env:TASK -ne "bdist") {
6866
conda activate $env:CONDA_ENV
@@ -124,7 +122,7 @@ if (($env:TASK -eq "regular") -or (($env:APPVEYOR -eq "true") -and ($env:TASK -e
124122
cd $env:BUILD_SOURCESDIRECTORY/examples/python-guide
125123
@("import matplotlib", "matplotlib.use('Agg')") + (Get-Content "plot_example.py") | Set-Content "plot_example.py"
126124
(Get-Content "plot_example.py").replace('graph.render(view=True)', 'graph.render(view=False)') | Set-Content "plot_example.py" # prevent interactive window mode
127-
conda install -q -y -n $env:CONDA_ENV "h5py>3.0" ipywidgets notebook
125+
conda install -y -n $env:CONDA_ENV "h5py>=3.10" "ipywidgets>=8.1.2" "notebook>=7.1.2"
128126
foreach ($file in @(Get-ChildItem *.py)) {
129127
@("import sys, warnings", "warnings.showwarning = lambda message, category, filename, lineno, file=None, line=None: sys.stdout.write(warnings.formatwarning(message, category, filename, lineno, line))") + (Get-Content $file) | Set-Content $file
130128
python $file ; Check-Output $?

0 commit comments

Comments
 (0)