From 37d9190b261985d26eaf357347fbbf8356baa39f Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Sun, 9 Apr 2023 15:54:02 -0400 Subject: [PATCH 01/30] Use scikit-build-core to create a PyPI package (wheels + sdist) Signed-off-by: Jean-Christophe Morin --- .gitignore | 1 + CMakeLists.txt | 55 +++++++------ libraries/CMakeLists.txt | 4 +- pyproject.toml | 78 +++++++++++++++++++ python/CMakeLists.txt | 25 +++--- python/MaterialX/_scripts/README.md | 2 + python/MaterialX/_scripts/__init__.py | 1 + resources/CMakeLists.txt | 6 +- source/MaterialXCore/CMakeLists.txt | 24 +++--- source/MaterialXFormat/CMakeLists.txt | 26 ++++--- source/MaterialXGenGlsl/CMakeLists.txt | 26 ++++--- source/MaterialXGenMdl/CMakeLists.txt | 32 ++++---- source/MaterialXGenMsl/CMakeLists.txt | 26 ++++--- source/MaterialXGenOsl/CMakeLists.txt | 27 +++---- source/MaterialXGenShader/CMakeLists.txt | 32 ++++---- source/MaterialXRender/CMakeLists.txt | 26 ++++--- source/MaterialXRenderGlsl/CMakeLists.txt | 22 +++--- source/MaterialXRenderHw/CMakeLists.txt | 22 +++--- source/MaterialXRenderMsl/CMakeLists.txt | 22 +++--- source/MaterialXRenderOsl/CMakeLists.txt | 26 ++++--- source/MaterialXTest/CMakeLists.txt | 1 + .../PyMaterialXCore/CMakeLists.txt | 5 +- .../PyMaterialXFormat/CMakeLists.txt | 4 +- .../PyMaterialXGenGlsl/CMakeLists.txt | 4 +- .../PyMaterialXGenMdl/CMakeLists.txt | 4 +- .../PyMaterialXGenMsl/CMakeLists.txt | 4 +- .../PyMaterialXGenOsl/CMakeLists.txt | 4 +- .../PyMaterialXGenShader/CMakeLists.txt | 4 +- .../PyMaterialXRender/CMakeLists.txt | 4 +- .../PyMaterialXRenderGlsl/CMakeLists.txt | 4 +- .../PyMaterialXRenderMsl/CMakeLists.txt | 4 +- .../PyMaterialXRenderOsl/CMakeLists.txt | 4 +- 32 files changed, 316 insertions(+), 213 deletions(-) create mode 100644 pyproject.toml create mode 100644 python/MaterialX/_scripts/README.md create mode 100644 python/MaterialX/_scripts/__init__.py diff --git a/.gitignore b/.gitignore index 378eac25d3..76af3d4ab7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build +/dist diff --git a/CMakeLists.txt b/CMakeLists.txt index 86872f26de..048ec51650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,13 @@ set(MATERIALX_OSL_BINARY_OSLC "" CACHE FILEPATH "Full path to the OSL compiler b set(MATERIALX_OSL_BINARY_TESTRENDER "" CACHE FILEPATH "Full path to the OSL test render binary.") set(MATERIALX_OSL_INCLUDE_PATH "" CACHE PATH "Full path to OSL shader includes (e.g. 'stdosl.h').") +set(MATERIALX_PYTHON_FOLDER_NAME "python/MaterialX" CACHE INTERNAL "Folder name to user for installing the Python library.") + +if(SKBUILD) + set(MATERIALX_INSTALL_STDLIB_PATH "${SKBUILD_PLATLIB_DIR}/MaterialX/libraries") + set(MATERIALX_PYTHON_FOLDER_NAME "MaterialX") +endif() + # Helpers for MDL validation if (MATERIALX_BUILD_GEN_MDL) set(MATERIALX_MDLC_EXECUTABLE "" CACHE FILEPATH "Full path to the mdlc binary.") @@ -309,26 +316,28 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.6.2") endif() # Install root-level documents -install(FILES LICENSE CHANGELOG.md README.md THIRD-PARTY.md - DESTINATION .) - -set(MATERIALX_GEN_CONFIG_PATH "${MATERIALX_INSTALL_LIB_PATH}/cmake/${CMAKE_PROJECT_NAME}") - -include(CMakePackageConfigHelpers) -configure_package_config_file(cmake/modules/MaterialXConfig.cmake.in - ${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}Config.cmake - INSTALL_DESTINATION "${MATERIALX_GEN_CONFIG_PATH}" - PATH_VARS CMAKE_INSTALL_PREFIX CMAKE_PROJECT_NAME) -write_basic_package_version_file(${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake - VERSION ${MATERIALX_LIBRARY_VERSION} - COMPATIBILITY AnyNewerVersion) - -# Install the auto-generated CMake configuration files: - -install(EXPORT MaterialX - DESTINATION "${MATERIALX_GEN_CONFIG_PATH}" - FILE ${CMAKE_PROJECT_NAME}Targets.cmake) - -install(FILES "${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" - "${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}Config.cmake" - DESTINATION "${MATERIALX_GEN_CONFIG_PATH}") +if(NOT SKBUILD) + install(FILES LICENSE CHANGELOG.md README.md THIRD-PARTY.md + DESTINATION .) + + set(MATERIALX_GEN_CONFIG_PATH "${MATERIALX_INSTALL_LIB_PATH}/cmake/${CMAKE_PROJECT_NAME}") + + include(CMakePackageConfigHelpers) + configure_package_config_file(cmake/modules/MaterialXConfig.cmake.in + ${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}Config.cmake + INSTALL_DESTINATION "${MATERIALX_GEN_CONFIG_PATH}" + PATH_VARS CMAKE_INSTALL_PREFIX CMAKE_PROJECT_NAME) + write_basic_package_version_file(${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake + VERSION ${MATERIALX_LIBRARY_VERSION} + COMPATIBILITY AnyNewerVersion) + + # Install the auto-generated CMake configuration files: + + install(EXPORT MaterialX + DESTINATION "${MATERIALX_GEN_CONFIG_PATH}" + FILE ${CMAKE_PROJECT_NAME}Targets.cmake) + + install(FILES "${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" + "${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}Config.cmake" + DESTINATION "${MATERIALX_GEN_CONFIG_PATH}") +endif() diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 0d47cad5ed..eb30eb20f4 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -13,8 +13,8 @@ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PB DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION "python/MaterialX/${MATERIALX_INSTALL_STDLIB_PATH}" + DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}" PATTERN "CMakeLists.txt" EXCLUDE PATTERN "pbrlib_genosl_impl.*" EXCLUDE) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PBRLIB_SUFFIX}" - DESTINATION "python/MaterialX/${MATERIALX_INSTALL_STDLIB_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx) + DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..c0e279870c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,78 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "MaterialX" +version = "0.0.0.dev1" # TODO: Change version +authors = [ + { name="Contributors to the MaterialX project", email="materialx-discussion@lists.aswf.io" }, +] +readme = "README.md" + +# TODO: Should it also support Python 2? +requires-python = ">=3.7" + +# OCIO is not required. But if you want to eventually add it, +# uncomment this, bundle the OCIO config and python/MaterialX/colorspace.py +# will just work. +# dependencies = [ +# "opencolorio" +# ] + +# TODO: Add more classifier. +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://materialx.org" +"Source" = "https://github.com/AcademySoftwareFoundation/MaterialX" +"Bug Tracker" = "https://github.com/AcademySoftwareFoundation/MaterialX/issues" + +[project.scripts] +baketextures = "MaterialX._scripts.baketextures:main" +generateshader = "MaterialX._scripts.generateshader:main" +genmdl = "MaterialX._scripts.genmdl:main" +mxdoc = "MaterialX._scripts.mxdoc:main" +mxupdate = "MaterialX._scripts.mxupdate:main" +mxvalidate = "MaterialX._scripts.mxvalidate:main" +translateshader = "MaterialX._scripts.translateshader:main" +writenodegraphs = "MaterialX._scripts.writenodegraphs:main" + +[tool.scikit-build] +cmake.minimum-version = "3.18" +cmake.verbose = false +cmake.build-type = "Release" + +# Uncoment when developing locally to enable inplace builds. +# build-dir = "build/" + +logging.level = "INFO" + +# Since the python package doesn't live in a standard directory +# in the source (i.e ./src or ./), we need to manually specify +# where the package is. +wheel.packages = ["python/MaterialX"] + +sdist.exclude = [ + "/build", + "/dist", + "/resources", + "/javascript", + "/documents", + "/.github", + "MANIFEST.in" + +] + +[tool.scikit-build.cmake.define] +MATERIALX_BUILD_SHARED_LIBS = 'OFF' # Be explicit +MATERIALX_BUILD_PYTHON = 'ON' +MATERIALX_TEST_RENDER = 'OFF' +MATERIALX_WARNINGS_AS_ERRORS = 'ON' + +# TODO: How could we harmonize this variable with SKBUILD? +MATERIALX_INSTALL_PYTHON = 'OFF' diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e036c5abd5..da35a38b72 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,18 +1,25 @@ -set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in") -set(SETUP_PY "${CMAKE_INSTALL_PREFIX}/python/setup.py") - -configure_file(${SETUP_PY_IN} ${SETUP_PY}) +if(NOT SKBUILD) + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/MaterialX" DESTINATION "python" MESSAGE_NEVER) + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Scripts" DESTINATION "python" MESSAGE_NEVER) +endif() -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/MaterialX" DESTINATION "python" MESSAGE_NEVER) -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Scripts" DESTINATION "python" MESSAGE_NEVER) +if(SKBUILD) + install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Scripts/" + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}/_scripts" + PATTERN "README.md" EXCLUDE + ) +endif() if(MATERIALX_PYTHON_OCIO_DIR) if(NOT EXISTS "${MATERIALX_PYTHON_OCIO_DIR}/config.ocio") message(WARNING "No file named config.ocio was found in the given OCIO directory.") endif() - install(DIRECTORY "${MATERIALX_PYTHON_OCIO_DIR}/" DESTINATION "python/MaterialX/config/" MESSAGE_NEVER) + install(DIRECTORY "${MATERIALX_PYTHON_OCIO_DIR}/" DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}/config/" MESSAGE_NEVER) endif() -if(MATERIALX_INSTALL_PYTHON AND PYTHON_EXECUTABLE) - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install clean --all)" MESSAGE_NEVER) +if(MATERIALX_INSTALL_PYTHON AND PYTHON_EXECUTABLE AND NOT SKBUILD) + set(SETUP_PY "${CMAKE_INSTALL_PREFIX}/python/setup.py") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in" "${SETUP_PY}") + install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install clean --all)") endif() diff --git a/python/MaterialX/_scripts/README.md b/python/MaterialX/_scripts/README.md new file mode 100644 index 0000000000..f3586c5133 --- /dev/null +++ b/python/MaterialX/_scripts/README.md @@ -0,0 +1,2 @@ +This directory is empty buit it's used when packaging the Python library. +the files in ../../Scripts will be copied inside. diff --git a/python/MaterialX/_scripts/__init__.py b/python/MaterialX/_scripts/__init__.py new file mode 100644 index 0000000000..1217aefc79 --- /dev/null +++ b/python/MaterialX/_scripts/__init__.py @@ -0,0 +1 @@ +# Only required for entry-points. diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 5c1a433cf9..10212c95c2 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -1,2 +1,4 @@ -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION "resources" MESSAGE_NEVER) +if(NOT SKBUILD) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION "resources" MESSAGE_NEVER) +endif() diff --git a/source/MaterialXCore/CMakeLists.txt b/source/MaterialXCore/CMakeLists.txt index 37edf7929a..340033ad51 100644 --- a/source/MaterialXCore/CMakeLists.txt +++ b/source/MaterialXCore/CMakeLists.txt @@ -27,14 +27,16 @@ target_include_directories(MaterialXCore PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXCore - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) - -install(FILES ${materialx_headers} - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXCore/) - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXCore.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +if(NOT SKBUILD) + install(TARGETS MaterialXCore + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) + + install(FILES ${materialx_headers} + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXCore/) + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXCore.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXFormat/CMakeLists.txt b/source/MaterialXFormat/CMakeLists.txt index 940ef9662c..79dc229ebc 100644 --- a/source/MaterialXFormat/CMakeLists.txt +++ b/source/MaterialXFormat/CMakeLists.txt @@ -29,15 +29,17 @@ target_include_directories(MaterialXFormat PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXFormat - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXFormat/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXFormat.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +if(NOT SKBUILD) + install(TARGETS MaterialXFormat + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) + + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXFormat/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXFormat.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXGenGlsl/CMakeLists.txt b/source/MaterialXGenGlsl/CMakeLists.txt index 2ddcb5475c..85527bd3a9 100644 --- a/source/MaterialXGenGlsl/CMakeLists.txt +++ b/source/MaterialXGenGlsl/CMakeLists.txt @@ -30,15 +30,17 @@ target_include_directories(MaterialXGenGlsl PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXGenGlsl - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenGlsl/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenGlsl.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +if(NOT SKBUILD) + install(TARGETS MaterialXGenGlsl + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) + + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenGlsl/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenGlsl.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXGenMdl/CMakeLists.txt b/source/MaterialXGenMdl/CMakeLists.txt index b73e674b7f..b835c8dca6 100644 --- a/source/MaterialXGenMdl/CMakeLists.txt +++ b/source/MaterialXGenMdl/CMakeLists.txt @@ -30,18 +30,20 @@ target_include_directories(MaterialXGenMdl PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXGenMdl - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenMdl/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") - -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mdl - DESTINATION "${MATERIALX_INSTALL_MDL_MODULE_PATH}") - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenMdl.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +if(NOT SKBUILD) + install(TARGETS MaterialXGenMdl + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) + + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenMdl/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") + + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mdl + DESTINATION "${MATERIALX_INSTALL_MDL_MODULE_PATH}") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenMdl.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXGenMsl/CMakeLists.txt b/source/MaterialXGenMsl/CMakeLists.txt index 31d2599531..c65a097924 100644 --- a/source/MaterialXGenMsl/CMakeLists.txt +++ b/source/MaterialXGenMsl/CMakeLists.txt @@ -30,15 +30,17 @@ target_include_directories(MaterialXGenMsl PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXGenMsl - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenMsl/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenMsl.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +if(NOT SKBUILD) + install(TARGETS MaterialXGenMsl + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) + + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenMsl/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenMsl.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXGenOsl/CMakeLists.txt b/source/MaterialXGenOsl/CMakeLists.txt index 03e30de0c1..110fec8854 100644 --- a/source/MaterialXGenOsl/CMakeLists.txt +++ b/source/MaterialXGenOsl/CMakeLists.txt @@ -30,16 +30,17 @@ target_include_directories(MaterialXGenOsl PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXGenOsl - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenOsl/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenOsl.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) - +if(NOT SKBUILD) + install(TARGETS MaterialXGenOsl + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) + + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenOsl/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenOsl.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXGenShader/CMakeLists.txt b/source/MaterialXGenShader/CMakeLists.txt index 231dda6e5c..5bf9603886 100644 --- a/source/MaterialXGenShader/CMakeLists.txt +++ b/source/MaterialXGenShader/CMakeLists.txt @@ -30,18 +30,20 @@ target_include_directories(MaterialXGenShader PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXGenShader - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenShader/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenShader.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../resources" - DESTINATION . MESSAGE_NEVER) +if(NOT SKBUILD) + install(TARGETS MaterialXGenShader + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) + + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenShader/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenShader.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) + + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../resources" + DESTINATION . MESSAGE_NEVER) +endif() diff --git a/source/MaterialXRender/CMakeLists.txt b/source/MaterialXRender/CMakeLists.txt index d0a50232cd..277667f5bf 100644 --- a/source/MaterialXRender/CMakeLists.txt +++ b/source/MaterialXRender/CMakeLists.txt @@ -52,17 +52,19 @@ set_target_properties( VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}") -install(TARGETS MaterialXRender - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) +if(NOT SKBUILD) + install(TARGETS MaterialXRender + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRender/ MESSAGE_NEVER - FILES_MATCHING - PATTERN "*.h*" - PATTERN "*.inl") + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRender/ MESSAGE_NEVER + FILES_MATCHING + PATTERN "*.h*" + PATTERN "*.inl") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRender.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRender.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXRenderGlsl/CMakeLists.txt b/source/MaterialXRenderGlsl/CMakeLists.txt index ddab96c318..c180561560 100644 --- a/source/MaterialXRenderGlsl/CMakeLists.txt +++ b/source/MaterialXRenderGlsl/CMakeLists.txt @@ -93,15 +93,17 @@ target_include_directories(MaterialXRenderGlsl PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXRenderGlsl - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) +if(NOT SKBUILD) + install(TARGETS MaterialXRenderGlsl + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRenderGlsl/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRenderGlsl/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderGlsl.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderGlsl.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXRenderHw/CMakeLists.txt b/source/MaterialXRenderHw/CMakeLists.txt index 85ef13c55c..ff93c84022 100644 --- a/source/MaterialXRenderHw/CMakeLists.txt +++ b/source/MaterialXRenderHw/CMakeLists.txt @@ -62,15 +62,17 @@ target_include_directories(MaterialXRenderHw PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXRenderHw - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) +if(NOT SKBUILD) + install(TARGETS MaterialXRenderHw + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRenderHw/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRenderHw/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderHw.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderHw.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXRenderMsl/CMakeLists.txt b/source/MaterialXRenderMsl/CMakeLists.txt index 5ad50ea2cc..7afc5d8de8 100644 --- a/source/MaterialXRenderMsl/CMakeLists.txt +++ b/source/MaterialXRenderMsl/CMakeLists.txt @@ -80,15 +80,17 @@ target_include_directories(MaterialXRenderMsl PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXRenderMsl - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) +if(NOT SKBUILD) + install(TARGETS MaterialXRenderMsl + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRenderMsl/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRenderMsl/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderMsl.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderMsl.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXRenderOsl/CMakeLists.txt b/source/MaterialXRenderOsl/CMakeLists.txt index a4ffa81235..c8ada8a571 100644 --- a/source/MaterialXRenderOsl/CMakeLists.txt +++ b/source/MaterialXRenderOsl/CMakeLists.txt @@ -29,15 +29,17 @@ target_include_directories(MaterialXRenderOsl PRIVATE ${EXTERNAL_INCLUDE_DIRS}) -install(TARGETS MaterialXRenderOsl - EXPORT MaterialX - ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} - RUNTIME DESTINATION bin) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" - DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRenderOsl/ MESSAGE_NEVER - FILES_MATCHING PATTERN "*.h*") - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderOsl.pdb" - DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +if(NOT SKBUILD) + install(TARGETS MaterialXRenderOsl + EXPORT MaterialX + ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH} + RUNTIME DESTINATION bin) + + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXRenderOsl/ MESSAGE_NEVER + FILES_MATCHING PATTERN "*.h*") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXRenderOsl.pdb" + DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL) +endif() diff --git a/source/MaterialXTest/CMakeLists.txt b/source/MaterialXTest/CMakeLists.txt index e66db4bd2e..3a28ff3c26 100644 --- a/source/MaterialXTest/CMakeLists.txt +++ b/source/MaterialXTest/CMakeLists.txt @@ -100,6 +100,7 @@ if(MATERIALX_OSL_LEGACY_CLOSURES) ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/libraries/pbrlib/genosl/pbrlib_genosl_impl.legacy ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx) endif() +# TODO: What do we do with this? if(MATERIALX_BUILD_GEN_MDL) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../source/MaterialXGenMdl/mdl/" DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MATERIALX_INSTALL_MDL_MODULE_PATH}/mdl) diff --git a/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt b/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt index dfc2aefac0..bd1b1053e4 100644 --- a/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt @@ -13,9 +13,8 @@ set_target_properties( OUTPUT_NAME PyMaterialXCore COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" + # This is suspicious... INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -24,4 +23,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXCore - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt b/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt index 9566e792fd..095b3eb087 100644 --- a/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -25,4 +23,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXFormat - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt index b65ef857a4..24266712fd 100644 --- a/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -25,4 +23,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXGenGlsl - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXGenMdl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenMdl/CMakeLists.txt index a1bc225a4f..328a2439ed 100644 --- a/source/PyMaterialX/PyMaterialXGenMdl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenMdl/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -24,4 +22,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXGenMdl - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXGenMsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenMsl/CMakeLists.txt index 88e21687bc..33dec7319a 100644 --- a/source/PyMaterialX/PyMaterialXGenMsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenMsl/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -25,4 +23,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXGenMsl - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt index 5d30769b4d..65b0dabe67 100644 --- a/source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -25,4 +23,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXGenOsl - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXGenShader/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenShader/CMakeLists.txt index 13c01b3351..5bee142c24 100644 --- a/source/PyMaterialX/PyMaterialXGenShader/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenShader/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -26,4 +24,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXGenShader - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXRender/CMakeLists.txt b/source/PyMaterialX/PyMaterialXRender/CMakeLists.txt index a050cb6aa3..2617a0b392 100644 --- a/source/PyMaterialX/PyMaterialXRender/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXRender/CMakeLists.txt @@ -17,8 +17,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -28,4 +26,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXRender - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt index a29cdc5c1e..a0b04ddbda 100644 --- a/source/PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -27,4 +25,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXRenderGlsl - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXRenderMsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXRenderMsl/CMakeLists.txt index ec562fe8cf..04c6d95e3c 100644 --- a/source/PyMaterialX/PyMaterialXRenderMsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXRenderMsl/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -27,4 +25,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXRenderMsl - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") diff --git a/source/PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt index 4777b13e7b..c0b83948a9 100644 --- a/source/PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt @@ -14,8 +14,6 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" - VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( @@ -25,4 +23,4 @@ target_link_libraries( PRIVATE ${CMAKE_DL_LIBS}) install(TARGETS PyMaterialXRenderOsl - DESTINATION "python/MaterialX") + DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") From b9d3acf53d67075b1542720157c2daffc18c5c8f Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 13:43:57 -0400 Subject: [PATCH 02/30] Add new GH Actions workflow to build the wheels Signed-off-by: Jean-Christophe Morin --- .github/workflows/main.yml | 4 ++ .github/workflows/python.yml | 100 +++++++++++++++++++++++++++++++++++ pyproject.toml | 3 +- 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e68529175..172cd3aae7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,10 @@ on: - '**.md' workflow_dispatch: +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + jobs: build: diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000000..d05eb83b45 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,100 @@ +name: python + +on: + push: + pull_request: + +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + wheels: + name: Generate wheels + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ['37', '38', '39', '310', '311'] + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + steps: + - uses: actions/checkout@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.12.1 + with: + output-dir: dist + env: + CIBW_BUILD: 'cp${{ matrix.python-version }}-*' + CIBW_SKIP: '*musllinux*' + CIBW_ARCHS: 'auto64' + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 + # CIBW_BUILD_FRONTEND: build # https://github.com/pypa/build + CIBW_BUILD_VERBOSITY: 1 + CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2 + + - name: Store wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: ./dist/*.whl + + sdist: + name: Generate sdist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install build command + run: python -m pip install build + + - name: Create sdist + run: python -m build -s . --outdir dist + + - name: Store sdist + uses: actions/upload-artifact@v3 + with: + name: sdist + path: ./dist/*.tar.gz + + test: + name: Test wheels + needs: ['wheels'] + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Download wheels + uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + + - name: Install wheel + run: python -m pip install dist/*.whl + + - name: Python tests + run: | + python python/MaterialXTest/main.py + python python/MaterialXTest/genshader.py + python python/Scripts/mxupdate.py resources/Materials/TestSuite/stdlib/upgrade --yes + python python/Scripts/mxvalidate.py resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose + python python/Scripts/mxdoc.py --docType md libraries/pbrlib/pbrlib_defs.mtlx + python python/Scripts/mxdoc.py --docType html libraries/bxdf/standard_surface.mtlx + python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target glsl + python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target osl + python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target mdl + python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target msl diff --git a/pyproject.toml b/pyproject.toml index c0e279870c..3194fbc8c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ cmake.build-type = "Release" # Uncoment when developing locally to enable inplace builds. # build-dir = "build/" -logging.level = "INFO" +logging.level = "DEBUG" # Since the python package doesn't live in a standard directory # in the source (i.e ./src or ./), we need to manually specify @@ -73,6 +73,7 @@ MATERIALX_BUILD_SHARED_LIBS = 'OFF' # Be explicit MATERIALX_BUILD_PYTHON = 'ON' MATERIALX_TEST_RENDER = 'OFF' MATERIALX_WARNINGS_AS_ERRORS = 'ON' +MATERIALX_BUILD_RENDER = 'OFF' # TODO: How could we harmonize this variable with SKBUILD? MATERIALX_INSTALL_PYTHON = 'OFF' From bcffe4e90af1390c422936af975264785f568f12 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 15:52:57 -0400 Subject: [PATCH 03/30] Fix stdlib install Signed-off-by: Jean-Christophe Morin --- CMakeLists.txt | 1 - libraries/CMakeLists.txt | 24 +++++++++++++++--------- source/MaterialXTest/CMakeLists.txt | 1 - 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 048ec51650..48a2334f6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,6 @@ set(MATERIALX_OSL_INCLUDE_PATH "" CACHE PATH "Full path to OSL shader includes ( set(MATERIALX_PYTHON_FOLDER_NAME "python/MaterialX" CACHE INTERNAL "Folder name to user for installing the Python library.") if(SKBUILD) - set(MATERIALX_INSTALL_STDLIB_PATH "${SKBUILD_PLATLIB_DIR}/MaterialX/libraries") set(MATERIALX_PYTHON_FOLDER_NAME "MaterialX") endif() diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index eb30eb20f4..eddbeb16e9 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -1,20 +1,26 @@ -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}" MESSAGE_NEVER - PATTERN "CMakeLists.txt" EXCLUDE - PATTERN "pbrlib_genosl_impl.*" EXCLUDE) - if (MATERIALX_OSL_LEGACY_CLOSURES) set(PBRLIB_SUFFIX "legacy") else() set(PBRLIB_SUFFIX "mtlx") endif() -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PBRLIB_SUFFIX}" - DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx) +if(NOT SKBUILD) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}" + PATTERN "CMakeLists.txt" EXCLUDE + PATTERN "pbrlib_genosl_impl.*" EXCLUDE) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PBRLIB_SUFFIX}" + DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx) +endif() + +set(MATERIALX_PYTHON_LIBRARIES_PATH "${MATERIALX_PYTHON_FOLDER_NAME}/${MATERIALX_INSTALL_STDLIB_PATH}") +if(SKBUILD) + set(MATERIALX_PYTHON_LIBRARIES_PATH "${SKBUILD_PLATLIB_DIR}/MaterialX/libraries") +endif() install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}" + DESTINATION "${MATERIALX_PYTHON_LIBRARIES_PATH}" PATTERN "CMakeLists.txt" EXCLUDE PATTERN "pbrlib_genosl_impl.*" EXCLUDE) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PBRLIB_SUFFIX}" - DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx) + DESTINATION "${MATERIALX_PYTHON_LIBRARIES_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx) diff --git a/source/MaterialXTest/CMakeLists.txt b/source/MaterialXTest/CMakeLists.txt index 3a28ff3c26..e66db4bd2e 100644 --- a/source/MaterialXTest/CMakeLists.txt +++ b/source/MaterialXTest/CMakeLists.txt @@ -100,7 +100,6 @@ if(MATERIALX_OSL_LEGACY_CLOSURES) ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/libraries/pbrlib/genosl/pbrlib_genosl_impl.legacy ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx) endif() -# TODO: What do we do with this? if(MATERIALX_BUILD_GEN_MDL) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../source/MaterialXGenMdl/mdl/" DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MATERIALX_INSTALL_MDL_MODULE_PATH}/mdl) From bf105f1c2a8c2a318dc9bd26bdc1fd5d5497f665 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 15:53:08 -0400 Subject: [PATCH 04/30] Set MACOSX_DEPLOYMENT_TARGET to 10.13 Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index d05eb83b45..a63d8ff8fb 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -29,9 +29,10 @@ jobs: CIBW_SKIP: '*musllinux*' CIBW_ARCHS: 'auto64' CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 - # CIBW_BUILD_FRONTEND: build # https://github.com/pypa/build CIBW_BUILD_VERBOSITY: 1 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2 + # CIBW_BUILD_FRONTEND: build # https://github.com/pypa/build + MACOSX_DEPLOYMENT_TARGET: '10.13' - name: Store wheels uses: actions/upload-artifact@v3 From 47396ff93640352c0e1b4451f6b3a5fabfadc827 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 15:56:22 -0400 Subject: [PATCH 05/30] Remove Python 3.11. We would need a newer Pybind11 Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index a63d8ff8fb..c4d1933e27 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['37', '38', '39', '310', '311'] + python-version: ['37', '38', '39', '310'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: - uses: actions/checkout@v3 @@ -68,7 +68,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: From 446e427ffb765580b77c7aef8fa71ef9d0097e95 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 16:25:22 -0400 Subject: [PATCH 06/30] Reorganize workflow to build from sdist and disable MaterialXTest Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 72 ++++++++++++++++++++++-------------- pyproject.toml | 2 +- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index c4d1933e27..52745155df 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -9,21 +9,59 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} jobs: + # Generate the sdist first. We'll use it to created the wheels. + sdist: + name: Generate sdist + runs-on: ubuntu-latest + outputs: + sdist_filename: ${{ steps.generate.outputs.filename }} + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install build command + run: python -m pip install build + + - name: Generate sdist + id: generate + run: | + python -m build -s . --outdir dist + echo "filename=$(ls dist)" >> "$GITHUB_OUTPUT" + + - name: Store sdist + uses: actions/upload-artifact@v3 + with: + name: sdist + path: ./dist/*.tar.gz + + # Create the wheels. It'll use the sdist to confirm that we can ocnpile MaterialX from the sdist. wheels: name: Generate wheels runs-on: ${{ matrix.os }} + needs: ['sdist'] strategy: fail-fast: false matrix: python-version: ['37', '38', '39', '310'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + steps: - - uses: actions/checkout@v3 + - name: Download sdist + uses: actions/download-artifact@v3 + with: + name: sdist + path: sdist - name: Build wheels uses: pypa/cibuildwheel@v2.12.1 with: - output-dir: dist + # Build from the sdist. We want to make sure it's valid and works as expected. + package-dir: ${{ github.workspace }}/sdist/${{ needs.sdist.outputs.sdist_filename }} + output-dir: wheels env: CIBW_BUILD: 'cp${{ matrix.python-version }}-*' CIBW_SKIP: '*musllinux*' @@ -38,29 +76,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: wheels - path: ./dist/*.whl - - sdist: - name: Generate sdist - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: 3.11 - - - name: Install build command - run: python -m pip install build - - - name: Create sdist - run: python -m build -s . --outdir dist - - - name: Store sdist - uses: actions/upload-artifact@v3 - with: - name: sdist - path: ./dist/*.tar.gz + path: ./wheels/*.whl test: name: Test wheels @@ -82,10 +98,12 @@ jobs: uses: actions/download-artifact@v3 with: name: wheels - path: dist + path: wheels - name: Install wheel - run: python -m pip install dist/*.whl + # Note that pip will install the right wheel. It's able to select the wheel based on the current + # platform, python version, etc. + run: python -m pip install wheels/*.whl - name: Python tests run: | diff --git a/pyproject.toml b/pyproject.toml index 3194fbc8c9..677bf7620d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,6 @@ MATERIALX_BUILD_PYTHON = 'ON' MATERIALX_TEST_RENDER = 'OFF' MATERIALX_WARNINGS_AS_ERRORS = 'ON' MATERIALX_BUILD_RENDER = 'OFF' - +MATERIALX_BUILD_TESTS = 'OFF' # TODO: How could we harmonize this variable with SKBUILD? MATERIALX_INSTALL_PYTHON = 'OFF' From 764315f5c34eb8b5bd464ddb19186a01f5eae036 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 16:58:01 -0400 Subject: [PATCH 07/30] Fix pip install command Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 52745155df..d039630b40 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -2,7 +2,12 @@ name: python on: push: + paths-ignore: + - '**.md' pull_request: + paths-ignore: + - '**.md' + workflow_dispatch: concurrency: cancel-in-progress: true @@ -10,6 +15,7 @@ concurrency: jobs: # Generate the sdist first. We'll use it to created the wheels. + # https://packaging.python.org/en/latest/flow#the-source-distribution-sdist sdist: name: Generate sdist runs-on: ubuntu-latest @@ -39,6 +45,7 @@ jobs: path: ./dist/*.tar.gz # Create the wheels. It'll use the sdist to confirm that we can ocnpile MaterialX from the sdist. + # https://packaging.python.org/en/latest/flow#the-built-distributions-wheels wheels: name: Generate wheels runs-on: ${{ matrix.os }} @@ -57,6 +64,7 @@ jobs: path: sdist - name: Build wheels + # https://cibuildwheel.readthedocs.io/en/stable/ uses: pypa/cibuildwheel@v2.12.1 with: # Build from the sdist. We want to make sure it's valid and works as expected. @@ -101,9 +109,7 @@ jobs: path: wheels - name: Install wheel - # Note that pip will install the right wheel. It's able to select the wheel based on the current - # platform, python version, etc. - run: python -m pip install wheels/*.whl + run: python -m pip install --find-links wheels --no-index - name: Python tests run: | From 057d018c3178edf9c1848a6a49448327d0e52fd2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 16:59:09 -0400 Subject: [PATCH 08/30] Only run on 3.10 to speed up testing Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index d039630b40..787b7ea586 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -53,7 +53,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['37', '38', '39', '310'] + python-version: ['310'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: @@ -92,7 +92,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.10'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: From 1980eae5a962284cb04a44f6fd2524d434f7ab65 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 17:13:35 -0400 Subject: [PATCH 09/30] Fix tests again... Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 787b7ea586..7147c564e1 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -91,6 +91,7 @@ jobs: needs: ['wheels'] runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: python-version: ['3.10'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] @@ -109,7 +110,7 @@ jobs: path: wheels - name: Install wheel - run: python -m pip install --find-links wheels --no-index + run: python -m pip install MaterialX --find-links wheels --no-index - name: Python tests run: | From 333d147632096e250c2ff91862c9eddee788131a Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 17:31:03 -0400 Subject: [PATCH 10/30] Re-enable all Python versions Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7147c564e1..b0f5b9e2b6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -53,7 +53,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['310'] + python-version: ['37', '38', '39', '310'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: @@ -93,7 +93,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: From 62d65b525973fadcda043919eccd34a680b72748 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Mon, 10 Apr 2023 15:54:39 -0700 Subject: [PATCH 11/30] Minor spelling Signed-off-by: Jonathan Stone --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b0f5b9e2b6..b196dd8845 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -44,7 +44,7 @@ jobs: name: sdist path: ./dist/*.tar.gz - # Create the wheels. It'll use the sdist to confirm that we can ocnpile MaterialX from the sdist. + # Create the wheels. It'll use the sdist to confirm that we can compile MaterialX from the sdist. # https://packaging.python.org/en/latest/flow#the-built-distributions-wheels wheels: name: Generate wheels From 54369db2e2f67db81e61ad3a71089e774c316f7d Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Tue, 11 Apr 2023 12:46:59 -0400 Subject: [PATCH 12/30] Re-enable MATERIALX_BUILD_RENDER Signed-off-by: Jean-Christophe Morin --- .github/workflows/main.yml | 4 ++++ .github/workflows/python.yml | 6 +++++- CMakeLists.txt | 4 +++- pyproject.toml | 2 -- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 172cd3aae7..ed22d54c96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,9 +4,13 @@ on: push: paths-ignore: - '**.md' + - 'pyproject.toml' + - '.github/workflows/python.yml' pull_request: paths-ignore: - '**.md' + - 'pyproject.toml' + - '.github/workflows/python.yml' workflow_dispatch: concurrency: diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b196dd8845..a1a6ec857e 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -74,11 +74,15 @@ jobs: CIBW_BUILD: 'cp${{ matrix.python-version }}-*' CIBW_SKIP: '*musllinux*' CIBW_ARCHS: 'auto64' + # https://github.com/pypa/manylinux + # manylinux2014 is CentOS 7 based. Which means GCC 10 and glibc 2.17. CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 + CIBW_BEFORE_ALL_LINUX: yum install -y libXt-devel + CIBW_BEFORE_ALL_MACOS: sudo xcode-select -switch /Applications/Xcode_13.4.app CIBW_BUILD_VERBOSITY: 1 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2 # CIBW_BUILD_FRONTEND: build # https://github.com/pypa/build - MACOSX_DEPLOYMENT_TARGET: '10.13' + MACOSX_DEPLOYMENT_TARGET: '10.15' - name: Store wheels uses: actions/upload-artifact@v3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 48a2334f6c..fccf6c9aaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,7 +282,9 @@ if(MATERIALX_BUILD_RENDER) if(MATERIALX_BUILD_GRAPH_EDITOR) add_subdirectory(source/MaterialXGraphEditor) endif() - add_subdirectory(resources) + if(NOT SKBUILD) + add_subdirectory(resources) + endif() endif() # Add test subdirectory diff --git a/pyproject.toml b/pyproject.toml index 677bf7620d..d8dd1b5642 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,6 @@ sdist.exclude = [ "/documents", "/.github", "MANIFEST.in" - ] [tool.scikit-build.cmake.define] @@ -73,7 +72,6 @@ MATERIALX_BUILD_SHARED_LIBS = 'OFF' # Be explicit MATERIALX_BUILD_PYTHON = 'ON' MATERIALX_TEST_RENDER = 'OFF' MATERIALX_WARNINGS_AS_ERRORS = 'ON' -MATERIALX_BUILD_RENDER = 'OFF' MATERIALX_BUILD_TESTS = 'OFF' # TODO: How could we harmonize this variable with SKBUILD? MATERIALX_INSTALL_PYTHON = 'OFF' From 911f7c82090b01c25dc364bd0c3c09fde64d72a0 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Tue, 25 Apr 2023 14:32:59 -0700 Subject: [PATCH 13/30] Add Python 3.11 to build matrix Signed-off-by: Jonathan Stone --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index a1a6ec857e..ca2393806b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -97,7 +97,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: From d0b05a3d31f04176742f38a1551c0c3b3690b027 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Tue, 25 Apr 2023 14:34:20 -0700 Subject: [PATCH 14/30] Add Python 3.11 to build matrix Signed-off-by: Jonathan Stone --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index ca2393806b..16d6b4e1a4 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -53,7 +53,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['37', '38', '39', '310'] + python-version: ['37', '38', '39', '310', '311'] os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: From f0b32fb33e2b2f6de6768f8d2340c9465d92abd7 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Tue, 25 Apr 2023 14:35:55 -0700 Subject: [PATCH 15/30] Update Python version range Signed-off-by: Jonathan Stone --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d8dd1b5642..15fbf026c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,9 +9,7 @@ authors = [ { name="Contributors to the MaterialX project", email="materialx-discussion@lists.aswf.io" }, ] readme = "README.md" - -# TODO: Should it also support Python 2? -requires-python = ">=3.7" +requires-python = ">=3.6" # OCIO is not required. But if you want to eventually add it, # uncomment this, bundle the OCIO config and python/MaterialX/colorspace.py From 8bc9f262d7f7b955aa536892aa2ba7c84f1e7c6b Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Tue, 25 Apr 2023 16:45:12 -0700 Subject: [PATCH 16/30] Simplify list of build exclusions This changelist simplifies the list of new build exclusions for GitHub Actions, since the overhead of running this workflow is relatively small. Signed-off-by: Jonathan Stone --- .github/workflows/main.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed22d54c96..172cd3aae7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,13 +4,9 @@ on: push: paths-ignore: - '**.md' - - 'pyproject.toml' - - '.github/workflows/python.yml' pull_request: paths-ignore: - '**.md' - - 'pyproject.toml' - - '.github/workflows/python.yml' workflow_dispatch: concurrency: From 6b0dcfa5a445c39bc98536725d89fc49b39d4ca6 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Tue, 25 Apr 2023 21:24:03 -0700 Subject: [PATCH 17/30] Minor workflow clarifications Signed-off-by: Jonathan Stone --- .github/workflows/python.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 16d6b4e1a4..e4fbdd62f0 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -14,10 +14,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} jobs: - # Generate the sdist first. We'll use it to created the wheels. + # Generate the sdist first. We'll use it to create the wheels. # https://packaging.python.org/en/latest/flow#the-source-distribution-sdist sdist: - name: Generate sdist + name: Generate Source Distribution runs-on: ubuntu-latest outputs: sdist_filename: ${{ steps.generate.outputs.filename }} @@ -47,7 +47,7 @@ jobs: # Create the wheels. It'll use the sdist to confirm that we can compile MaterialX from the sdist. # https://packaging.python.org/en/latest/flow#the-built-distributions-wheels wheels: - name: Generate wheels + name: Generate Wheel runs-on: ${{ matrix.os }} needs: ['sdist'] strategy: @@ -91,7 +91,7 @@ jobs: path: ./wheels/*.whl test: - name: Test wheels + name: Test Wheel needs: ['wheels'] runs-on: ${{ matrix.os }} strategy: From 669d7d4df4d3a7e16d86b4cd0ab4da43cd3dbf0a Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Tue, 25 Apr 2023 21:49:35 -0700 Subject: [PATCH 18/30] Remove OCIO from Python build Signed-off-by: Jonathan Stone --- pyproject.toml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 15fbf026c3..352c9f38f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,14 +11,7 @@ authors = [ readme = "README.md" requires-python = ">=3.6" -# OCIO is not required. But if you want to eventually add it, -# uncomment this, bundle the OCIO config and python/MaterialX/colorspace.py -# will just work. -# dependencies = [ -# "opencolorio" -# ] - -# TODO: Add more classifier. +# TODO: Add more classifiers. classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", From 3e714879a379f077b40e3b4efc0c2bd681e79303 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Thu, 27 Apr 2023 20:23:50 -0700 Subject: [PATCH 19/30] Minor naming updates Signed-off-by: Jonathan Stone --- .github/workflows/python.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e4fbdd62f0..70c8765111 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -29,16 +29,16 @@ jobs: with: python-version: 3.11 - - name: Install build command + - name: Install Build Command run: python -m pip install build - - name: Generate sdist + - name: Generate Sdist id: generate run: | python -m build -s . --outdir dist echo "filename=$(ls dist)" >> "$GITHUB_OUTPUT" - - name: Store sdist + - name: Upload Sdist uses: actions/upload-artifact@v3 with: name: sdist @@ -57,13 +57,13 @@ jobs: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] steps: - - name: Download sdist + - name: Download Sdist uses: actions/download-artifact@v3 with: name: sdist path: sdist - - name: Build wheels + - name: Build Wheel # https://cibuildwheel.readthedocs.io/en/stable/ uses: pypa/cibuildwheel@v2.12.1 with: @@ -84,7 +84,7 @@ jobs: # CIBW_BUILD_FRONTEND: build # https://github.com/pypa/build MACOSX_DEPLOYMENT_TARGET: '10.15' - - name: Store wheels + - name: Upload Wheel uses: actions/upload-artifact@v3 with: name: wheels @@ -107,16 +107,16 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Download wheels + - name: Download Wheels uses: actions/download-artifact@v3 with: name: wheels path: wheels - - name: Install wheel + - name: Install Wheel run: python -m pip install MaterialX --find-links wheels --no-index - - name: Python tests + - name: Python Tests run: | python python/MaterialXTest/main.py python python/MaterialXTest/genshader.py From 4252d6a052e5dd564e68f4ca3c5abed127e9dc59 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Sat, 3 Jun 2023 16:53:09 -0400 Subject: [PATCH 20/30] Update tests Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 70c8765111..c349d6fed6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -118,13 +118,14 @@ jobs: - name: Python Tests run: | + set -e python python/MaterialXTest/main.py python python/MaterialXTest/genshader.py - python python/Scripts/mxupdate.py resources/Materials/TestSuite/stdlib/upgrade --yes - python python/Scripts/mxvalidate.py resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose - python python/Scripts/mxdoc.py --docType md libraries/pbrlib/pbrlib_defs.mtlx - python python/Scripts/mxdoc.py --docType html libraries/bxdf/standard_surface.mtlx - python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target glsl - python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target osl - python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target mdl - python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target msl + python python/Scripts/mxformat.py ./resources/Materials/TestSuite/stdlib/upgrade --yes --upgradeVersion True + python python/Scripts/mxvalidate.py ./resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose + python python/Scripts/mxdoc.py --docType md ./libraries/pbrlib/pbrlib_defs.mtlx + python python/Scripts/mxdoc.py --docType html ./libraries/bxdf/standard_surface.mtlx + python python/Scripts/generateshader.py ./resources/Materials/Examples/StandardSurface --target glsl + python python/Scripts/generateshader.py ./resources/Materials/Examples/StandardSurface --target osl + python python/Scripts/generateshader.py ./resources/Materials/Examples/StandardSurface --target mdl + python python/Scripts/generateshader.py ./resources/Materials/Examples/StandardSurface --target msl From 009c5efad404d2451b5e5420c9ca700c9e27d6bf Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Sat, 3 Jun 2023 17:18:42 -0400 Subject: [PATCH 21/30] Get python package version from CMake Signed-off-by: Jean-Christophe Morin --- CMakeLists.txt | 4 +- mtx_skbuild_plugin.py | 90 +++++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 15 +++++++- 3 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 mtx_skbuild_plugin.py diff --git a/CMakeLists.txt b/CMakeLists.txt index fccf6c9aaa..388dd8ef12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,9 @@ if (MATERIALX_BUILD_JS) endif() endif() -project(MaterialX) +project(MaterialX + VERSION ${MATERIALX_LIBRARY_VERSION} +) option(MATERIALX_BUILD_PYTHON "Build the MaterialX Python package from C++ bindings. Requires Python 3.6 or greater." OFF) option(MATERIALX_BUILD_VIEWER "Build the MaterialX Viewer." OFF) diff --git a/mtx_skbuild_plugin.py b/mtx_skbuild_plugin.py new file mode 100644 index 0000000000..483e7df95f --- /dev/null +++ b/mtx_skbuild_plugin.py @@ -0,0 +1,90 @@ +""" +This is a custom scikit-build-core plugin that will +fetch the MaterialX version from the CMake project. +""" +import os +import tempfile +import subprocess +from pathlib import Path +from typing import FrozenSet, Dict, Optional, Union, List + +from scikit_build_core.file_api.query import stateless_query +from scikit_build_core.file_api.reply import load_reply_dir + + +def dynamic_metadata( + fields: FrozenSet[str], + settings: Optional[Dict[str, object]] = None, +) -> Dict[str, Union[str, Dict[str, Optional[str]]]]: + print("mtx_skbuild_plugin: Computing MaterialX version from CMake...") + + if fields != {"version"}: + msg = "Only the 'version' field is supported" + raise ValueError(msg) + + if settings: + msg = "No inline configuration is supported" + raise ValueError(msg) + + current_dir = os.path.dirname(__file__) + + with tempfile.TemporaryDirectory() as tmpdir: + # We will use CMake's file API to get the version + # instead of parsing the CMakeLists files. + + # First generate the query folder so that CMake can generate replies. + reply_dir = stateless_query(Path(tmpdir)) + + # Run cmake (configure). CMake will generate a reply automatically. + try: + subprocess.run( + [ + "cmake", + "-S", + current_dir, + "-B", + tmpdir, + "-DMATERIALX_BUILD_SHARED_LIBS=OFF", + "-DMATERIALX_BUILD_PYTHON=OFF", + "-DMATERIALX_TEST_RENDER=OFF", + "-DMATERIALX_BUILD_TESTS=OFF", + "-DMATERIALX_INSTALL_PYTHON=OFF", + "-DMATERIALX_BUILD_RENDER=OFF", + ], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=True, + text=True, + ) + except subprocess.CalledProcessError as exc: + print(exc.stdout) + raise RuntimeError( + "Failed to configure project to get the version" + ) from exc + + # Get the generated replies. + index = load_reply_dir(reply_dir) + + # Get the version from the CMAKE_PROJECT_VERSION variable. + entries = [ + entry + for entry in index.reply.cache_v2.entries + if entry.name == "CMAKE_PROJECT_VERSION" + ] + + if not entries: + raise ValueError("Could not find MaterialX version from CMake project") + + if len(entries) > 1: + raise ValueError("More than one entry for CMAKE_PROJECT_VERSION found...") + + version = entries[0].value + print("mtx_skbuild_plugin: Computed version: {0}".format(version)) + + return {"version": version} + + +def get_requires_for_dynamic_metadata( + _settings: Optional[Dict[str, object]] = None, +) -> List[str]: + return ["cmake"] diff --git a/pyproject.toml b/pyproject.toml index 352c9f38f0..e965ccab31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,14 @@ [build-system] -requires = ["scikit-build-core"] +# Use a fixed version because we use an experimental feature +# (a custom plugin) and for now that functionality has +# no compatibility promises. +requires = ["scikit-build-core==0.4.4"] build-backend = "scikit_build_core.build" [project] name = "MaterialX" -version = "0.0.0.dev1" # TODO: Change version +dynamic = ["version"] + authors = [ { name="Contributors to the MaterialX project", email="materialx-discussion@lists.aswf.io" }, ] @@ -38,6 +42,13 @@ cmake.minimum-version = "3.18" cmake.verbose = false cmake.build-type = "Release" +# Enable experimental features if any are available +# In this case we need custom local plugin to get +# the project version from cmake. +experimental = true +metadata.version.provider = "mtx_skbuild_plugin" +metadata.version.provider-path = "./" + # Uncoment when developing locally to enable inplace builds. # build-dir = "build/" From aa175f4165ab812e1f5e03e16a8c17ed749ae058 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Sun, 4 Jun 2023 16:22:06 -0400 Subject: [PATCH 22/30] Fix tests on Windows Signed-off-by: Jean-Christophe Morin --- .github/workflows/python.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index c349d6fed6..33b74972e4 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -117,6 +117,7 @@ jobs: run: python -m pip install MaterialX --find-links wheels --no-index - name: Python Tests + shell: bash run: | set -e python python/MaterialXTest/main.py From 43c3fe987ea08dad620944d972be299d52f6cf97 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Wed, 12 Jul 2023 16:31:53 -0700 Subject: [PATCH 23/30] Update script syntax Signed-off-by: Jonathan Stone --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 33b74972e4..96705142df 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -122,7 +122,7 @@ jobs: set -e python python/MaterialXTest/main.py python python/MaterialXTest/genshader.py - python python/Scripts/mxformat.py ./resources/Materials/TestSuite/stdlib/upgrade --yes --upgradeVersion True + python python/Scripts/mxformat.py ./resources/Materials/TestSuite/stdlib/upgrade --yes --upgrade python python/Scripts/mxvalidate.py ./resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose python python/Scripts/mxdoc.py --docType md ./libraries/pbrlib/pbrlib_defs.mtlx python python/Scripts/mxdoc.py --docType html ./libraries/bxdf/standard_surface.mtlx From 3e69d80d27b908164e444031f6f919871462bd71 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Thu, 13 Jul 2023 13:39:00 -0700 Subject: [PATCH 24/30] Use original concurrency rules in main This changelist restores the original concurrency rules to the "main" workflow for now, and we can consider this change separately in the future. Signed-off-by: Jonathan Stone --- .github/workflows/main.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb6539f6ff..fecdbf7a52 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,10 +9,6 @@ on: - '**.md' workflow_dispatch: -concurrency: - cancel-in-progress: true - group: ${{ github.workflow }}-${{ github.ref }} - jobs: build: From d1f7001035f0f9b29ca89737d1afa618eb8f35d2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Fri, 4 Aug 2023 15:40:36 -0400 Subject: [PATCH 25/30] move mtx_skbuild_plugin.py into python folder Signed-off-by: Jean-Christophe Morin --- pyproject.toml | 2 +- mtx_skbuild_plugin.py => python/mtx_skbuild_plugin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename mtx_skbuild_plugin.py => python/mtx_skbuild_plugin.py (98%) diff --git a/pyproject.toml b/pyproject.toml index e965ccab31..12dc486adb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ cmake.build-type = "Release" # the project version from cmake. experimental = true metadata.version.provider = "mtx_skbuild_plugin" -metadata.version.provider-path = "./" +metadata.version.provider-path = "./python" # Uncoment when developing locally to enable inplace builds. # build-dir = "build/" diff --git a/mtx_skbuild_plugin.py b/python/mtx_skbuild_plugin.py similarity index 98% rename from mtx_skbuild_plugin.py rename to python/mtx_skbuild_plugin.py index 483e7df95f..56de6a9f53 100644 --- a/mtx_skbuild_plugin.py +++ b/python/mtx_skbuild_plugin.py @@ -41,7 +41,7 @@ def dynamic_metadata( [ "cmake", "-S", - current_dir, + os.path.dirname(current_dir), "-B", tmpdir, "-DMATERIALX_BUILD_SHARED_LIBS=OFF", From 6b4db09724daee67a552afcc16b5f45789a83153 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Sat, 5 Aug 2023 14:36:31 -0400 Subject: [PATCH 26/30] Make sure there is no RPATH on Linux and macOS wheels Signed-off-by: Jean-Christophe Morin --- CMakeLists.txt | 6 ++++++ source/PyMaterialX/PyMaterialXCore/CMakeLists.txt | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d42d276b..8c67e880f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,6 +193,12 @@ set(MATERIALX_SAME_DIR_RPATH "${RPATH_RELATIVE_SYMBOL};${CMAKE_INSTALL_PREFIX}/$ set(MATERIALX_UP_ONE_RPATH "${RPATH_RELATIVE_SYMBOL}/../${MATERIALX_INSTALL_LIB_PATH};${MATERIALX_SAME_DIR_RPATH}") # For linking to libraries where source is two directories deep, ie: "MATX/python/MaterialX/../../lib" set(MATERIALX_UP_TWO_RPATH "${RPATH_RELATIVE_SYMBOL}/../../${MATERIALX_INSTALL_LIB_PATH};${MATERIALX_SAME_DIR_RPATH}") +if(SKBUILD) + # When building the Python wheels, we don't want to set any RPATH because + # we want to wheel to be self-contained. We don't want any interference from + # external paths. + set(MATERIALX_UP_TWO_RPATH "${RPATH_RELATIVE_SYMBOL}") +endif() # Adjust compiler settings if(MSVC) diff --git a/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt b/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt index bd1b1053e4..9f3d2291c0 100644 --- a/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt @@ -13,7 +13,6 @@ set_target_properties( OUTPUT_NAME PyMaterialXCore COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" - # This is suspicious... INSTALL_RPATH "${MATERIALX_UP_TWO_RPATH}" DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") From ae2cae5ed5d85583032858214ad9db1b8e632e6c Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Thu, 17 Aug 2023 17:08:30 -0700 Subject: [PATCH 27/30] Remove TODO Signed-off-by: Jonathan Stone --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 12dc486adb..e674339900 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ authors = [ readme = "README.md" requires-python = ">=3.6" -# TODO: Add more classifiers. classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", From 6a8c7f9753eac99160894fc6574881dd59aa376a Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Thu, 17 Aug 2023 19:12:11 -0700 Subject: [PATCH 28/30] Allow concurrent builds for now Signed-off-by: Jonathan Stone --- .github/workflows/python.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 96705142df..6f54ed45e4 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -9,10 +9,6 @@ on: - '**.md' workflow_dispatch: -concurrency: - cancel-in-progress: true - group: ${{ github.workflow }}-${{ github.ref }} - jobs: # Generate the sdist first. We'll use it to create the wheels. # https://packaging.python.org/en/latest/flow#the-source-distribution-sdist From 2cade133c95b5c34629961205d8c87aedfaef093 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Tue, 22 Aug 2023 10:07:44 -0700 Subject: [PATCH 29/30] Minor spacing update Signed-off-by: Jonathan Stone --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c67e880f3..d8d082ca61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,7 @@ if (MATERIALX_BUILD_JS) endif() endif() -project(MaterialX - VERSION ${MATERIALX_LIBRARY_VERSION} -) +project(MaterialX VERSION ${MATERIALX_LIBRARY_VERSION}) option(MATERIALX_BUILD_PYTHON "Build the MaterialX Python package from C++ bindings. Requires Python 3.6 or greater." OFF) option(MATERIALX_BUILD_VIEWER "Build the MaterialX Viewer." OFF) From f775f6f3bf37f8ebaa480215d4ff4e948605e02b Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Tue, 22 Aug 2023 10:17:33 -0700 Subject: [PATCH 30/30] Remove forward slash for consistency Signed-off-by: Jonathan Stone --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 76af3d4ab7..9d0b71a3c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ build -/dist +dist