diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 9e84f38b38..6df5751a7e 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -18,7 +18,7 @@ concurrency: cancel-in-progress: true jobs: - ResInsight-x64-buildcache: + build: runs-on: ${{ matrix.config.os }} strategy: fail-fast: false @@ -34,6 +34,7 @@ jobs: build-python-module: true, execute-unit-tests: true, unity-build: true, + publish-to-pypi: false, } - { name: "Ubuntu Latest gcc", @@ -45,6 +46,7 @@ jobs: build-python-module: true, execute-unit-tests: true, unity-build: false, + publish-to-pypi: true, } - { name: "Ubuntu Latest clang", @@ -56,6 +58,7 @@ jobs: build-python-module: true, execute-unit-tests: true, unity-build: false, + publish-to-pypi: false, } steps: - name: Checkout @@ -79,10 +82,9 @@ jobs: run: echo "${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}" - name: Install dependencies - # Make sure protobuf version is compatible with grpc - https://github.com/OPM/ResInsight/issues/9304 run: | python -m pip install --upgrade pip - pip install -r requirements.txt + pip install -r GrpcInterface/Python/requirements.txt - name: Use CMake uses: lukka/get-cmake@latest @@ -232,12 +234,52 @@ jobs: env: RESINSIGHT_EXECUTABLE: ${{ runner.workspace }}/ResInsight/cmakebuild/ApplicationExeCode/ResInsight run: | - cd GrpcInterface/Python/rips + cd GrpcInterface/Python + python setup.py sdist + cd rips ${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pytest --console - - name: Upload artifact + - name: Upload python distribution folder + if: matrix.config.publish-to-pypi + uses: actions/upload-artifact@v3 + with: + name: python-distribution + path: GrpcInterface/Python/dist + + - name: Upload Windows install artifact if: ${{contains( matrix.config.os, 'windows') }} uses: actions/upload-artifact@v3 with: name: ResInsight-${{ matrix.config.name }} path: ${{ runner.workspace }}/ResInsight/cmakebuild/install + + pypi-publish: + name: Upload release to PyPI + needs: build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/rips + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + + # If this is a tagged release + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + + steps: + - name: Download python distribution folder + uses: actions/download-artifact@v3 + with: + name: python-distribution + path: dist + + - name: Display structure of downloaded files + run: ls -R + + - name: Publish Python package to pypi + # https://docs.pypi.org/trusted-publishers/adding-a-publisher/ + uses: pypa/gh-action-pypi-publish@release/v1 + # uncomment the two lines below to publish to test PyPi + # with: + # repository-url: https://test.pypi.org/legacy/ + diff --git a/ApplicationLibCode/Adm/RiaVersionInfo.py.cmake b/ApplicationLibCode/Adm/RiaVersionInfo.py.cmake index 65841a4f1b..dbb3ea3a6e 100644 --- a/ApplicationLibCode/Adm/RiaVersionInfo.py.cmake +++ b/ApplicationLibCode/Adm/RiaVersionInfo.py.cmake @@ -19,3 +19,5 @@ RESINSIGHT_MAJOR_VERSION = "@RESINSIGHT_MAJOR_VERSION@" RESINSIGHT_MINOR_VERSION = "@RESINSIGHT_MINOR_VERSION@" RESINSIGHT_PATCH_VERSION = "@RESINSIGHT_PATCH_VERSION@" + +PYTHON_GRPC_PROTOC_VERSION = "@PYTHON_GRPC_PROTOC_VERSION@" \ No newline at end of file diff --git a/GrpcInterface/CMakeLists.txt b/GrpcInterface/CMakeLists.txt index 4e958c80a6..229172e770 100644 --- a/GrpcInterface/CMakeLists.txt +++ b/GrpcInterface/CMakeLists.txt @@ -77,7 +77,7 @@ if(Protobuf_FOUND) # Find gRPC installation Looks for gRPCConfig.cmake file installed by gRPC's # cmake installation. find_package(gRPC CONFIG REQUIRED) - message(STATUS "Using gRPC ${gRPC_VERSION}") + message(STATUS "Generate C++ code using grpc : ${gRPC_VERSION}") set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) set(_PROTOBUF_PROTOC $) @@ -144,6 +144,12 @@ add_custom_target(PipInstall) if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE) message(STATUS "Using Python Executable: ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}") + + execute_process(COMMAND "${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}" -m grpc_tools.protoc --version + OUTPUT_VARIABLE PYTHON_GRPC_PROTOC_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + + message(STATUS "Using Python grpc protoc compiler: ${PYTHON_GRPC_PROTOC_VERSION}") else() message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not install Python client code") endif() diff --git a/GrpcInterface/Python/setup.py.cmake b/GrpcInterface/Python/setup.py.cmake index 9f14dcab76..9e0db3466e 100644 --- a/GrpcInterface/Python/setup.py.cmake +++ b/GrpcInterface/Python/setup.py.cmake @@ -6,7 +6,7 @@ with open('README.md') as f: with open('LICENSE') as f: license = f.read() -RIPS_DIST_VERSION = '1' +RIPS_DIST_VERSION = '2' setup( name='rips', @@ -19,5 +19,5 @@ setup( license=license, packages=['rips'], package_data={'rips': ['*.py', 'generated/*.py', 'PythonExamples/*.py', 'tests/*.py']}, - install_requires=['grpcio>=1.20.0', 'protobuf', 'wheel'] + install_requires=['grpcio', 'protobuf', 'wheel'] ) \ No newline at end of file