From 43ddfeeb96085f57ff918ef69164ab9073c79e30 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Thu, 9 May 2024 23:38:34 -0700 Subject: [PATCH 1/6] Fix python module install destination We were installing python modules in the wrong locations (and double installing pyimath). * Get rid of the double install. * Make the one install go to the right destination: `/lib/pythonX.Y/site-packages` * With that in place, we can restore the EXPORT that makes the python module show up as a target in the exported cmake config. Signed-off-by: Larry Gritz --- src/python/PyImathNumpy/CMakeLists.txt | 8 ++++++-- src/python/config/ModuleDefine.cmake | 16 ++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/python/PyImathNumpy/CMakeLists.txt b/src/python/PyImathNumpy/CMakeLists.txt index 7b4f6b22..56f0804a 100644 --- a/src/python/PyImathNumpy/CMakeLists.txt +++ b/src/python/PyImathNumpy/CMakeLists.txt @@ -22,7 +22,9 @@ if(TARGET Python2::Python AND LIBRARY_OUTPUT_NAME "imathnumpy" DEBUG_POSTFIX "" ) - install(TARGETS imathnumpy_python2 DESTINATION ${PyImath_Python2_SITEARCH_REL}) + install(TARGETS imathnumpy_python2 + DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages" + ) endif() if(TARGET Python3::Python AND @@ -48,5 +50,7 @@ if(TARGET Python3::Python AND LIBRARY_OUTPUT_NAME "imathnumpy" DEBUG_POSTFIX "" ) - install(TARGETS imathnumpy_python3 DESTINATION ${PyImath_Python3_SITEARCH_REL}) + install(TARGETS imathnumpy_python3 + DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" + ) endif() diff --git a/src/python/config/ModuleDefine.cmake b/src/python/config/ModuleDefine.cmake index adee61c8..41cb7ea6 100644 --- a/src/python/config/ModuleDefine.cmake +++ b/src/python/config/ModuleDefine.cmake @@ -53,12 +53,6 @@ function(PYIMATH_ADD_LIBRARY_PRIV libname) ) add_library(${PROJECT_NAME}::${libname} ALIAS ${libname}) - - install(TARGETS ${libname} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - ) endfunction() # NB: This function has a number if specific names / variables @@ -130,7 +124,10 @@ function(PYIMATH_DEFINE_MODULE modname) LIBRARY_OUTPUT_NAME "${modname}" DEBUG_POSTFIX "" ) - install(TARGETS ${modname}_python2 DESTINATION ${PyImath_Python2_SITEARCH_REL}) + install(TARGETS ${modname}_python2 + EXPORT ${PROJECT_NAME} + DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages" + ) endif() else() if(TARGET Python3::Python) @@ -157,7 +154,10 @@ function(PYIMATH_DEFINE_MODULE modname) LIBRARY_OUTPUT_NAME "${modname}" DEBUG_POSTFIX "" ) - install(TARGETS ${modname}_python3 DESTINATION ${PyImath_Python3_SITEARCH_REL}) + install(TARGETS ${modname}_python3 + EXPORT ${PROJECT_NAME} + DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" + ) endif() endif() endfunction() From 61f14162d81e896c133198b87dad0f619f4de569 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Fri, 10 May 2024 21:00:48 -0700 Subject: [PATCH 2/6] Fix destination, should have gone under lib, not bin Signed-off-by: Larry Gritz --- src/python/PyImathNumpy/CMakeLists.txt | 4 ++-- src/python/config/ModuleDefine.cmake | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/python/PyImathNumpy/CMakeLists.txt b/src/python/PyImathNumpy/CMakeLists.txt index 56f0804a..9871a172 100644 --- a/src/python/PyImathNumpy/CMakeLists.txt +++ b/src/python/PyImathNumpy/CMakeLists.txt @@ -23,7 +23,7 @@ if(TARGET Python2::Python AND DEBUG_POSTFIX "" ) install(TARGETS imathnumpy_python2 - DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages" ) endif() @@ -51,6 +51,6 @@ if(TARGET Python3::Python AND DEBUG_POSTFIX "" ) install(TARGETS imathnumpy_python3 - DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" ) endif() diff --git a/src/python/config/ModuleDefine.cmake b/src/python/config/ModuleDefine.cmake index 41cb7ea6..1039f919 100644 --- a/src/python/config/ModuleDefine.cmake +++ b/src/python/config/ModuleDefine.cmake @@ -126,7 +126,7 @@ function(PYIMATH_DEFINE_MODULE modname) ) install(TARGETS ${modname}_python2 EXPORT ${PROJECT_NAME} - DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages" ) endif() else() @@ -156,7 +156,7 @@ function(PYIMATH_DEFINE_MODULE modname) ) install(TARGETS ${modname}_python3 EXPORT ${PROJECT_NAME} - DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" ) endif() endif() From 34818e102704107955b34d0491e89832c65c2e67 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sat, 11 May 2024 16:08:42 -0700 Subject: [PATCH 3/6] Put python module under Imath subdirectory Signed-off-by: Larry Gritz --- src/python/PyImathNumpy/CMakeLists.txt | 4 ++-- src/python/config/ModuleDefine.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/PyImathNumpy/CMakeLists.txt b/src/python/PyImathNumpy/CMakeLists.txt index 9871a172..f1fb9e57 100644 --- a/src/python/PyImathNumpy/CMakeLists.txt +++ b/src/python/PyImathNumpy/CMakeLists.txt @@ -23,7 +23,7 @@ if(TARGET Python2::Python AND DEBUG_POSTFIX "" ) install(TARGETS imathnumpy_python2 - DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages/Imath" ) endif() @@ -51,6 +51,6 @@ if(TARGET Python3::Python AND DEBUG_POSTFIX "" ) install(TARGETS imathnumpy_python3 - DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/Imath" ) endif() diff --git a/src/python/config/ModuleDefine.cmake b/src/python/config/ModuleDefine.cmake index 1039f919..9a6ecd47 100644 --- a/src/python/config/ModuleDefine.cmake +++ b/src/python/config/ModuleDefine.cmake @@ -156,7 +156,7 @@ function(PYIMATH_DEFINE_MODULE modname) ) install(TARGETS ${modname}_python3 EXPORT ${PROJECT_NAME} - DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/Imath" ) endif() endif() From e5540f3ad293a119f05727698438c768796b243e Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 12 May 2024 09:17:21 -0700 Subject: [PATCH 4/6] Try to use python for mac and windows also Signed-off-by: Larry Gritz --- .github/workflows/ci_workflow.yml | 49 +++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci_workflow.yml b/.github/workflows/ci_workflow.yml index 6bb2c7f5..2c4f5232 100644 --- a/.github/workflows/ci_workflow.yml +++ b/.github/workflows/ci_workflow.yml @@ -220,7 +220,7 @@ jobs: - name: Examples run: | # Confirm the python module loads. Query the site-packages directory and substitute ../_install - export PYTHONPATH=`python -c "import site; print('../_install%s' % site.USER_SITE[len(site.USER_BASE):])"` + export PYTHONPATH=`python -c "import site; print('../_install%s' % site.USER_SITE[len(site.USER_BASE):])"` python -c "import imath;print(imath.__version__)" # Make sure we can build the tests when configured as a # standalone application linking against the just-installed @@ -258,9 +258,10 @@ jobs: # macOS # --------------------------------------------------------------------------- - macos_no_python: + macos: name: 'macOS VFXP-${{matrix.vfx-cy }} macos-${{ matrix.osver }} ' + cxx=${{ matrix.cxx-standard }}>' runs-on: windows-${{ matrix.osver }} strategy: matrix: @@ -417,6 +426,8 @@ jobs: vfx-cy: 2023 exclude-tests: osver: 2022 + python: 'ON' + python-desc: '' # C++17, Debug - ## - build: 2 @@ -434,6 +445,8 @@ jobs: vfx-cy: 2023 exclude-tests: osver: 2022 + python: 'ON' + python-desc: '' # ------------------------------------------------------------------- # VFX CY2022 - C++17 - Windows 2019 @@ -447,6 +460,8 @@ jobs: vfx-cy: 2022 exclude-tests: osver: 2019 + python: 'ON' + python-desc: '' # C++17, Debug - ## - build: 5 @@ -464,6 +479,8 @@ jobs: vfx-cy: 2022 exclude-tests: osver: 2019 + python: 'ON' + python-desc: '' # ------------------------------------------------------------------- # VFX CY2020 - C++14 - Windows 2019 @@ -477,6 +494,8 @@ jobs: vfx-cy: 2020 exclude-tests: osver: 2019 + python: 'ON' + python-desc: '' # ------------------------------------------------------------------- # VFX CY2019 - C++11 - Windows 2019 @@ -489,6 +508,8 @@ jobs: cxx-standard: 11 exclude-tests: osver: 2019 + python: 'ON' + python-desc: '' steps: # - name: Setup Python @@ -502,8 +523,9 @@ jobs: mkdir _install mkdir _build shell: bash - # - name: Install Dependences - # run: | + - name: Install Dependencies + run: | + time vcpkg install boost-thread:x64-windows # share/ci/scripts/windows/install_python.ps1 ${{ matrix.python-version }} $HOME # share/ci/scripts/windows/install_boost.ps1 ${{ matrix.boost-version }} $HOME 3.8 # shell: powershell @@ -515,7 +537,8 @@ jobs: -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} \ -DCMAKE_CXX_FLAGS=${{ matrix.cxx-flags }} \ -DCMAKE_VERBOSE_MAKEFILE:BOOL='OFF' \ - -DBUILD_SHARED_LIBS=${{ matrix.build-shared }} + -DBUILD_SHARED_LIBS=${{ matrix.build-shared }} \ + -DPYTHON=${{ matrix.python }} # NB: removed trailing slash from these lines # -DBOOST_ROOT:FILEPATH=$BOOST_ROOT # -DPYTHON='ON' From 84bace326cb9f57b9a9de6dc5d9812972fef4ed5 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 12 May 2024 14:32:58 -0700 Subject: [PATCH 5/6] Roll our own PYTHONPATH Signed-off-by: Larry Gritz --- .github/workflows/ci_workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci_workflow.yml b/.github/workflows/ci_workflow.yml index 2c4f5232..91767a45 100644 --- a/.github/workflows/ci_workflow.yml +++ b/.github/workflows/ci_workflow.yml @@ -221,6 +221,7 @@ jobs: run: | # Confirm the python module loads. Query the site-packages directory and substitute ../_install export PYTHONPATH=`python -c "import site; print('../_install%s' % site.USER_SITE[len(site.USER_BASE):])"` + export PYTHONPATH=$PYTHONPATH:$PWD/../_install/lib/python*/site-packages python -c "import imath;print(imath.__version__)" # Make sure we can build the tests when configured as a # standalone application linking against the just-installed From 5de54cf4cef6e33851a42a0753825c00a6d8e3dd Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 12 May 2024 14:34:40 -0700 Subject: [PATCH 6/6] Install boost-python via brew Signed-off-by: Larry Gritz --- .github/workflows/ci_workflow.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_workflow.yml b/.github/workflows/ci_workflow.yml index 91767a45..37e14e3f 100644 --- a/.github/workflows/ci_workflow.yml +++ b/.github/workflows/ci_workflow.yml @@ -221,7 +221,8 @@ jobs: run: | # Confirm the python module loads. Query the site-packages directory and substitute ../_install export PYTHONPATH=`python -c "import site; print('../_install%s' % site.USER_SITE[len(site.USER_BASE):])"` - export PYTHONPATH=$PYTHONPATH:$PWD/../_install/lib/python*/site-packages + export PYTHONPATH=$PYTHONPATH:$PWD/../_install/lib*/python*/site-packages + echo $PYTHONPATH python -c "import imath;print(imath.__version__)" # Make sure we can build the tests when configured as a # standalone application linking against the just-installed @@ -345,7 +346,8 @@ jobs: mkdir _examples - name: Install Dependences run: | - brew --display-times -q install python + brew list --version + brew install --display-times -q boost-python3 ## share/ci/scripts/macos/install_boost.sh ## shell: bash - name: Configure @@ -370,6 +372,8 @@ jobs: run: | # Confirm the python module loads. Query the site-packages directory and substitute ../_install export PYTHONPATH=`python -c "import site; print('../_install%s' % site.USER_SITE[len(site.USER_BASE):])"` + export PYTHONPATH=$PYTHONPATH:$PWD/../_install/lib/python*/site-packages + echo $PYTHONPATH python -c "import imath;print(imath.__version__)" # Make sure we can build the tests when configured as a # standalone application linking against the just-installed @@ -526,7 +530,7 @@ jobs: shell: bash - name: Install Dependencies run: | - time vcpkg install boost-thread:x64-windows + vcpkg install boost-python:x64-windows # share/ci/scripts/windows/install_python.ps1 ${{ matrix.python-version }} $HOME # share/ci/scripts/windows/install_boost.ps1 ${{ matrix.boost-version }} $HOME 3.8 # shell: powershell