Skip to content

Commit

Permalink
CI: Change build using external igraph
Browse files Browse the repository at this point in the history
  • Loading branch information
vtraag committed Jul 12, 2024
1 parent e9d3ff1 commit 4e6ea0f
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 12 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build wheels (manylinux)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "yum install -y flex bison libxml2-devel zlib-devel cairo-devel && pip install -U cmake pip setuptools wheel && python setup.py build_c_core"
CIBW_BEFORE_BUILD: "yum install -y flex bison libxml2-devel zlib-devel cairo-devel && pip install -U cmake pip setuptools wheel && scripts/build_igraph.sh"
CIBW_BUILD: "*-manylinux_${{ matrix.wheel_arch }}"
# Skip tests for Python 3.10 onwards because SciPy does not have
# 32-bit wheels for Linux
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Build wheels (musllinux)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "apk add flex bison libxml2-dev zlib-dev cairo-dev && pip install -U cmake pip setuptools wheel && python setup.py build_c_core"
CIBW_BEFORE_BUILD: "apk add flex bison libxml2-dev zlib-dev cairo-dev && pip install -U cmake pip setuptools wheel && scripts/build_igraph.sh"
CIBW_BUILD: "*-musllinux_${{ matrix.wheel_arch }}"
CIBW_TEST_COMMAND: "cd {project} && pip install --prefer-binary '.[test-musl]' && python -m pytest -v tests"

Expand All @@ -66,7 +66,7 @@ jobs:
- name: Build wheels (manylinux)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "yum install -y flex bison libxml2-devel zlib-devel cairo-devel && pip install -U cmake pip setuptools wheel && python setup.py build_c_core"
CIBW_BEFORE_BUILD: "yum install -y flex bison libxml2-devel zlib-devel cairo-devel && pip install -U cmake pip setuptools wheel && scripts/build_igraph.sh"
CIBW_ARCHS_LINUX: aarch64
CIBW_BUILD: "*-manylinux_aarch64"

Expand All @@ -91,7 +91,7 @@ jobs:
- name: Build wheels (musllinux)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "apk add flex bison libxml2-dev zlib-dev cairo-dev && pip install -U cmake pip setuptools wheel && python setup.py build_c_core"
CIBW_BEFORE_BUILD: "apk add flex bison libxml2-dev zlib-dev cairo-dev && pip install -U cmake pip setuptools wheel && scripts/build_igraph.sh"
CIBW_ARCHS_LINUX: aarch64
CIBW_BUILD: "*-musllinux_aarch64"
CIBW_TEST_COMMAND: "cd {project} && pip install --prefer-binary '.[test-musl]' && python -m pytest -v tests"
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: "${{ matrix.wheel_arch }}"
CIBW_BEFORE_BUILD: "pip install -U setuptools && python setup.py build_c_core"
CIBW_BEFORE_BUILD: "pip install -U setuptools && scripts/build_igraph.sh"
CIBW_ENVIRONMENT: "LDFLAGS=-L$HOME/local/lib"
IGRAPH_CMAKE_EXTRA_ARGS: -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }} ${{ matrix.cmake_extra_args }} -DCMAKE_PREFIX_PATH=$HOME/local

Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "pip install -U setuptools && python setup.py build_c_core"
CIBW_BEFORE_BUILD: "pip install -U setuptools && scripts/build_igraph.bat"
CIBW_BUILD: "*-${{ matrix.wheel_arch }}"
CIBW_TEST_COMMAND: "cd /d {project} && pip install --prefer-binary \".[test]\" && python -m pytest tests"
# Skip tests for Python 3.10 onwards because SciPy does not have
Expand Down Expand Up @@ -303,7 +303,7 @@ jobs:

- name: Build sdist
run: |
python setup.py build_c_core
scripts/build_igraph.sh
python setup.py sdist
python setup.py install
Expand Down Expand Up @@ -356,7 +356,7 @@ jobs:
env:
IGRAPH_USE_SANITIZERS: 1
run: |
python setup.py build_c_core
scripts/build_igraph.sh
- name: Build and install Python extension
env:
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

63 changes: 63 additions & 0 deletions scripts/build_igraph.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@echo off

set IGRAPH_VERSION=0.10.13

set ROOT_DIR=%cd%
echo Using root dir %ROOT_DIR%

if not exist "%ROOT_DIR%\build-deps\src\" (
md %ROOT_DIR%\build-deps\src
)

cd "%ROOT_DIR%\build-deps\src"
if not exist "igraph\" (
echo.
echo Cloning igraph into %ROOT_DIR%\build-deps\src\igraph
REM Clone repository if it does not exist yet
git clone --depth 1 --branch %IGRAPH_VERSION% https://github.com/igraph/igraph.git
)

