Skip to content
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
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ graft share
graft src
graft tests
global-include CMakeLists.txt *.cmake *.md
global-exclude */__pycache__/*
global-exclude *.pyc
global-exclude .DS_Store
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build-backend = "setuptools.build_meta"
[tool.cibuildwheel]
build-verbosity = "1"

test-command = "python -m PyOpenColorIOTests.OpenColorIOTestSuite"
test-command = "python -m PyOpenColorIO.tests.OpenColorIOTestSuite"
test-requires = ["numpy"]

manylinux-x86_64-image = "manylinux2014"
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ def build_extension(self, ext):
setup(
version=get_version(),
package_dir={
'PyOpenColorIOTests': 'tests/python',
'PyOpenColorIOTests.data': 'tests/data',
'PyOpenColorIO': 'src/bindings/python/package',
'PyOpenColorIO.tests': 'tests/python',
'PyOpenColorIO.data': 'tests/data',
},
packages=['PyOpenColorIOTests', 'PyOpenColorIOTests.data'],
ext_modules=[CMakeExtension("PyOpenColorIO")],
packages=['PyOpenColorIO', 'PyOpenColorIO.tests', 'PyOpenColorIO.data'],
ext_modules=[CMakeExtension("PyOpenColorIO.PyOpenColorIO")],
cmdclass={"build_ext": CMakeBuild},
include_package_data=True
)
32 changes: 21 additions & 11 deletions src/bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,6 @@ if(WIN32)
)
endif()

# NOTE: Depending of the compiler version pybind11 2.4.3 does not compile with C++17 so revert to c++11

set(APP_CXX_STANDARD ${CMAKE_CXX_STANDARD})
if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 17)
set(APP_CXX_STANDARD 11)
endif()

set(CUSTOM_COMPILE_FLAGS ${PLATFORM_COMPILE_OPTIONS})
set(CUSTOM_LINK_FLAGS ${PLATFORM_LINK_OPTIONS})

Expand All @@ -159,7 +152,6 @@ set_target_properties(PyOpenColorIO
PROPERTIES
COMPILE_OPTIONS "${CUSTOM_COMPILE_FLAGS}"
LINK_OPTIONS "${CUSTOM_LINK_FLAGS}"
CXX_STANDARD ${APP_CXX_STANDARD}
)

if(NOT BUILD_SHARED_LIBS)
Expand All @@ -183,10 +175,10 @@ if (UNIX AND NOT CMAKE_SKIP_RPATH)
# dynamic library based on the default installation directory structure.
if (APPLE)
set_target_properties(PyOpenColorIO PROPERTIES
INSTALL_RPATH "@loader_path/../..;${CMAKE_INSTALL_RPATH}")
INSTALL_RPATH "@loader_path/../../..;${CMAKE_INSTALL_RPATH}")
else()
set_target_properties(PyOpenColorIO PROPERTIES
INSTALL_RPATH "$ORIGIN/../..;${CMAKE_INSTALL_RPATH}")
INSTALL_RPATH "$ORIGIN/../../..;${CMAKE_INSTALL_RPATH}")
endif()
endif()

Expand Down Expand Up @@ -227,6 +219,24 @@ target_compile_definitions(PyOpenColorIO
PY_VERSION_PATCH=${Python_VERSION_PATCH}
)

###############################################################################
# Build layout
# Mirrors the installation, using PyOpenColorIO folder and __init__.py file.
# When building the Python wheel, do not override the target directory.
set(_PyOpenColorIO_BUILD_PACKAGE_DIR "${CMAKE_CURRENT_BINARY_DIR}/PyOpenColorIO")
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set_target_properties(PyOpenColorIO PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${_PyOpenColorIO_BUILD_PACKAGE_DIR}"
# For Windows compatibility
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${_PyOpenColorIO_BUILD_PACKAGE_DIR}"
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${_PyOpenColorIO_BUILD_PACKAGE_DIR}"
)
endif()

file(COPY package/__init__.py DESTINATION "${_PyOpenColorIO_BUILD_PACKAGE_DIR}")

###############################################################################
# Install layout
# Set to site-package location.
if(WIN32)
set(_Python_VARIANT_PATH "${CMAKE_INSTALL_LIBDIR}/site-packages")
Expand All @@ -245,4 +255,4 @@ install(TARGETS PyOpenColorIO
LIBRARY DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR}
)

install(FILES __init__.py DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR})
install(FILES package/__init__.py DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR})
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@
if os.path.exists(path) and path != ".":
os.add_dll_directory(path)

from .PyOpenColorIO import *
del os, sys, platform

#
# Import compiled module.
#

from .PyOpenColorIO import __author__, __email__, __license__, __copyright__, __version__, __status__, __doc__

from .PyOpenColorIO import *
12 changes: 12 additions & 0 deletions tests/python/OpenColorIOTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@

class OpenColorIOTest(unittest.TestCase):

def test_attributes(self):
"""
Test Global attributes.
"""
self.assertTrue(hasattr(OCIO, "__author__"))
self.assertTrue(hasattr(OCIO, "__email__"))
self.assertTrue(hasattr(OCIO, "__license__"))
self.assertTrue(hasattr(OCIO, "__copyright__"))
self.assertTrue(hasattr(OCIO, "__version__"))
self.assertTrue(hasattr(OCIO, "__status__"))
self.assertTrue(hasattr(OCIO, "__doc__"))

def test_env_variable(self):
"""
Test Get/SetEnvVariable().
Expand Down
12 changes: 3 additions & 9 deletions tests/python/OpenColorIOTestSuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@
# Note: Only when compiling within Microsoft Visual Studio editor i.e. not on command line.
if len(sys.argv) == 3:
opencolorio_dir = os.path.join(opencolorio_dir, sys.argv[2])
pyopencolorio_dir = os.path.join(pyopencolorio_dir, sys.argv[2])

# Python 3.8+ does no longer look for DLLs in PATH environment variable
if hasattr(os, 'add_dll_directory'):
os.add_dll_directory(opencolorio_dir)
else:
os.environ['PATH'] = '{0};{1}'.format(
opencolorio_dir, os.getenv('PATH', ''))
# PyOpenColorIO __init__.py file handle os.add_dll_directory()
os.environ['PATH'] = '{0};{1}'.format(opencolorio_dir, os.getenv('PATH', ''))
elif sys.platform == 'darwin':
# On OSX we must add the main library location to DYLD_LIBRARY_PATH
os.environ['DYLD_LIBRARY_PATH'] = '{0}:{1}'.format(
Expand All @@ -41,7 +35,7 @@
# Else it probably means direct invocation from installed package
else:
here = os.path.dirname(__file__)
os.environ["TEST_DATAFILES_DIR"] = os.path.join(here, 'data', 'files')
os.environ["TEST_DATAFILES_DIR"] = os.path.join(os.path.dirname(here), 'data', 'files')
sys.path.insert(0, here)

import PyOpenColorIO as OCIO
Expand Down
2 changes: 1 addition & 1 deletion tests/python/TransformsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def all_transforms_as_group(self):
# Ensure we only catch and filter for this specific error
self.assertEqual(
str(e),
'PyOpenColorIO.Transform: No constructor defined!',
'PyOpenColorIO.PyOpenColorIO.Transform: No constructor defined!',
'Unintended Error Raised: {0}'.format(e)
)

Expand Down