Skip to content
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

use FetchContent instead of submodules #6322

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ environment:
clone_depth: 5

install:
- git submodule update --init --recursive # get `external_libs` folder
- set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH%
- set PYTHON_VERSION=%CONFIGURATION%
- set CONDA_ENV="test-env"
Expand Down
3 changes: 1 addition & 2 deletions .ci/lint-cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ echo "done running cpplint"

echo "running cmakelint"
cmake_files=$(
find . -name CMakeLists.txt -o -path "./cmake/*.cmake" \
| grep -v external_libs
find . -name CMakeLists.txt -o -path "./cmake/*.cmake"
)
cmakelint \
--linelength=120 \
Expand Down
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ indent_size = 2
[*.{py,sh,js}]
indent_size = 4
line_length = 120
skip = external_libs
known_first_party = lightgbm

# Placeholder files
Expand Down
12 changes: 0 additions & 12 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
exclude: |
(?x)^(
build|
external_libs|
lightgbm-python|
lightgbm_r|
)$
Expand Down
33 changes: 29 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ cmake_minimum_required(VERSION 3.18)

project(lightgbm LANGUAGES C CXX)

include(FetchContent)
FetchContent_Declare(
fast_double_parser
GIT_REPOSITORY https://github.com/lemire/fast_double_parser.git
GIT_TAG efec03532ef65984786e5e32dbc81f6e6a55a115
)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG f5e54359df4c26b6230fc61d38aa294581393084
)
FetchContent_MakeAvailable(fast_double_parser fmt)
include_directories(${fast_double_parser_SOURCE_DIR}/include)
include_directories(${fmt_SOURCE_DIR}/include/fmt)

if(BUILD_CPP_TEST)
set(CMAKE_CXX_STANDARD 14)
else()
Expand Down Expand Up @@ -111,8 +126,13 @@ if(USE_SWIG)
endif()
endif()

set(EIGEN_DIR "${PROJECT_SOURCE_DIR}/external_libs/eigen")
include_directories(${EIGEN_DIR})
FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3147391d946bb4b6c68edd901f2add6ac1f31f8c
)
FetchContent_MakeAvailable(eigen)
include_directories(${eigen_SOURCE_DIR})

# See https://gitlab.com/libeigen/eigen/-/blob/master/COPYING.README
add_definitions(-DEIGEN_MPL2_ONLY)
Expand Down Expand Up @@ -171,8 +191,13 @@ if(USE_OPENMP)
endif()

