Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include standard data libraries in Python package #1237

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jobs:
python MaterialXTest/main.py
python MaterialXTest/genshader.py
python Scripts/mxupdate.py ../resources/Materials/TestSuite/stdlib/upgrade --yes
python Scripts/mxvalidate.py ../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --verbose
python Scripts/mxvalidate.py ../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose
python Scripts/mxdoc.py --docType md ../libraries/pbrlib/pbrlib_defs.mtlx
python Scripts/mxdoc.py --docType html ../libraries/bxdf/standard_surface.mtlx
python Scripts/generateshader.py ../resources/Materials/Examples/StandardSurface --path .. --target glsl
Expand Down
7 changes: 7 additions & 0 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ 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)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION "python/MaterialX/${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)
1 change: 1 addition & 0 deletions python/MaterialX/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include libraries
jstone-lucasfilm marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 18 additions & 1 deletion python/MaterialX/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .PyMaterialXCore import *
from .PyMaterialXFormat import *
from .datatype import *

import os

#
# Element
Expand Down Expand Up @@ -292,3 +292,20 @@ def _stringToValue(string, t):
#

readFromXmlFile = readFromXmlFileBase


#
# Data Search Paths
#
def getDefaultDataSearchPath():
"""
Return the default data search path.
"""
root_path = os.path.dirname(__file__)
return root_path

def getDefaultDataLibraryFolders():
"""
Return list of default data library folders
"""
return [ 'libraries' ]
10 changes: 5 additions & 5 deletions python/Scripts/mxvalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def main():

if opts.stdlib:
stdlib = mx.createDocument()
filePath = os.path.dirname(os.path.abspath(__file__))
searchPath = mx.FileSearchPath(os.path.join(filePath, '..', '..'))
searchPath.append(os.path.dirname(opts.inputFilename))
libraryFolders = [ "libraries" ]
mx.loadLibraries(libraryFolders, searchPath, stdlib)
try:
mx.loadLibraries(mx.getDefaultDataLibraryFolders(), mx.getDefaultDataSearchPath(), stdlib)
except err:
print(err)
sys.exit(0)
doc.importLibrary(stdlib)

(valid, message) = doc.validate()
Expand Down