From d7f7e421ec81bcaf2aa37497e1e9d6532281d83d Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 6 Nov 2024 10:51:30 +0100 Subject: [PATCH 1/8] Bump python bindings action: add windows py313, bump macos to 12 (will be removed in december) and use ubuntu 22.04 --- .github/workflows/python_bindings.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python_bindings.yml b/.github/workflows/python_bindings.yml index df0db1f9846..f6f372c9f1c 100644 --- a/.github/workflows/python_bindings.yml +++ b/.github/workflows/python_bindings.yml @@ -27,11 +27,11 @@ jobs: name: [Ubuntu, macOS, macOS_arm64, Windows_py37, Windows_py38, Windows_py39, Windows_py310, Windows_py311, Windows_py312] include: - name: Ubuntu - os: ubuntu-20.04 + os: ubuntu-22.04 python-version: 3.8 allow_failure: false - name: macOS - os: macos-11 + os: macos-12 python-version: 3.8 allow_failure: false MACOSX_DEPLOYMENT_TARGET: 10.15 @@ -41,7 +41,7 @@ jobs: python-version: 3.8 allow_failure: false MACOSX_DEPLOYMENT_TARGET: 12.1 - SDKROOT: /Applications/Xcode_14.3.1.app + SDKROOT: /Applications/Xcode_15.2.app - name: Windows_py37 os: windows-2019 python-version: 3.7 @@ -66,6 +66,11 @@ jobs: os: windows-2019 python-version: '3.12' allow_failure: true # Possible this fails, don't care yet + - name: Windows_py313 + os: windows-2019 + python-version: '3.13' + allow_failure: true # Possible this fails, don't care yet + steps: - uses: actions/checkout@v4 # with: @@ -265,7 +270,7 @@ jobs: begin_group "Conan install" if [ "$RUNNER_OS" == "macOS" ]; then # Avoid "builtin __has_nothrow_assign is deprecated; use __is_nothrow_assignable instead" in boost/1.79 with recent clang - conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']" + conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -Wno-enum-constexpr-conversion']" else conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False fi From 2b8be92042b08d62240aa4405a7cb52562c0d9ec Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 6 Nov 2024 11:04:23 +0100 Subject: [PATCH 2/8] my forked setup-python doesn't work for windows py313 because it's not in the image cache also -Wno-enum-constexpr-conversion isn't understand on older apple clang --- .github/workflows/python_bindings.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python_bindings.yml b/.github/workflows/python_bindings.yml index f6f372c9f1c..716202cd8d3 100644 --- a/.github/workflows/python_bindings.yml +++ b/.github/workflows/python_bindings.yml @@ -65,7 +65,7 @@ jobs: - name: Windows_py312 os: windows-2019 python-version: '3.12' - allow_failure: true # Possible this fails, don't care yet + allow_failure: false - name: Windows_py313 os: windows-2019 python-version: '3.13' @@ -77,12 +77,20 @@ jobs: # ref: develop - name: Set up Python ${{ matrix.python-version }} + if: runner.os == 'macOS' id: setup-python # 3.10 is the first one to have a prebuilt binary for macos-14 (arm64) on the actions/setup-python, so I forked it and actions/python-versions to add 3.8 uses: jmarrec/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} + if: runner.os != 'macOS' + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install System dependencies shell: bash run: | @@ -269,8 +277,12 @@ jobs: begin_group "Conan install" if [ "$RUNNER_OS" == "macOS" ]; then + if [ "${{ matrix.name }}" == "macOS_arm64" ]; then # Avoid "builtin __has_nothrow_assign is deprecated; use __is_nothrow_assignable instead" in boost/1.79 with recent clang - conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -Wno-enum-constexpr-conversion']" + conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -Wno-enum-constexpr-conversion']" + else + conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']" + fi else conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False fi From b31e02cdb40ac2e33da0baeb723667f2c215db44 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 6 Nov 2024 11:09:56 +0100 Subject: [PATCH 3/8] Try with a ternary like operator I'm referencing the id of that step... https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#example --- .github/workflows/python_bindings.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/python_bindings.yml b/.github/workflows/python_bindings.yml index 716202cd8d3..ebef2855ad4 100644 --- a/.github/workflows/python_bindings.yml +++ b/.github/workflows/python_bindings.yml @@ -80,14 +80,7 @@ jobs: if: runner.os == 'macOS' id: setup-python # 3.10 is the first one to have a prebuilt binary for macos-14 (arm64) on the actions/setup-python, so I forked it and actions/python-versions to add 3.8 - uses: jmarrec/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Set up Python ${{ matrix.python-version }} - if: runner.os != 'macOS' - id: setup-python - uses: actions/setup-python@v5 + uses: ${{ runner.os == 'macOS' && 'jmarrec/setup-python@v5' || 'actions/setup-python@v5' }} with: python-version: ${{ matrix.python-version }} From 0e3cc37f73918d754607f4b6fcda18eb4c7a8661 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 6 Nov 2024 11:13:51 +0100 Subject: [PATCH 4/8] Use a different step id --- .github/workflows/python_bindings.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python_bindings.yml b/.github/workflows/python_bindings.yml index ebef2855ad4..1519c537d4f 100644 --- a/.github/workflows/python_bindings.yml +++ b/.github/workflows/python_bindings.yml @@ -78,9 +78,16 @@ jobs: - name: Set up Python ${{ matrix.python-version }} if: runner.os == 'macOS' - id: setup-python + id: setup-python-macos # 3.10 is the first one to have a prebuilt binary for macos-14 (arm64) on the actions/setup-python, so I forked it and actions/python-versions to add 3.8 - uses: ${{ runner.os == 'macOS' && 'jmarrec/setup-python@v5' || 'actions/setup-python@v5' }} + uses: jmarrec/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up Python ${{ matrix.python-version }} + if: runner.os != 'macOS' + id: setup-python + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -269,14 +276,18 @@ jobs: set -x begin_group "Conan install" + PYTHON_ARCH=x64 if [ "$RUNNER_OS" == "macOS" ]; then + PYTHON_VERSION=${{ steps.setup-python-macos.outputs.python-version }} if [ "${{ matrix.name }}" == "macOS_arm64" ]; then - # Avoid "builtin __has_nothrow_assign is deprecated; use __is_nothrow_assignable instead" in boost/1.79 with recent clang + PYTHON_ARCH=arm64 + # Avoid "builtin __has_nothrow_assign is deprecated; use __is_nothrow_assignable instead" in boost/1.79 with recent clang conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -Wno-enum-constexpr-conversion']" else conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']" fi else + PYTHON_VERSION=${{ steps.setup-python.outputs.python-version }} conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -o with_testing=False -o with_benchmark=False fi echo -e "::endgroup::" @@ -284,8 +295,8 @@ jobs: begin_group "CMake Configure" cmake --preset conan-release \ -DBUILD_PYTHON_BINDINGS:BOOL=ON -DBUILD_PYTHON_PIP_PACKAGE:BOOL=ON -DPYTHON_PIP_REPOSITORY:STRING=${{ env.PYTHON_PIP_REPOSITORY }} \ - -DPYTHON_VERSION:STRING=${{ steps.setup-python.outputs.python-version }} \ - -DPython_ROOT_DIR:PATH=$RUNNER_TOOL_CACHE/Python/${{ steps.setup-python.outputs.python-version }}/x64/ \ + -DPYTHON_VERSION:STRING=$PYTHON_VERSION \ + -DPython_ROOT_DIR:PATH=$RUNNER_TOOL_CACHE/Python/$PYTHON_VERSION/$PYTHON_ARCH/ \ -DBUILD_TESTING:BOOL=OFF -DBUILD_RUBY_BINDINGS:BOOL=${{ env.BUILD_RUBY_BINDINGS }} -DBUILD_CLI:BOOL=${{ env.BUILD_CLI }} echo -e "::endgroup::" From f2ce25b602fdae7dc65fe127f12783be06509eed Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 6 Nov 2024 12:19:56 +0100 Subject: [PATCH 5/8] use os.add_dll_directory for windows when using the **installed** Python/ folder with system python https://docs.python.org/3/library/os.html#os.add_dll_directory --- python/module/openstudio.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/module/openstudio.py b/python/module/openstudio.py index 70b72eadb51..62e8260b440 100644 --- a/python/module/openstudio.py +++ b/python/module/openstudio.py @@ -45,6 +45,12 @@ from .openstudioutilitiesxml import * else: + import os + if os.name == 'nt': + # When we're using system python to load the **installed** C:\openstudio-X.Y-Z\Python stuff (not PyPi package) + # This allows finding openstudiolib.dll and the msvc ones in the bin/ folder while we're in the Python/ folder + # Otherwise you'd have to manually copy these DLLs from bin/ to Python/ + os.add_dll_directory(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'bin'))) import openstudioairflow as airflow import openstudioenergyplus as energyplus import openstudioepjson as epjson From ad5f5505d4d671c39dc51375f0ca1aef8cf302ec Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 7 Nov 2024 09:23:14 +0100 Subject: [PATCH 6/8] Py_SetPath removed from Python 3.13. We should upgrade to use PyConfig, but too late in the release cycle --- python/engine/PythonEngine.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python/engine/PythonEngine.cpp b/python/engine/PythonEngine.cpp index 97e12250ba4..a9b95140111 100644 --- a/python/engine/PythonEngine.cpp +++ b/python/engine/PythonEngine.cpp @@ -25,6 +25,17 @@ # pragma GCC diagnostic pop #endif +// >= 3.13.0 +// #if PY_VERSION_HEX >= 0x30d0000 +#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 12) +extern "C" +{ + // These functions was removed from Python 3.13 API but are still exported + // for the stable ABI. Until we upgrade to PyConfig, just keep using it + extern void Py_SetPath(const wchar_t* path); +} +#endif + namespace openstudio { void addToPythonPath(const openstudio::path& includePath) { From 76e2246d56d277f60ca75da5a570a6b401239edd Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 7 Nov 2024 12:07:55 +0100 Subject: [PATCH 7/8] Why is testpypi upload failing? Try with --verbose --- .github/workflows/python_bindings.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python_bindings.yml b/.github/workflows/python_bindings.yml index 1519c537d4f..368fab0d8b2 100644 --- a/.github/workflows/python_bindings.yml +++ b/.github/workflows/python_bindings.yml @@ -372,7 +372,7 @@ jobs: done; ls -R - python -m twine upload --skip-existing --repository testpypi dist/* + python -m twine upload --verbose --skip-existing --repository testpypi dist/* test_python_bindings: @@ -499,4 +499,4 @@ jobs: done; ls -R - python -m twine upload --skip-existing --repository pypi dist/* + python -m twine upload --verbose --skip-existing --repository pypi dist/* From 49582994cecb5ef1231e047159e00d1672674a9a Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 13 Nov 2024 09:15:20 +0100 Subject: [PATCH 8/8] Drop support for python bindings on Ubuntu 20.04, update mac runner, add test for py313 --- .github/workflows/python_bindings.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python_bindings.yml b/.github/workflows/python_bindings.yml index 368fab0d8b2..1985167a973 100644 --- a/.github/workflows/python_bindings.yml +++ b/.github/workflows/python_bindings.yml @@ -24,7 +24,7 @@ jobs: # fail-fast: Default is true, switch to false to allow one platform to fail and still run others fail-fast: false matrix: - name: [Ubuntu, macOS, macOS_arm64, Windows_py37, Windows_py38, Windows_py39, Windows_py310, Windows_py311, Windows_py312] + name: [Ubuntu, macOS, macOS_arm64, Windows_py37, Windows_py38, Windows_py39, Windows_py310, Windows_py311, Windows_py312, Windows_py313] include: - name: Ubuntu os: ubuntu-22.04 @@ -330,7 +330,7 @@ jobs: upload_python_bindings_to_testpypi: needs: python_bindings name: Upload to TestPyPi - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Set up Python @@ -384,14 +384,14 @@ jobs: # fail-fast: Default is true, switch to false to allow one platform to fail and still run others fail-fast: false matrix: - name: [Ubuntu, macOS, macOS_arm64, Windows_py37, Windows_py38, Windows_py39, Windows_py310, Windows_py311, Windows_py312] + name: [Ubuntu, macOS, macOS_arm64, Windows_py37, Windows_py38, Windows_py39, Windows_py310, Windows_py311, Windows_py312, Windows_py313] include: - name: Ubuntu - os: ubuntu-20.04 + os: ubuntu-22.04 python-version: 3.11 # Voluntarily using a newer version than built with for Unix allow_failure: false - name: macOS - os: macos-11 + os: macos-12 python-version: 3.11 allow_failure: false - name: macOS_arm64 @@ -421,8 +421,11 @@ jobs: - name: Windows_py312 os: windows-2019 python-version: '3.12' + allow_failure: false + - name: Windows_py313 + os: windows-2019 + python-version: '3.13' allow_failure: true # Possible this fails, don't care yet - steps: - uses: actions/checkout@v4 @@ -459,7 +462,7 @@ jobs: if: contains(github.ref, 'refs/tags') needs: test_python_bindings name: Upload to PyPi - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Set up Python