if(USE_GPU)
set(BOOST_COMPUTE_HEADER_DIR ${PROJECT_SOURCE_DIR}/external_libs/compute/include)
include_directories(${BOOST_COMPUTE_HEADER_DIR})
FetchContent_Declare(
compute
GIT_REPOSITORY https://github.com/boostorg/compute.git
GIT_TAG 36350b7de849300bd3d72a05d8bf890ca405a014
)
FetchContent_MakeAvailable(compute)
include_directories(${compute_SOURCE_DIR}/include)
find_package(OpenCL REQUIRED)
include_directories(${OpenCL_INCLUDE_DIRS})
message(STATUS "OpenCL include directory: " ${OpenCL_INCLUDE_DIRS})
Expand Down
80 changes: 0 additions & 80 deletions build-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,85 +211,6 @@ create_isolated_source_dir() {
cp -R ./src ./lightgbm-python
cp -R ./swig ./lightgbm-python
cp -R ./windows ./lightgbm-python

# include only specific files from external_libs, to keep the package
# small and avoid redistributing code with licenses incompatible with
# LightGBM's license

######################
# fast_double_parser #
######################
mkdir -p ./lightgbm-python/external_libs/fast_double_parser
cp \
external_libs/fast_double_parser/CMakeLists.txt \
./lightgbm-python/external_libs/fast_double_parser/CMakeLists.txt
cp \
external_libs/fast_double_parser/LICENSE* \
./lightgbm-python/external_libs/fast_double_parser/

mkdir -p ./lightgbm-python/external_libs/fast_double_parser/include/
cp \
external_libs/fast_double_parser/include/fast_double_parser.h \
./lightgbm-python/external_libs/fast_double_parser/include/

#######
# fmt #
#######
mkdir -p ./lightgbm-python/external_libs/fmt
cp \
external_libs/fast_double_parser/CMakeLists.txt \
./lightgbm-python/external_libs/fmt/CMakeLists.txt
cp \
external_libs/fmt/LICENSE* \
./lightgbm-python/external_libs/fmt/

mkdir -p ./lightgbm-python/external_libs/fmt/include/fmt
cp \
external_libs/fmt/include/fmt/*.h \
./lightgbm-python/external_libs/fmt/include/fmt/

#########
# Eigen #
#########
mkdir -p ./lightgbm-python/external_libs/eigen/Eigen
cp \
external_libs/eigen/CMakeLists.txt \
./lightgbm-python/external_libs/eigen/CMakeLists.txt

modules="Cholesky Core Dense Eigenvalues Geometry Householder Jacobi LU QR SVD"
for eigen_module in ${modules}; do
cp \
external_libs/eigen/Eigen/${eigen_module} \
./lightgbm-python/external_libs/eigen/Eigen/${eigen_module}
if [ ${eigen_module} != "Dense" ]; then
mkdir -p ./lightgbm-python/external_libs/eigen/Eigen/src/${eigen_module}/
cp \
-R \
external_libs/eigen/Eigen/src/${eigen_module}/* \
./lightgbm-python/external_libs/eigen/Eigen/src/${eigen_module}/
fi
done

mkdir -p ./lightgbm-python/external_libs/eigen/Eigen/misc
cp \
-R \
external_libs/eigen/Eigen/src/misc \
./lightgbm-python/external_libs/eigen/Eigen/src/misc/

mkdir -p ./lightgbm-python/external_libs/eigen/Eigen/plugins
cp \
-R \
external_libs/eigen/Eigen/src/plugins \
./lightgbm-python/external_libs/eigen/Eigen/src/plugins/

###################
# compute (Boost) #
###################
mkdir -p ./lightgbm-python/external_libs/compute
cp \
-R \
external_libs/compute/include \
./lightgbm-python/external_libs/compute/include/
}

create_isolated_source_dir
Expand All @@ -305,7 +226,6 @@ if test "${INSTALL}" = true; then
rm -rf \
./cmake \
./CMakeLists.txt \
./external_libs \
./include \
./src \
./swig \
Expand Down
1 change: 0 additions & 1 deletion external_libs/compute
Submodule compute deleted from 36350b
1 change: 0 additions & 1 deletion external_libs/eigen
Submodule eigen deleted from 314739
1 change: 0 additions & 1 deletion external_libs/fast_double_parser
Submodule fast_double_parser deleted from efec03
1 change: 0 additions & 1 deletion external_libs/fmt
Submodule fmt deleted from f5e543
4 changes: 2 additions & 2 deletions include/LightGBM/utils/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include <vector>

#define FMT_HEADER_ONLY
#include "../../../external_libs/fast_double_parser/include/fast_double_parser.h"
#include "../../../external_libs/fmt/include/fmt/format.h"
#include "fast_double_parser.h"
#include "format.h"

#ifdef _MSC_VER
#include <intrin.h>
Expand Down
5 changes: 1 addition & 4 deletions python-package/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,17 @@ minimum-version = "0.4.4"
[tool.isort]
line_length = 120
skip_glob = [
"*/external_libs/*",
"*/lightgbm-python/*"
]

[tool.mypy]
exclude = 'build/*|compile/*|docs/*|examples/*|external_libs/*|lightgbm-python/*|tests/*'
exclude = 'build/*|compile/*|docs/*|examples/*|lightgbm-python/*|tests/*'
ignore_missing_imports = true

[tool.ruff]
exclude = [
"build",
"compile",
"external_libs",
"lightgbm-python",
]
line-length = 120
Expand All @@ -109,7 +107,6 @@ exclude = [
"build/*.py",
"compile/*.py",
"examples/*.py",
"external_libs/*.py",
"lightgbm-python/*.py",
"python-package/*.py",
"tests/*.py"
Expand Down
1 change: 0 additions & 1 deletion python-package/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ ignore =
W503
exclude =
./.nuget,
./external_libs,
./lightgbm-python,
./python-package/build,
./python-package/compile
Loading