Skip to content

Commit 846609c

Browse files
Merge branch 'main' into otime_doxygen
2 parents 4b05054 + 43de3e5 commit 846609c

File tree

9 files changed

+101
-28
lines changed

9 files changed

+101
-28
lines changed

CMakeLists.txt

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ option(OTIO_INSTALL_COMMANDLINE_TOOLS "Install the OTIO command line tools" ON)
3434
option(OTIO_INSTALL_CONTRIB "Install the opentimelineio_contrib Python package" ON)
3535
set(OTIO_IMATH_LIBS "" CACHE STRING "Imath library overrides to use instead of src/deps or find_package")
3636
option(OTIO_FIND_IMATH "Find Imath using find_package, ignored if OTIO_IMATH_LIBS is set" OFF)
37+
option(OTIO_FIND_RAPIDJSON "Find RapidJSON using find_package" OFF)
3738
set(OTIO_PYTHON_INSTALL_DIR "" CACHE STRING "Python installation dir (such as the site-packages dir)")
3839

3940
# Build options
@@ -118,6 +119,31 @@ else()
118119
endif()
119120
endif()
120121

122+
# Set the SO version. The SO version must be incremented every time a change
123+
# occurs to the ABI that causes a backward incompatibility. Such changes
124+
# include, exhaustively:
125+
#
126+
# * a change to struct or class layout
127+
# * enum changes that would cause a renumbering of previously published enums
128+
# * a removal of a struct, class, enumeration, or function
129+
# * a change in parameters to a free standing function
130+
# * a removal of a global variable
131+
#
132+
# OTIO currently designates the minor version number for breaking changes,
133+
# e.g. v0.15, v0.16.0, v0.17.0, accordingly the SO version will be incremented
134+
# to match. SO version must be monotically increasing, so the ABI version
135+
# should be computed as: major * 100 + revision. The third digit will never
136+
# implicate an ABI version change. So for example, the following OTIO versions
137+
# would map to these ABI versions:
138+
#
139+
# * v0.18.0 - 18
140+
# * v0.19.0 - 19
141+
# * v0.19.1 - 19 # No ABI changes with minor version changes
142+
# * v1.0.0 - 100
143+
# * v1.1.0 - 101
144+
#
145+
math(EXPR OTIO_SOVERSION "${OTIO_VERSION_MAJOR} * 100 + ${OTIO_VERSION_MINOR}")
146+
121147
set(OTIO_RESOLVED_CXX_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
122148

123149
if(OTIO_CXX_INSTALL)
@@ -223,13 +249,10 @@ if (NOT "${OTIO_IMATH_LIBS}" STREQUAL "")
223249
set(OTIO_RESOLVED_IMATH_LIBRARIES "${OTIO_IMATH_LIBS}")
224250
set(USE_DEPS_IMATH OFF)
225251
elseif(OTIO_FIND_IMATH)
226-
find_package(Imath QUIET)
252+
set(USE_DEPS_IMATH OFF)
253+
find_package(Imath REQUIRED)
227254
if (Imath_FOUND)
228255
message(STATUS "Found Imath 3 at ${Imath_CONFIG}")
229-
set(USE_DEPS_IMATH OFF)
230-
else()
231-
message(STATUS "Imath 3 was not found, using src/deps/Imath")
232-
set(USE_DEPS_IMATH ON)
233256
endif()
234257
else()
235258
message(STATUS "Using src/deps/Imath by default")
@@ -240,6 +263,17 @@ if(USE_DEPS_IMATH)
240263
include_directories("${PROJECT_SOURCE_DIR}/src/deps/Imath/src")
241264
endif()
242265

266+
#----- RapidJSON
267+
268+
if(OTIO_FIND_RAPIDJSON)
269+
find_package(RapidJSON CONFIG REQUIRED)
270+
if (RapidJSON_FOUND)
271+
message(STATUS "Found RapidJSON at ${RapidJSON_CONFIG}")
272+
endif()
273+
else()
274+
message(STATUS "Using src/deps/rapidjson by default")
275+
endif()
276+
243277
# set up the internally hosted dependencies
244278
add_subdirectory(src/deps)
245279

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,12 @@ namespace otio = opentimelineio::OPENTIMELINEIO_VERSION;
106106
void
107107
main()
108108
{
109-
otio::ErrorStatus err;
110109
otio::SerializableObject::Retainer<otio::Timeline> tl(
111110
dynamic_cast<otio::Timeline*>(
112-
otio::Timeline::from_json_file("taco.otio", &err)
111+
otio::Timeline::from_json_file("taco.otio")
113112
)
114113
);
115-
const std::vector<otio::SerializableObject::Retainer<otio::Clip>> clips = (
116-
tl->find_clips()
117-
);
118-
for (const auto& cl : clips)
114+
for (const auto& cl : tl->find_clips())
119115
{
120116
otio::RationalTime dur = cl->duration();
121117
std::cout << "Name: " << cl->name() << " [";

src/deps/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
#----- Other dependencies
55

66
# detect if the submodules haven't been updated
7-
set(DEPS_SUBMODULES pybind11 rapidjson)
7+
set(DEPS_SUBMODULES pybind11)
8+
9+
if(NOT OTIO_FIND_RAPIDJSON)
10+
set(DEPS_SUBMODULES ${DEPS_SUBMODULES} rapidjson)
11+
endif()
12+
813
foreach(submodule IN LISTS DEPS_SUBMODULES)
914
file(GLOB SUBMOD_CONTENTS ${submodule})
1015
list(LENGTH SUBMOD_CONTENTS SUBMOD_CONTENT_LEN)

src/opentime/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ set_target_properties(opentime PROPERTIES
2424
POSITION_INDEPENDENT_CODE TRUE
2525
WINDOWS_EXPORT_ALL_SYMBOLS true)
2626

27+
if(BUILD_SHARED_LIBS)
28+
set_target_properties(opentime PROPERTIES
29+
SOVERSION ${OTIO_SOVERSION}
30+
VERSION ${OTIO_VERSION})
31+
endif()
32+
2733
if(APPLE)
2834
set_target_properties(opentime PROPERTIES
2935
INSTALL_NAME_DIR "@loader_path"

src/opentimelineio/CMakeLists.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ add_library(opentimelineio ${OTIO_SHARED_OR_STATIC_LIB}
7878
add_library(OTIO::opentimelineio ALIAS opentimelineio)
7979

8080
target_include_directories(opentimelineio
81-
PRIVATE "${PROJECT_SOURCE_DIR}/src"
82-
"${PROJECT_SOURCE_DIR}/src/deps"
83-
"${PROJECT_SOURCE_DIR}/src/deps/rapidjson/include")
81+
PRIVATE "${PROJECT_SOURCE_DIR}/src")
82+
83+
if(OTIO_FIND_RAPIDJSON)
84+
target_include_directories(opentimelineio
85+
PRIVATE "${RapidJSON_INCLUDE_DIRS}")
86+
else()
87+
target_include_directories(opentimelineio
88+
PRIVATE "${PROJECT_SOURCE_DIR}/src/deps/rapidjson/include")
89+
endif()
8490

8591

8692
target_link_libraries(opentimelineio
@@ -92,6 +98,12 @@ set_target_properties(opentimelineio PROPERTIES
9298
POSITION_INDEPENDENT_CODE TRUE
9399
WINDOWS_EXPORT_ALL_SYMBOLS true)
94100

101+
if(BUILD_SHARED_LIBS)
102+
set_target_properties(opentimelineio PROPERTIES
103+
SOVERSION ${OTIO_SOVERSION}
104+
VERSION ${OTIO_VERSION})
105+
endif()
106+
95107
if(APPLE)
96108
set_target_properties(opentimelineio PROPERTIES
97109
INSTALL_NAME_DIR "@loader_path"

src/opentimelineio/serialization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class Encoder
7777
virtual void write_value(class TimeTransform const& value) = 0;
7878
virtual void write_value(struct SerializableObject::ReferenceId) = 0;
7979
virtual void write_value(IMATH_NAMESPACE::Box2d const&) = 0;
80+
virtual void write_value(IMATH_NAMESPACE::V2d const&) = 0;
8081

8182
protected:
8283
void _error(ErrorStatus const& error_status)
@@ -269,7 +270,7 @@ class CloningEncoder : public Encoder
269270
_store(std::any(value));
270271
}
271272

272-
void write_value(IMATH_NAMESPACE::V2d const& value)
273+
void write_value(IMATH_NAMESPACE::V2d const& value) override
273274
{
274275

275276
if (_result_object_policy == ResultObjectPolicy::OnlyAnyDictionary)

src/py-opentimelineio/opentimelineio/url_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ def filepath_from_url(urlstr):
7777
filepath = pathlib.PurePosixPath(filepath.drive, *filepath.parts[1:])
7878

7979
# If the specified index is a windows drive, then offset the path
80-
elif pathlib.PureWindowsPath(filepath.parts[1]).drive:
80+
elif (
81+
# relative paths may not have a parts[1]
82+
len(filepath.parts) > 1
83+
and pathlib.PureWindowsPath(filepath.parts[1]).drive
84+
):
8185
# Remove leading "/" if/when `request.url2pathname` yields
8286
# "/S:/path/file.ext"
8387
filepath = pathlib.PurePosixPath(*filepath.parts[1:])

tests/test_url_conversions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ def test_posix_urls(self):
7979
processed_url = otio.url_utils.filepath_from_url(url)
8080
self.assertEqual(processed_url, POSIX_PATH)
8181

82+
def test_relative_url(self):
83+
# see github issue #1817 - when a relative URL has only one name after
84+
# the "." (ie ./blah but not ./blah/blah)
85+
self.assertEqual(
86+
otio.url_utils.filepath_from_url(os.path.join(".", "docs")),
87+
"docs",
88+
)
89+
8290

8391
if __name__ == "__main__":
8492
unittest.main()

tests/test_v2d.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright Contributors to the OpenTimelineIO project
33

4-
import unittest
4+
import json
55
import sys
6+
import unittest
67

7-
import opentimelineio as otio
88
import opentimelineio.test_utils as otio_test_utils
99

10+
import opentimelineio as otio
11+
1012

1113
class V2dTests(unittest.TestCase, otio_test_utils.OTIOAssertions):
1214
def test_cons(self):
@@ -21,15 +23,9 @@ def test_cons(self):
2123
def test_str(self):
2224
v = otio.schema.V2d(1.0, 2.0)
2325

24-
self.assertMultiLineEqual(
25-
str(v),
26-
'V2d(1.0, 2.0)'
27-
)
26+
self.assertMultiLineEqual(str(v), "V2d(1.0, 2.0)")
2827

29-
self.assertMultiLineEqual(
30-
repr(v),
31-
'otio.schema.V2d(x=1.0, y=2.0)'
32-
)
28+
self.assertMultiLineEqual(repr(v), "otio.schema.V2d(x=1.0, y=2.0)")
3329

3430
def test_equality(self):
3531
v1 = otio.schema.V2d(1.0, 2.0)
@@ -104,6 +100,17 @@ def test_limits(self):
104100
self.assertEqual(otio.schema.V2d.baseTypeSmallest(), sys.float_info.min)
105101
self.assertEqual(otio.schema.V2d.baseTypeEpsilon(), sys.float_info.epsilon)
106102

103+
def test_json_serialization(self):
104+
serialized = otio.adapters.otio_json.write_to_string(otio.schema.V2d())
105+
json_v2d = json.loads(serialized)
106+
self.assertEqual(json_v2d["OTIO_SCHEMA"], "V2d.1")
107+
108+
def test_serialization_round_trip(self):
109+
v2d = otio.schema.V2d()
110+
serialized = otio.adapters.otio_json.write_to_string(v2d)
111+
deserialized = otio.adapters.otio_json.read_from_string(serialized)
112+
self.assertEqual(v2d, deserialized)
113+
107114

108-
if __name__ == '__main__':
115+
if __name__ == "__main__":
109116
unittest.main()

0 commit comments

Comments
 (0)