REM Make sure the git repository points to the correct version
echo.
echo Checking out %IGRAPH_VERSION} in ${ROOT_DIR%\build-deps\src\igraph
cd "%ROOT_DIR%\build-deps\src\igraph"
git fetch origin tag %IGRAPH_VERSION% --no-tags
git checkout %IGRAPH_VERSION%

REM Make build directory
if not exist "%ROOT_DIR%\build-deps\build\igraph\" (
echo.
echo Make directory %ROOT_DIR%\build-deps\build\igraph
md %ROOT_DIR%\build-deps\build\igraph
)

REM Configure, build and install
cd "%ROOT_DIR%\build-deps\build\igraph"

echo.
echo Configure igraph build
cmake %ROOT_DIR%\build-deps\src\igraph ^
-DCMAKE_INSTALL_PREFIX=%ROOT_DIR%\build-deps\install\ ^
-DBUILD_SHARED_LIBS=ON ^
-DIGRAPH_GLPK_SUPPORT=ON ^
-DIGRAPH_GRAPHML_SUPPORT=ON ^
-DIGRAPH_OPENMP_SUPPORT=ON ^
-DIGRAPH_USE_INTERNAL_BLAS=ON ^
-DIGRAPH_USE_INTERNAL_LAPACK=ON ^
-DIGRAPH_USE_INTERNAL_ARPACK=ON ^
-DIGRAPH_USE_INTERNAL_GLPK=ON ^
-DIGRAPH_USE_INTERNAL_GMP=ON ^
-DIGRAPH_WARNINGS_AS_ERRORS=OFF ^
-DCMAKE_BUILD_TYPE=Release ^
-DBUILD_TESTING=OFF ^
%EXTRA_CMAKE_ARGS%

echo.
echo Build igraph
cmake --build . --config Release

echo.
echo Install igraph to %ROOT_DIR%\build-deps\install\
cmake --build . --target install --config Release

cd "%ROOT_DIR%"
61 changes: 61 additions & 0 deletions scripts/build_igraph.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
IGRAPH_VERSION=0.10.13

ROOT_DIR=`pwd`
echo "Using root dir ${ROOT_DIR}"

# Create source directory
if [ ! -d "${ROOT_DIR}/build-deps/src" ]; then
echo ""
echo "Make directory ${ROOT_DIR}/build-deps/src"
mkdir -p ${ROOT_DIR}/build-deps/src
fi

cd ${ROOT_DIR}/build-deps/src
if [ ! -d "igraph" ]; then
echo ""
echo "Cloning igraph into ${ROOT_DIR}/build-deps/src/igraph"
# Clone repository if it does not exist yet
git clone --branch ${IGRAPH_VERSION} https://github.com/igraph/igraph.git --single-branch
fi

# Make sure the git repository points to the correct version
echo ""
echo "Checking out ${IGRAPH_VERSION} in ${ROOT_DIR}/build-deps/src/igraph"
cd ${ROOT_DIR}/build-deps/src/igraph
git fetch origin tag ${IGRAPH_VERSION} --no-tags
git checkout ${IGRAPH_VERSION}

# Make build directory
if [ ! -d "${ROOT_DIR}/build-deps/build/igraph" ]; then
echo ""
echo "Make directory ${ROOT_DIR}/build-deps/build/igraph"
mkdir -p ${ROOT_DIR}/build-deps/build/igraph
fi

# Configure, build and install
cd ${ROOT_DIR}/build-deps/build/igraph

echo ""
echo "Configure igraph build"
cmake ${ROOT_DIR}/build-deps/src/igraph \
-DCMAKE_INSTALL_PREFIX=${ROOT_DIR}/build-deps/install/ \
-DBUILD_SHARED_LIBS=ON \
-DIGRAPH_GLPK_SUPPORT=ON \
-DIGRAPH_GRAPHML_SUPPORT=ON \
-DIGRAPH_OPENMP_SUPPORT=ON \
-DIGRAPH_USE_INTERNAL_BLAS=ON \
-DIGRAPH_USE_INTERNAL_LAPACK=ON \
-DIGRAPH_USE_INTERNAL_ARPACK=ON \
-DIGRAPH_USE_INTERNAL_GLPK=ON \
-DIGRAPH_USE_INTERNAL_GMP=ON \
-DIGRAPH_WARNINGS_AS_ERRORS=OFF \
-DCMAKE_BUILD_TYPE=Release \
${EXTRA_CMAKE_ARGS}

echo ""
echo "Build igraph"
cmake --build .

echo ""
echo "Install igraph to ${ROOT_DIR}/build-deps/install/"
cmake --build . --target install
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def get_tag(self):
igraph_extension = Extension(
"igraph._igraph",
libraries=["igraph"],
include_dirs=['build-deps/install/include'],
library_dirs=['build-deps/install/lib'],
sources=sources,
py_limited_api=should_build_abi3_wheel,
define_macros=macros,
Expand Down
1 change: 0 additions & 1 deletion vendor/source/igraph
Submodule igraph deleted from ac22a9

0 comments on commit 4e6ea0f

Please sign in to comment.