diff --git a/.github/workflows/centos.yml b/.github/workflows/centos.yml index 6c82936..c342cf8 100644 --- a/.github/workflows/centos.yml +++ b/.github/workflows/centos.yml @@ -36,39 +36,38 @@ jobs: shared: [ON, OFF] steps: - - name: Checkout or-tools rte-france - if: ${{ env.RELEASE_CREATED == 'false' }} + - name: Checkout this repository uses: actions/checkout@v4 - with: - repository: rte-france/or-tools - ref: ${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} - - name: Checkout or-tools google + - name: set or-tools repo vars release if: ${{ env.RELEASE_CREATED == 'true' }} - uses: actions/checkout@v4 - with: - repository: google/or-tools - ref: 'stable' - - - name: Checkout this repository - uses: actions/checkout@v4 - with: - path: "patch" + shell: bash + run: | + OR_REPO="https://github.com/google/or-tools.git" + TAGNAME="${{ github.event.release.tag_name }}" + TAGNAME_WITHOUT_SUFFIX=${TAGNAME%%-*} + echo "OR_REPO=$OR_REPO" >> $GITHUB_ENV + echo "OR_REF=$TAGNAME_WITHOUT_SUFFIX" >> $GITHUB_ENV - - name: Apply patch + - name: set or-tools repo vars not release + if: ${{ env.RELEASE_CREATED == 'false' }} + shell: bash run: | - cp -r patch/ortools patch/patch.py patch/patch_utils.py . - python3 patch.py + OR_REPO="https://github.com/rte-france/or-tools.git" + OR_REF=${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} + echo "OR_REPO=$OR_REPO" >> $GITHUB_ENV + echo "OR_REF=$OR_REF" >> $GITHUB_ENV - name: Build inside docker run: | - cp -r patch/docker . docker build \ --target build \ -t centos:shared-${{ matrix.shared }}-sirius-${{ matrix.sirius }} \ --build-arg="SIRIUS=${{ matrix.sirius }}" \ --build-arg="SHARED=${{ matrix.shared }}" \ --build-arg="SIRIUS_RELEASE_TAG=${{ env.SIRIUS_RELEASE_TAG }}" \ + --build-arg="OR_REPO=${{ env.OR_REPO }}" \ + --build-arg="OR_REF=${{ env.OR_REF }}" \ -f docker/centos.dockerfile . - name: retrieve install from docker diff --git a/.github/workflows/oracle.yml b/.github/workflows/oracle.yml index e7eb01a..a4f0c0a 100644 --- a/.github/workflows/oracle.yml +++ b/.github/workflows/oracle.yml @@ -52,9 +52,6 @@ jobs: APPENDIX_WITH_SHARED="${OS}${WITH_SHARED}${WITH_SIRIUS}" echo "appendix_with_shared=$APPENDIX_WITH_SHARED" >> $GITHUB_OUTPUT - # Fill variable ${BRANCH_NAME} - - uses: nelonoel/branch-name@v1.0.1 - - name: Install requirements (dnf) run: | dnf -y update @@ -102,29 +99,27 @@ jobs: with: cmake-version: '3.26.x' - - name: Checkout or-tools - if: ${{ env.RELEASE_CREATED == 'false' }} + - name: Checkout this repository uses: actions/checkout@v4 - with: - repository: rte-france/or-tools - ref: ${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} - - name: Checkout or-tools + - name: set or-tools repo vars release if: ${{ env.RELEASE_CREATED == 'true' }} - uses: actions/checkout@v4 - with: - repository: google/or-tools - ref: 'stable' - - - name: Checkout this repository - uses: actions/checkout@v4 - with: - path: "patch" + shell: bash + run: | + OR_REPO="https://github.com/google/or-tools.git" + TAGNAME="${{ github.event.release.tag_name }}" + TAGNAME_WITHOUT_SUFFIX=${TAGNAME%%-*} + echo "OR_REPO=$OR_REPO" >> $GITHUB_ENV + echo "OR_REF=$TAGNAME_WITHOUT_SUFFIX" >> $GITHUB_ENV - - name: Apply patch + - name: set or-tools repo vars not release + if: ${{ env.RELEASE_CREATED == 'false' }} + shell: bash run: | - cp -r patch/ortools patch/patch.py patch/patch_utils.py . - python3 patch.py + OR_REPO="https://github.com/rte-france/or-tools.git" + OR_REF=${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} + echo "OR_REPO=$OR_REPO" >> $GITHUB_ENV + echo "OR_REF=$OR_REF" >> $GITHUB_ENV - name: Set-up Xpress with pip run: | @@ -150,6 +145,8 @@ jobs: cmake --version cmake -S . -B build \ -DCMAKE_BUILD_TYPE=Release \ + -Dortools_REPO=${{ env.OR_REPO }} \ + -Dortools_REF=${{ env.OR_REF }} \ -DBUILD_SHARED_LIBS=${{ matrix.cmake.shared }} \ -DBUILD_PYTHON=${{ matrix.cmake.python }} \ -DBUILD_JAVA=${{ matrix.cmake.java }} \ @@ -211,7 +208,7 @@ jobs: run: | MY_DIR="ortools_python-3.9${{ steps.names.outputs.appendix }}" mkdir $MY_DIR - cp build/python/dist/*.whl $MY_DIR + cp ./build/_deps/ortools-build/python/dist/*.whl $MY_DIR ARCHIVE_NAME="${MY_DIR}.zip" ARCHIVE_PATH="$PWD/${ARCHIVE_NAME}" zip -r ${ARCHIVE_PATH} ${MY_DIR} @@ -236,7 +233,7 @@ jobs: run: | MY_DIR="ortools_java${{ steps.names.outputs.appendix }}" mkdir ${MY_DIR} - cp build/java/ortools-*/target/*.jar $MY_DIR + cp ./build/_deps/ortools-build/java/ortools-*/target/*.jar $MY_DIR ARCHIVE_NAME="${MY_DIR}.zip" ARCHIVE_PATH="$PWD/${ARCHIVE_NAME}" df -h diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 073084e..58e602b 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -46,34 +46,32 @@ jobs: sirius: [ON, OFF] sirius-release-tag: [antares-integration-v1.4] steps: - - name: Checkout or-tools - if: ${{ env.RELEASE_CREATED == 'false' }} - uses: actions/checkout@v4 - with: - repository: rte-france/or-tools - ref: ${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} - - - name: Checkout or-tools - if: ${{ env.RELEASE_CREATED == 'true' }} - uses: actions/checkout@v4 - with: - repository: google/or-tools - ref: 'stable' - - name: Checkout this repository uses: actions/checkout@v4 - with: - path: "patch" - name: Setup Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.cmake.python-version }} - - name: Apply patch + - name: set or-tools repo vars release + if: ${{ env.RELEASE_CREATED == 'true' }} + shell: bash + run: | + OR_REPO="https://github.com/google/or-tools.git" + TAGNAME="${{ github.event.release.tag_name }}" + TAGNAME_WITHOUT_SUFFIX=${TAGNAME%%-*} + echo "OR_REPO=$OR_REPO" >> $GITHUB_ENV + echo "OR_REF=$TAGNAME_WITHOUT_SUFFIX" >> $GITHUB_ENV + + - name: set or-tools repo vars not release + if: ${{ env.RELEASE_CREATED == 'false' }} + shell: bash run: | - cp -r patch/ortools patch/patch.py patch/patch_utils.py . - python patch.py + OR_REPO="https://github.com/rte-france/or-tools.git" + OR_REF=${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} + echo "OR_REPO=$OR_REPO" >> $GITHUB_ENV + echo "OR_REF=$OR_REF" >> $GITHUB_ENV - name: Install GCC10 and others shell: bash @@ -99,7 +97,7 @@ jobs: - name: Setup .NET 6.0 if: ${{ matrix.cmake.dotnet == 'ON' }} - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 6.0.x @@ -137,6 +135,8 @@ jobs: run: > cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + -Dortools_REPO=${{ env.OR_REPO }} + -Dortools_REF=${{ env.OR_REF }} -DBUILD_SHARED_LIBS=${{ matrix.cmake.shared }} -DBUILD_PYTHON=${{ matrix.cmake.python }} -DBUILD_JAVA=${{ matrix.cmake.java }} @@ -226,7 +226,7 @@ jobs: id: wheel shell: bash run: | - cd ./build/python/dist + cd ./build/_deps/ortools-build/python/dist MY_DIR="ortools_python-${{ matrix.cmake.python-version }}${{ steps.names.outputs.appendix }}" mkdir ${MY_DIR} cp *.whl "${MY_DIR}" @@ -253,7 +253,7 @@ jobs: id: jar shell: bash run: | - cd ./build/java + cd ./build/_deps/ortools-build/java MY_DIR="ortools_java${{ steps.names.outputs.appendix }}" mkdir ${MY_DIR} cp ortools-*/target/*.jar "${MY_DIR}" @@ -280,7 +280,7 @@ jobs: id: dotnet shell: bash run: | - cd ./build/dotnet/packages/ + cd ./build/_deps/ortools-build/dotnet/packages/ MY_DIR="ortools_dotnet${{ steps.names.outputs.appendix }}" mkdir ${MY_DIR} cp Google.OrTools.*.nupkg "${MY_DIR}" diff --git a/.github/workflows/windows-cpp.yml b/.github/workflows/windows-cpp.yml index 352b56c..9326a5b 100644 --- a/.github/workflows/windows-cpp.yml +++ b/.github/workflows/windows-cpp.yml @@ -37,19 +37,29 @@ jobs: os: [windows-latest] sirius-release-tag: [ antares-integration-v1.4 ] steps: - - name: Checkout or-tools - if: ${{ env.RELEASE_CREATED == 'false' }} - uses: actions/checkout@v4 - with: - repository: rte-france/or-tools - ref: ${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} + - name: set or-tools repo vars if release + if: ${{ env.RELEASE_CREATED == 'true' }} + shell: bash + run: | + OR_REPO="https://github.com/google/or-tools.git" + TAGNAME="${{ github.event.release.tag_name }}" + TAGNAME_WITHOUT_SUFFIX=${TAGNAME%%-*} + echo "OR_REPO=$OR_REPO" >> $GITHUB_ENV + echo "OR_REF=$TAGNAME_WITHOUT_SUFFIX" >> $GITHUB_ENV - - name: Checkout or-tools + - name: Checkout or-tools if release if: ${{ env.RELEASE_CREATED == 'true' }} uses: actions/checkout@v4 with: repository: google/or-tools - ref: 'stable' + ref: ${{ env.OR_REF }} + + - name: Checkout or-tools not release + if: ${{ env.RELEASE_CREATED == 'false' }} + uses: actions/checkout@v4 + with: + repository: rte-france/or-tools + ref: ${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} - name: Checkout this repository uses: actions/checkout@v4 @@ -64,7 +74,7 @@ jobs: - name: Apply patch shell: bash run: | - cp -r patch/ortools patch/patch.py patch/patch_utils.py . + cp -r patch/ortools patch/patch.py patch/patch_utils.py patch/cmake_patches . python patch.py - name: Set-up Xpress with pip diff --git a/.github/workflows/windows-python.yml b/.github/workflows/windows-python.yml index 8770982..dfe4a48 100644 --- a/.github/workflows/windows-python.yml +++ b/.github/workflows/windows-python.yml @@ -39,19 +39,29 @@ jobs: { version: "3.11", dir: Python311 }, ] steps: - - name: Checkout or-tools - if: ${{ env.RELEASE_CREATED == 'false' }} - uses: actions/checkout@v4 - with: - repository: rte-france/or-tools - ref: ${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} + - name: set or-tools repo vars if release + if: ${{ env.RELEASE_CREATED == 'true' }} + shell: bash + run: | + OR_REPO="https://github.com/google/or-tools.git" + TAGNAME="${{ github.event.release.tag_name }}" + TAGNAME_WITHOUT_SUFFIX=${TAGNAME%%-*} + echo "OR_REPO=$OR_REPO" >> $GITHUB_ENV + echo "OR_REF=$TAGNAME_WITHOUT_SUFFIX" >> $GITHUB_ENV - - name: Checkout or-tools + - name: Checkout or-tools if release if: ${{ env.RELEASE_CREATED == 'true' }} uses: actions/checkout@v4 with: repository: google/or-tools - ref: 'stable' + ref: ${{ env.OR_REF }} + + - name: Checkout or-tools not release + if: ${{ env.RELEASE_CREATED == 'false' }} + uses: actions/checkout@v4 + with: + repository: rte-france/or-tools + ref: ${{ github.event.inputs.rtefrance_ortools_branch || 'main' }} - name: Checkout this repository uses: actions/checkout@v4 @@ -69,7 +79,7 @@ jobs: - name: Apply patch shell: bash run: | - cp -r patch/ortools patch/patch.py patch/patch_utils.py . + cp -r patch/ortools patch/patch.py patch/patch_utils.py patch/cmake_patches . python patch.py - name: Install SWIG 4.1.1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1955c14..026a6a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ endif () if (NOT DEFINED ortools_REF) message(FATAL_ERROR "ortools_REF is not defined") endif () +find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) +message("found PYTHON interpreter ${Python_EXECUTABLE} = " ${Python_EXECUTABLE}) FetchContent_Declare(ortools GIT_REPOSITORY ${ortools_REPO} GIT_TAG ${ortools_REF} @@ -19,8 +21,8 @@ FetchContent_Declare(ortools ${CMAKE_CURRENT_SOURCE_DIR}/patch.py ${CMAKE_CURRENT_SOURCE_DIR}/patch_utils.py ${CMAKE_CURRENT_SOURCE_DIR}/ortools - ${CMAKE_CURRENT_SOURCE_DIR}/patchs - . && python patch.py + ${CMAKE_CURRENT_SOURCE_DIR}/cmake_patches + . && ${Python3_EXECUTABLE} patch.py OVERRIDE_FIND_PACKAGE ON ) message("BUILD_DEPS: " ${BUILD_DEPS}) @@ -30,12 +32,7 @@ set_if_not_defined(BUILD_FLATZINC "OFF" CACHE INTERNAL "") set_if_not_defined(BUILD_EXAMPLES "OFF" CACHE INTERNAL "") set_if_not_defined(USE_SCIP "ON" CACHE INTERNAL "") set_if_not_defined(USE_GLPK "ON" CACHE INTERNAL "") -# We build OR-Tools as a static lib. Cyclic dependencies are detected -# without this flag. -set_if_not_defined(BUILD_SHARED_LIBS "OFF" CACHE INTERNAL "") -# In mode optimization error analysis, we call Sirius through or-tools -# So we need to activate Sirius in or-tools configuration (OFF by default) -set_if_not_defined(USE_SIRIUS "ON" CACHE INTERNAL "") +set_if_not_defined(USE_SIRIUS "OFF" CACHE INTERNAL "") FetchContent_MakeAvailable(ortools) find_package(ortools REQUIRED) diff --git a/patchs/sirius.cmake b/cmake_patches/sirius.cmake similarity index 100% rename from patchs/sirius.cmake rename to cmake_patches/sirius.cmake diff --git a/docker/centos.dockerfile b/docker/centos.dockerfile index eb7453c..f68a56d 100644 --- a/docker/centos.dockerfile +++ b/docker/centos.dockerfile @@ -11,7 +11,7 @@ RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo &&\ sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo &&\ sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo &&\ sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo &&\ - yum install -y devtoolset-11 &&\ + yum install -y devtoolset-11 python3-devel python3-pip python3-numpy &&\ python3 -m pip install --upgrade pip &&\ python3 -m pip install dataclasses @@ -55,10 +55,14 @@ FROM base AS devel ARG SIRIUS=OFF ARG SHARED=ON ARG BUILD_EXAMPLES=OFF +ARG OR_REPO="https://github.com/google/or-tools.git" +ARG OR_REF="stable" WORKDIR /home/project COPY . . FROM devel AS build RUN cmake -S. -Bbuild \ + -Dortools_REPO=${OR_REPO} \ + -Dortools_REF=${OR_REF} \ -DBUILD_DEPS=ON \ -DBUILD_SHARED_LIBS=${SHARED} \ -DUSE_SIRIUS=${SIRIUS}\ diff --git a/patch.py b/patch.py index b37f7c5..6b19078 100644 --- a/patch.py +++ b/patch.py @@ -38,7 +38,7 @@ # add the USE_SIRIUS configuration flag in deps.cmake full_patch.append(Addition( - Path.cwd()/'cmake'/'deps.cmake', + Path.cwd()/'cmake'/'system_deps.cmake', ''' if(USE_CPLEX) find_package(CPLEX REQUIRED) @@ -47,7 +47,7 @@ ''' #add SIRIUS if (USE_SIRIUS) - include(patchs/sirius.cmake) + include(cmake_patches/sirius.cmake) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif()