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

Support --prefix correctly in new cmake system #886

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
28 changes: 14 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ if(OTIO_PYTHON_INSTALL)
# that default behaviors match a reasonable expectation, as follows:
#
# if nothing has been set,
# Python: ${Python_SITEARCH}/opentimelineio
# C++: ${Python_SITEARCH}/opentimelineio/cxx-libs
# Python: ${OTIO_RESOLVED_PYTHON_INSTALL_DIR}/opentimelineio
# C++: ${OTIO_RESOLVED_PYTHON_INSTALL_DIR}/opentimelineio/cxx-libs
# if only CMAKE_INSTALL_PREFIX has been set,
# Python: ${CMAKE_INSTALL_PREFIX}/opentimelineio/python
# C++: ${CMAKE_INSTALL_PREFIX}/opentimelineio
Expand All @@ -60,29 +60,29 @@ if(OTIO_PYTHON_INSTALL)
if(OTIO_PYTHON_INSTALL_DIR STREQUAL "" AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# neither install directory supplied from the command line
find_package(Python REQUIRED COMPONENTS Interpreter Development)
set(OTIO_RESOLVED_PYTHON_INSTALL_DIR "${Python_SITEARCH}")
set(OTIO_RESOLVED_CXX_INSTALL_DIR "${Python_SITEARCH}/opentimelineio/cxx-libs")
set(OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR "${Python_SITEARCH}/opentimelineio")
set(OTIO_RESOLVED_PYTHON_INSTALL_DIR "${OTIO_RESOLVED_PYTHON_INSTALL_DIR}")
set(OTIO_RESOLVED_CXX_INSTALL_DIR "${OTIO_RESOLVED_PYTHON_INSTALL_DIR}/opentimelineio/cxx-libs")
set(OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR "${OTIO_RESOLVED_PYTHON_INSTALL_DIR}/opentimelineio")
message(INFO, "OTIO Defaulting both Python and C++ install to ${OTIO_RESOLVED_PYTHON_INSTALL_DIR}")
else()
# either python_install or install_prefix have been set
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# OTIO_PYTHON_INSTALL_DIR was set, so install everything into the python package
set(OTIO_RESOLVED_PYTHON_INSTALL_DIR "${OTIO_PYTHON_INSTALL_DIR}")
set(OTIO_RESOLVED_CXX_INSTALL_DIR "${OTIO_PYTHON_INSTALL_DIR}/opentimelineio/lib")
set(OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR "${OTIO_PYTHON_INSTALL_DIR}/opentimelineio")
message(INFO, "OTIO Defaulting C++ install to ${OTIO_RESOLVED_CXX_INSTALL_DIR}")
else()
if(OTIO_PYTHON_INSTALL_DIR_INITIALIZED_TO_DEFAULT)
# CMAKE_INSTALL_PREFIX was set, so install the python components there
set(OTIO_RESOLVED_PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/python")
set(OTIO_RESOLVED_CXX_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")

# In order to not require setting $PYTHONPATH to point at the .so,
# the shared libraries are installed into the python library
# location.
set(OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR "${OTIO_PYTHON_INSTALL_DIR}/opentimelineio")
set(OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR "${OTIO_RESOLVED_PYTHON_INSTALL_DIR}/opentimelineio")
message(INFO, "OTIO Defaulting Python install to ${OTIO_RESOLVED_PYTHON_INSTALL_DIR}")
message(INFO, "Note: C++ linkable-shared libraries can be found: ${OTIO_PYTHON_INSTALL_DIR}/opentimelineio")
message(INFO, "Note: C++ linkable-shared libraries can be found: ${CMAKE_INSTALL_PREFIX}/opentimelineio")
else()
# OTIO_PYTHON_INSTALL_DIR was set, so install everything into the python package
set(OTIO_RESOLVED_PYTHON_INSTALL_DIR "${OTIO_PYTHON_INSTALL_DIR}")
set(OTIO_RESOLVED_CXX_INSTALL_DIR "${OTIO_PYTHON_INSTALL_DIR}/opentimelineio/cxx-sdk")
set(OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR "${OTIO_PYTHON_INSTALL_DIR}/opentimelineio")
message(INFO, "OTIO Defaulting C++ install to ${OTIO_PYTHON_INSTALL_DIR}")
endif()
endif()
else()
Expand Down
49 changes: 33 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
import distutils


# XXX: If there is a better way to find the value of --prefix, please notify
# the maintainers of OpenTimelineIO.
_dist = distutils.dist.Distribution()
_dist.parse_config_files()
_dist.parse_command_line()
PREFIX = _dist.get_option_dict('install').get('prefix', [None, None])[1]


class _Ctx(object):
pass

Expand Down Expand Up @@ -77,21 +85,30 @@ def cmake_generate():
'-DCMAKE_BUILD_TYPE=' + ('Debug' if _ctx.debug else 'Release')
]

if "--user" in sys.argv:
cmake_args += [
'-DOTIO_PYTHON_INSTALL_DIR=' + _ctx.install_usersite,
'-DCMAKE_INSTALL_PREFIX=' + os.path.join(_ctx.install_usersite,
"opentimelineio", "cxx-libs"),
'-DOTIO_PYTHON_PACKAGE_DIR=' + os.path.join(_ctx.install_usersite,
"opentimelineio")
]
else:
cmake_args += [
'-DOTIO_PYTHON_INSTALL_DIR=' + get_python_lib(),
'-DCMAKE_INSTALL_PREFIX=' + os.path.join(get_python_lib(),
"opentimelineio", "cxx-libs"),
'-DOTIO_PYTHON_PACKAGE_DIR=' + get_python_lib()
]
python_inst_dir = get_python_lib()

if PREFIX:
# XXX: is there a better way to find this? This is the suffix from
# where it would have been installed pasted onto the PREFIX as passed
# in by --prefix.
python_inst_dir = (
distutils.sysconfig.get_python_lib().replace(sys.prefix, PREFIX)
)
elif "--user" in sys.argv:
python_inst_dir = _ctx.install_usersite

# install the C++ into the opentimelineio/cxx-sdk directory under the
# python installation
cmake_install_prefix = os.path.join(
python_inst_dir,
"opentimelineio",
"cxx-sdk"
)

cmake_args += [
'-DOTIO_PYTHON_INSTALL_DIR=' + python_inst_dir,
'-DCMAKE_INSTALL_PREFIX=' + cmake_install_prefix,
]

if platform.system() == "Windows":
if sys.maxsize > 2**32:
Expand Down Expand Up @@ -369,7 +386,7 @@ def test_otio():
],
'opentimelineio_contrib': [
'adapters/contrib_adapters.plugin_manifest.json',
]
],
},

include_package_data=True,
Expand Down