diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fca627c9..9ebca027 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,13 +49,13 @@ jobs: build: runs-on: ${{ matrix.os }} - needs: [linting] +# needs: [linting] strategy: fail-fast: false max-parallel: 3 matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.10", 3.11, 3.12, 3.13, 3.14] + os: [windows-latest] + python-version: [3.11, 3.12, 3.13, 3.14] steps: - uses: actions/checkout@v2 @@ -67,9 +67,12 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Setup msbuild Windows - if: runner.os == 'Windows' - uses: microsoft/setup-msbuild@v1.0.2 + - name: Set up MSVC environment # for debug + uses: ilammy/msvc-dev-cmd@v1 + +# - name: Setup msbuild Windows +# if: runner.os == 'Windows' +# uses: microsoft/setup-msbuild@v1.0.2 - name: Fix Paths Windows # Make sure that tar.exe from Git is used not from Windows @@ -87,14 +90,16 @@ jobs: if: runner.os == 'Windows' timeout-minutes: 20 run: | - $PYTHONHOME=$(python -c 'import sys; print(sys.executable);').replace('\', '/') - $PYTHONPATH=$(python -c "import sys; print([x for x in sys.path if 'site-packages' in x][0]);").replace('\', '/') - echo "PYTHONHOME=$PYTHONHOME" - echo "PYTHONPATH=$PYTHONPATH" - echo "Running: ${{ matrix.os }}" - bazel.exe --output_base ./bazel-cache build src/python:pydp --config windows --verbose_failures --action_env=PYTHON_BIN_PATH=$PYTHONHOME --action_env=PYTHON_LIB_PATH=$PYTHONPATH - copy ./bazel-bin/src/bindings/_pydp.so ./src/pydp/_pydp.pyd + .\build_windows.cmd + - name: Archive build artifacts + # more details https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts + uses: actions/upload-artifact@v4 + with: + name: build-py${{ matrix.python-version }} + path: | + src + retention-days: 1 - name: Upgrade pip run: | pip install --upgrade --user pip diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 911bb235..c6364c6f 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -53,7 +53,7 @@ jobs: max-parallel: 12 matrix: # TODO: fix for Mac and Windows. - os: [ubuntu-latest, macos-latest] + os: []#ubuntu-latest, macos-latest] python-version: ["3.11", "3.12", "3.13", "3.14"] steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index c5895f7e..526c1e76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,24 @@ cmake_minimum_required(VERSION 3.16) project(PyDP LANGUAGES CXX) +# 1. Keep MSVC runtime Dynamic (Python standard) +# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + +# 2. Force third-party libraries to be built statically so they are baked into the wheel +# set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) +# 1. Globally tell CMake to prefer static libraries over shared DLLs +set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static libraries" FORCE) +set(OPENSSL_USE_STATIC_LIBS TRUE) + +# 2. Specifically override Protobuf/Abseil if they ignore BUILD_SHARED_LIBS +set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Build protobuf as static" FORCE) +set(protobuf_MSVC_STATIC_RUNTIME ON CACHE BOOL "Use /MT for protobuf" FORCE) + +set(ABSL_MSVC_STATIC_RUNTIME ON CACHE BOOL "Force Abseil to use /MT" FORCE) +set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE) +#set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static libraries" FORCE) + # C++ Standard set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/build_windows.cmd b/build_windows.cmd new file mode 100644 index 00000000..76fab32a --- /dev/null +++ b/build_windows.cmd @@ -0,0 +1,19 @@ +@REM git clone https://github.com/Delphier/dumpbin.git +@REM echo Y| python dumpbin/dumpbin.py +@REM dumpbin.exe /exports *.dll + +mkdir build_dir +cd build_dir +cmake -S .. -B . -DOPENSSL_ROOT_DIR="C:\Program Files\OpenSSL" +cmake --build . --parallel --config Release + +move "src\bindings\PyDP\Release\_pydp.*-win_amd64.pyd" "..\src\pydp\" +cd ..\src\pydp\ +ren "_pydp.*-win_amd64.pyd" "_pydp.pyd" +dir "C:\Program Files\OpenSSL" +dir "C:\Program Files\OpenSSL\bin" +copy "C:\Program Files\OpenSSL\libcrypto*.dll" . +dumpbin.exe /dependents "_pydp.pyd" +dumpbin.exe /dependents "libcrypto-3-x64.dll" + +python -c "import _pydp" \ No newline at end of file