From eb51c7eebbc56e3e606fde39bf3678762d99143c Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Mon, 26 Apr 2021 16:55:39 -0700 Subject: [PATCH 01/15] Adding cibuildwheel github action --- .github/workflows/python-wheels.yml | 30 +++++++++++++++++++++++++++++ pyproject.toml | 9 +++++++++ 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/python-wheels.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml new file mode 100644 index 0000000000..7e06486f73 --- /dev/null +++ b/.github/workflows/python-wheels.yml @@ -0,0 +1,30 @@ +name: Build + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, windows-2019, macOS-10.15] + + steps: + - uses: actions/checkout@v2 + + # Used to host cibuildwheel + - uses: actions/setup-python@v2 + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==1.10.0 + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + # to supply options, put them in 'env', like: + # env: + # CIBW_SOME_OPTION: value + + - uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..2eb9477bfb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel", + "ninja; sys_platform != 'win32'", + "cmake>=3.12", + "pip", +] +build-backend = "setuptools.build_meta" From d020a5dc7dcfb00ca1216011395a50104c2b96d0 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Mon, 26 Apr 2021 18:47:31 -0700 Subject: [PATCH 02/15] Restoring CMake option that installs python binding .so files into the wheel build directory --- setup.py | 5 ++++- src/py-opentimelineio/opentime-bindings/CMakeLists.txt | 4 ++++ src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 17ad76e8e9..1f17daf618 100755 --- a/setup.py +++ b/setup.py @@ -125,6 +125,9 @@ def cmake_generate(): '-DCMAKE_INSTALL_PREFIX=' + cmake_install_prefix, ] + if _ctx.ext_dir: + cmake_args.append('-DOTIO_PYTHON_OTIO_DIR=' + _ctx.ext_dir) + if platform.system() == "Windows": if sys.maxsize > 2**32: cmake_args += ['-A', 'x64'] @@ -208,7 +211,7 @@ def run(self): self.build() def build(self): - _ctx.ext_dir = os.path.abspath(self.build_lib) + _ctx.ext_dir = os.path.abspath(os.path.join(self.build_lib, "opentimelineio")) _ctx.build_temp_dir = ( os.environ.get("OTIO_CXX_BUILD_TMP_DIR") diff --git a/src/py-opentimelineio/opentime-bindings/CMakeLists.txt b/src/py-opentimelineio/opentime-bindings/CMakeLists.txt index bd92bbfa0f..1274a425de 100644 --- a/src/py-opentimelineio/opentime-bindings/CMakeLists.txt +++ b/src/py-opentimelineio/opentime-bindings/CMakeLists.txt @@ -44,3 +44,7 @@ install(TARGETS _opentime ARCHIVE DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}" LIBRARY DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}" RUNTIME DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}") + +if (OTIO_PYTHON_OTIO_DIR) + install(TARGETS _opentime DESTINATION "${OTIO_PYTHON_OTIO_DIR}") +endif (OTIO_PYTHON_OTIO_DIR) diff --git a/src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt b/src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt index f994c440d5..e5aff1f45e 100644 --- a/src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt +++ b/src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt @@ -54,6 +54,9 @@ install(TARGETS _otio LIBRARY DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}" RUNTIME DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}") +if (OTIO_PYTHON_OTIO_DIR) + install(TARGETS _otio DESTINATION "${OTIO_PYTHON_OTIO_DIR}") +endif (OTIO_PYTHON_OTIO_DIR) #------------------------------------------------------------------------------ # Install the Python scripts From 77711319d0cc73db531aeeb764be3846127ff771 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Tue, 27 Apr 2021 16:20:41 -0700 Subject: [PATCH 03/15] Revert "Restoring CMake option that installs python binding .so files into the wheel build directory" This reverts commit db960694da3d688944ac27421f8d9f24aba5828b. --- setup.py | 5 +---- src/py-opentimelineio/opentime-bindings/CMakeLists.txt | 4 ---- src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt | 3 --- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 1f17daf618..17ad76e8e9 100755 --- a/setup.py +++ b/setup.py @@ -125,9 +125,6 @@ def cmake_generate(): '-DCMAKE_INSTALL_PREFIX=' + cmake_install_prefix, ] - if _ctx.ext_dir: - cmake_args.append('-DOTIO_PYTHON_OTIO_DIR=' + _ctx.ext_dir) - if platform.system() == "Windows": if sys.maxsize > 2**32: cmake_args += ['-A', 'x64'] @@ -211,7 +208,7 @@ def run(self): self.build() def build(self): - _ctx.ext_dir = os.path.abspath(os.path.join(self.build_lib, "opentimelineio")) + _ctx.ext_dir = os.path.abspath(self.build_lib) _ctx.build_temp_dir = ( os.environ.get("OTIO_CXX_BUILD_TMP_DIR") diff --git a/src/py-opentimelineio/opentime-bindings/CMakeLists.txt b/src/py-opentimelineio/opentime-bindings/CMakeLists.txt index 1274a425de..bd92bbfa0f 100644 --- a/src/py-opentimelineio/opentime-bindings/CMakeLists.txt +++ b/src/py-opentimelineio/opentime-bindings/CMakeLists.txt @@ -44,7 +44,3 @@ install(TARGETS _opentime ARCHIVE DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}" LIBRARY DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}" RUNTIME DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}") - -if (OTIO_PYTHON_OTIO_DIR) - install(TARGETS _opentime DESTINATION "${OTIO_PYTHON_OTIO_DIR}") -endif (OTIO_PYTHON_OTIO_DIR) diff --git a/src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt b/src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt index e5aff1f45e..f994c440d5 100644 --- a/src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt +++ b/src/py-opentimelineio/opentimelineio-bindings/CMakeLists.txt @@ -54,9 +54,6 @@ install(TARGETS _otio LIBRARY DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}" RUNTIME DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}") -if (OTIO_PYTHON_OTIO_DIR) - install(TARGETS _otio DESTINATION "${OTIO_PYTHON_OTIO_DIR}") -endif (OTIO_PYTHON_OTIO_DIR) #------------------------------------------------------------------------------ # Install the Python scripts From 3e4eacaa93c9d83d8472cdaafff728e4cdbd24da Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Tue, 27 Apr 2021 16:28:23 -0700 Subject: [PATCH 04/15] Updated setup.py to have cmake install the python package to the dir specified by setuptools and allow it to handle the final install dir. This allows setuptools to handle targeting the final install using products of the intermediate install. --- setup.py | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/setup.py b/setup.py index 17ad76e8e9..3588937465 100755 --- a/setup.py +++ b/setup.py @@ -24,19 +24,10 @@ import setuptools.command.build_ext import setuptools.command.build_py from setuptools.command.install import install -from distutils.sysconfig import get_python_lib from distutils.version import LooseVersion 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 @@ -87,11 +78,7 @@ def cmake_version_check(): raise RuntimeError("CMake >= 3.12.0 is required") -# if "--user" in sys.argv: -# C++ installation should go to _ctx.install_usersite -# else -# otherwise it should go get_python_lib() -def cmake_generate(): +def cmake_generate(install_dir): cmake_args = [ '-DPYTHON_EXECUTABLE=' + sys.executable, '-DOTIO_PYTHON_INSTALL:BOOL=ON', @@ -100,28 +87,16 @@ def cmake_generate(): '-DPYBIND11_FINDPYTHON=ON', # Smart tool to find python's libs ] # https://pybind11.readthedocs.io/en/latest/compiling.html#findpython-mode - 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, + install_dir, "opentimelineio", "cxx-sdk" ) cmake_args += [ - '-DOTIO_PYTHON_INSTALL_DIR=' + python_inst_dir, + '-DOTIO_PYTHON_INSTALL_DIR=' + install_dir, '-DCMAKE_INSTALL_PREFIX=' + cmake_install_prefix, ] @@ -208,7 +183,7 @@ def run(self): self.build() def build(self): - _ctx.ext_dir = os.path.abspath(self.build_lib) + install_dir = os.path.abspath(self.build_lib) _ctx.build_temp_dir = ( os.environ.get("OTIO_CXX_BUILD_TMP_DIR") @@ -216,12 +191,12 @@ def build(self): ) _ctx.debug = self.debug or bool(os.environ.get("OTIO_CXX_DEBUG_BUILD")) - if not _ctx.ext_dir.endswith(os.path.sep): - _ctx.ext_dir += os.path.sep + if not install_dir.endswith(os.path.sep): + install_dir += os.path.sep if not os.path.exists(_ctx.build_temp_dir): os.makedirs(_ctx.build_temp_dir) - cmake_generate() + cmake_generate(install_dir) cmake_install('Debug' if _ctx.debug else 'Release') From c1e0754a0a58bcfd0d9ee1231cfad90392ecdf35 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Tue, 27 Apr 2021 16:31:26 -0700 Subject: [PATCH 05/15] removed ninja from pyproject.toml dependencies (this was carried over from somewhere else) and trued up setuptools and pip with the versions enforced in setup.py --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2eb9477bfb..efd07fcec9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,8 @@ [build-system] requires = [ - "setuptools>=42", + "setuptools>=20.5.0", "wheel", - "ninja; sys_platform != 'win32'", "cmake>=3.12", - "pip", + "pip>=6.0.0", ] build-backend = "setuptools.build_meta" From 79480bf37e6b45955e8128a753ea05f1cfa47c58 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Tue, 27 Apr 2021 16:36:26 -0700 Subject: [PATCH 06/15] Temporarily disabled python 2.7 builds on windows due to known issue with 32/64-bit issues. --- .github/workflows/python-wheels.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml index 7e06486f73..d88a18fcd8 100644 --- a/.github/workflows/python-wheels.yml +++ b/.github/workflows/python-wheels.yml @@ -21,9 +21,10 @@ jobs: - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse - # to supply options, put them in 'env', like: - # env: - # CIBW_SOME_OPTION: value + # TODO: Solve for the 32-bit errors in windows python 2.7: + # https://github.com/pybind/cmake_example/blob/master/.github/workflows/wheels.yml#L66 + env: + CIBW_SKIP: cp27-win* - uses: actions/upload-artifact@v2 with: From bea2f14512965407d3e8370ab8b0002713c902bd Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Tue, 27 Apr 2021 16:43:52 -0700 Subject: [PATCH 07/15] Disabling Windows to defer troubleshooting issues on that platform initially --- .github/workflows/python-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml index d88a18fcd8..5abb83efb7 100644 --- a/.github/workflows/python-wheels.yml +++ b/.github/workflows/python-wheels.yml @@ -8,7 +8,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macOS-10.15] + os: [ubuntu-20.04, macOS-10.15] steps: - uses: actions/checkout@v2 From ae136547fa8907d855ce6c4147340a1d474d3757 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Tue, 27 Apr 2021 18:52:29 -0700 Subject: [PATCH 08/15] Refactored setup.py to remove global _ctx object, simplify, and make behavior more explicit --- setup.py | 188 ++++++++++++++++++++++--------------------------------- 1 file changed, 76 insertions(+), 112 deletions(-) diff --git a/setup.py b/setup.py index 3588937465..99b888ceb5 100755 --- a/setup.py +++ b/setup.py @@ -23,24 +23,10 @@ import setuptools.command.build_ext import setuptools.command.build_py -from setuptools.command.install import install from distutils.version import LooseVersion import distutils - -class _Ctx(object): - pass - - -_ctx = _Ctx() -_ctx.cxx_install_root = None -_ctx.cxx_coverage = False -_ctx.build_temp_dir = None -_ctx.installed = False -_ctx.ext_dir = None -_ctx.source_dir = os.path.abspath(os.path.dirname(__file__)) -_ctx.install_usersite = '' -_ctx.debug = False +SOURCE_DIR = os.path.abspath(os.path.dirname(__file__)) INSTALL_REQUIRES = [ @@ -78,126 +64,105 @@ def cmake_version_check(): raise RuntimeError("CMake >= 3.12.0 is required") -def cmake_generate(install_dir): - cmake_args = [ - '-DPYTHON_EXECUTABLE=' + sys.executable, - '-DOTIO_PYTHON_INSTALL:BOOL=ON', - '-DOTIO_CXX_INSTALL:BOOL=ON', - '-DCMAKE_BUILD_TYPE=' + ('Debug' if _ctx.debug else 'Release'), - '-DPYBIND11_FINDPYTHON=ON', # Smart tool to find python's libs - ] # https://pybind11.readthedocs.io/en/latest/compiling.html#findpython-mode - - # install the C++ into the opentimelineio/cxx-sdk directory under the - # python installation - cmake_install_prefix = os.path.join( - install_dir, - "opentimelineio", - "cxx-sdk" - ) - - cmake_args += [ - '-DOTIO_PYTHON_INSTALL_DIR=' + install_dir, - '-DCMAKE_INSTALL_PREFIX=' + cmake_install_prefix, - ] - - if platform.system() == "Windows": - if sys.maxsize > 2**32: - cmake_args += ['-A', 'x64'] - - if _ctx.cxx_coverage and not os.environ.get("OTIO_CXX_BUILD_TMP_DIR"): - raise RuntimeError( - "C++ code coverage requires that both OTIO_CXX_COVERAGE_BUILD=ON " - "and OTIO_CXX_BUILD_TMP_DIR are specified as environment " - "variables, otherwise coverage cannot be generated." - ) - - if _ctx.cxx_coverage: - cmake_args += ['-DOTIO_CXX_COVERAGE=1'] - - cmake_args = ['cmake', _ctx.source_dir] + cmake_args - subprocess.check_call( - cmake_args, - cwd=_ctx.build_temp_dir, - env=os.environ.copy() - ) - - -# cfg should be Debug or Release -def cmake_install(cfg): - if platform.system() == "Windows": - multi_proc = '/m' - else: - multi_proc = '-j2' - - subprocess.check_call( - ['cmake', '--build', '.', - '--target', 'install', - '--config', cfg, - '--', multi_proc], - cwd=_ctx.build_temp_dir, - env=os.environ.copy() - ) - - def _debugInstance(x): for a in sorted(dir(x)): print("%s: %s" % (a, getattr(x, a))) -class OTIO_install(install): - user_options = install.user_options + [ - ( - 'cxx-install-root=', - None, - 'Root directory for installing C++ headers/libraries' - ' (required if you want to develop in C++)' - ), - ] - - def initialize_options(self): - self.cxx_install_root = "" - install.initialize_options(self) - - def run(self): - _ctx.cxx_install_root = self.cxx_install_root - _ctx.install_usersite = self.install_usersite - install.run(self) - - class CMakeExtension(Extension): def __init__(self, name): Extension.__init__(self, name, sources=[]) class OTIO_build_ext(setuptools.command.build_ext.build_ext): + """ def initialize_options(self): - self.cxx_coverage = False - setuptools.command.build_ext.build_ext.initialize_options(self) + super(setuptools.command.build_ext.build_ext, self).initialize_options() + """ def run(self): - _ctx.cxx_coverage = ( - self.cxx_coverage is not False - or bool(os.environ.get("OTIO_CXX_COVERAGE_BUILD")) - ) - + # This works around the fact that we build _opentime and _otio + # extensions as a one-shot cmake invocation. Usually we'd build each + # separate using build_extension. self.build() def build(self): - install_dir = os.path.abspath(self.build_lib) - - _ctx.build_temp_dir = ( + self.build_temp_dir = ( os.environ.get("OTIO_CXX_BUILD_TMP_DIR") or os.path.abspath(self.build_temp) ) - _ctx.debug = self.debug or bool(os.environ.get("OTIO_CXX_DEBUG_BUILD")) + if not os.path.exists(self.build_temp_dir): + os.makedirs(self.build_temp_dir) + + debug = (self.debug or bool(os.environ.get("OTIO_CXX_DEBUG_BUILD"))) + self.build_config = ('Debug' if debug else 'Release') + + self.cmake_generate() + self.cmake_install() + + def cmake_generate(self): + # Determine the target directory for the built library + install_dir = os.path.abspath(self.build_lib) if not install_dir.endswith(os.path.sep): install_dir += os.path.sep - if not os.path.exists(_ctx.build_temp_dir): - os.makedirs(_ctx.build_temp_dir) - cmake_generate(install_dir) - cmake_install('Debug' if _ctx.debug else 'Release') + cmake_args = [ + '-DPYTHON_EXECUTABLE=' + sys.executable, + '-DOTIO_PYTHON_INSTALL:BOOL=ON', + '-DOTIO_CXX_INSTALL:BOOL=ON', + '-DCMAKE_BUILD_TYPE=' + self.build_config, '-DPYBIND11_FINDPYTHON=ON', # Smart tool to find python's libs + ] # https://pybind11.readthedocs.io/en/latest/compiling.html#findpython-mode + + # install the C++ into the opentimelineio/cxx-sdk directory under the + # python installation + cmake_install_prefix = os.path.join( + install_dir, + "opentimelineio", + "cxx-sdk" + ) + + cmake_args += [ + '-DOTIO_PYTHON_INSTALL_DIR=' + install_dir, + '-DCMAKE_INSTALL_PREFIX=' + cmake_install_prefix, + ] + + if platform.system() == "Windows": + if sys.maxsize > 2**32: + cmake_args += ['-A', 'x64'] + + cxx_coverage = bool(os.environ.get("OTIO_CXX_COVERAGE_BUILD")) + if cxx_coverage and not os.environ.get("OTIO_CXX_BUILD_TMP_DIR"): + raise RuntimeError( + "C++ code coverage requires that both OTIO_CXX_COVERAGE_BUILD=ON " + "and OTIO_CXX_BUILD_TMP_DIR are specified as environment " + "variables, otherwise coverage cannot be generated." + ) + + if cxx_coverage: + cmake_args += ['-DOTIO_CXX_COVERAGE=1'] + + cmake_args = ['cmake', SOURCE_DIR] + cmake_args + subprocess.check_call( + cmake_args, + cwd=self.build_temp_dir, + env=os.environ.copy() + ) + + def cmake_install(self): + if platform.system() == "Windows": + multi_proc = '/m' + else: + multi_proc = '-j2' + + subprocess.check_call( + ['cmake', '--build', '.', + '--target', 'install', + '--config', self.build_config, + '--', multi_proc], + cwd=self.build_temp_dir, + env=os.environ.copy() + ) # Make sure the environment contains an up to date enough version of pip. @@ -448,7 +413,6 @@ def test_otio(): # installation root. cmdclass={ - 'install': OTIO_install, 'build_py': OTIO_build_py, 'build_ext': OTIO_build_ext, }, From b72a1feac2af98b9fc1256b7368269efbeda1fa3 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Wed, 28 Apr 2021 10:05:43 -0700 Subject: [PATCH 09/15] Removing wheel building to narrow down to just the setup.py refactor. --- .github/workflows/python-wheels.yml | 31 ----------------------------- pyproject.toml | 8 -------- 2 files changed, 39 deletions(-) delete mode 100644 .github/workflows/python-wheels.yml delete mode 100644 pyproject.toml diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml deleted file mode 100644 index 5abb83efb7..0000000000 --- a/.github/workflows/python-wheels.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Build - -on: [push, pull_request] - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04, macOS-10.15] - - steps: - - uses: actions/checkout@v2 - - # Used to host cibuildwheel - - uses: actions/setup-python@v2 - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==1.10.0 - - - name: Build wheels - run: python -m cibuildwheel --output-dir wheelhouse - # TODO: Solve for the 32-bit errors in windows python 2.7: - # https://github.com/pybind/cmake_example/blob/master/.github/workflows/wheels.yml#L66 - env: - CIBW_SKIP: cp27-win* - - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index efd07fcec9..0000000000 --- a/pyproject.toml +++ /dev/null @@ -1,8 +0,0 @@ -[build-system] -requires = [ - "setuptools>=20.5.0", - "wheel", - "cmake>=3.12", - "pip>=6.0.0", -] -build-backend = "setuptools.build_meta" From ec6996d4d3f72f289b8194287956f5fb05075084 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Wed, 28 Apr 2021 10:36:03 -0700 Subject: [PATCH 10/15] Addressed lint issue --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 99b888ceb5..655bd233a5 100755 --- a/setup.py +++ b/setup.py @@ -111,7 +111,8 @@ def cmake_generate(self): '-DPYTHON_EXECUTABLE=' + sys.executable, '-DOTIO_PYTHON_INSTALL:BOOL=ON', '-DOTIO_CXX_INSTALL:BOOL=ON', - '-DCMAKE_BUILD_TYPE=' + self.build_config, '-DPYBIND11_FINDPYTHON=ON', # Smart tool to find python's libs + '-DCMAKE_BUILD_TYPE=' + self.build_config, + '-DPYBIND11_FINDPYTHON=ON', # Smart tool to find python's libs ] # https://pybind11.readthedocs.io/en/latest/compiling.html#findpython-mode # install the C++ into the opentimelineio/cxx-sdk directory under the From fc61b798a9e994d18b5b3fba9db0a57a23ed6a63 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Wed, 28 Apr 2021 10:47:02 -0700 Subject: [PATCH 11/15] Fixed typo in setup.py comments --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 655bd233a5..f888877c9c 100755 --- a/setup.py +++ b/setup.py @@ -83,7 +83,7 @@ def initialize_options(self): def run(self): # This works around the fact that we build _opentime and _otio # extensions as a one-shot cmake invocation. Usually we'd build each - # separate using build_extension. + # separately using build_extension. self.build() def build(self): From 43e586d4ca6a2cf441f29ce8ac65adf2028d3e74 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Wed, 28 Apr 2021 11:00:08 -0700 Subject: [PATCH 12/15] updated -j arg for build invoked by setup.py to be the system cpu count vs. always being 2 --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f888877c9c..ed710d2440 100755 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ - http://opentimeline.io """ +import multiprocessing import os import re import sys @@ -154,7 +155,7 @@ def cmake_install(self): if platform.system() == "Windows": multi_proc = '/m' else: - multi_proc = '-j2' + multi_proc = '-j{}'.format(multiprocessing.cpu_count()) subprocess.check_call( ['cmake', '--build', '.', From b0d19b61793e0da4169514cc82553d53c10757d4 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Wed, 28 Apr 2021 11:12:20 -0700 Subject: [PATCH 13/15] Removed setuptools and pip version checks --- setup.py | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/setup.py b/setup.py index ed710d2440..84d135e7fc 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,6 @@ import platform import subprocess import unittest -import pip from setuptools import ( setup, @@ -25,7 +24,6 @@ import setuptools.command.build_ext import setuptools.command.build_py from distutils.version import LooseVersion -import distutils SOURCE_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -167,47 +165,6 @@ def cmake_install(self): ) -# Make sure the environment contains an up to date enough version of pip. -PIP_VERSION = pip.__version__ -REQUIRED_PIP_VERSION = "6.0.0" -if ( - distutils.version.LooseVersion(PIP_VERSION) - <= distutils.version.LooseVersion(REQUIRED_PIP_VERSION) -): - sys.stderr.write( - "Your pip version is: '{}', OpenTimelineIO requires at least " - "version '{}'. Please update pip by running:\n" - "pip install -U pip\n".format( - PIP_VERSION, - REQUIRED_PIP_VERSION, - ) - ) - sys.exit(1) - - -# Make sure the environment contains an up to date enough version of setuptools. -try: - import setuptools.version - SETUPTOOLS_VERSION = setuptools.version.__version__ -except ImportError: - SETUPTOOLS_VERSION = setuptools.__version__ - -REQUIRED_SETUPTOOLS_VERSION = '20.5.0' -if ( - distutils.version.LooseVersion(SETUPTOOLS_VERSION) - <= distutils.version.LooseVersion(REQUIRED_SETUPTOOLS_VERSION) -): - sys.stderr.write( - "Your setuptools version is: '{}', OpenTimelineIO requires at least " - "version '{}'. Please update setuptools by running:\n" - "pip install -U setuptools\n".format( - SETUPTOOLS_VERSION, - REQUIRED_SETUPTOOLS_VERSION, - ) - ) - sys.exit(1) - - # check the python version first if ( sys.version_info[0] < 2 or From e86982883c2f4c39f3ba7853ea4336e2517db99f Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Wed, 28 Apr 2021 14:43:15 -0700 Subject: [PATCH 14/15] Addressed list formatting to better match codebase conventions. --- setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 84d135e7fc..f3f8c362c5 100755 --- a/setup.py +++ b/setup.py @@ -156,10 +156,13 @@ def cmake_install(self): multi_proc = '-j{}'.format(multiprocessing.cpu_count()) subprocess.check_call( - ['cmake', '--build', '.', + [ + 'cmake', + '--build', '.', '--target', 'install', '--config', self.build_config, - '--', multi_proc], + '--', multi_proc, + ], cwd=self.build_temp_dir, env=os.environ.copy() ) From a576a8a1d9678ec988af4b9784f8261964c06a46 Mon Sep 17 00:00:00 2001 From: Eric Reinecke Date: Wed, 28 Apr 2021 17:17:53 -0700 Subject: [PATCH 15/15] Updated comment in setup.py about determining install location to better clarify intent for our future selves --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f3f8c362c5..6dacc23733 100755 --- a/setup.py +++ b/setup.py @@ -101,7 +101,8 @@ def build(self): self.cmake_install() def cmake_generate(self): - # Determine the target directory for the built library + # Use the provided build dir so setuptools will be able to locate and + # either install to the correct location or package. install_dir = os.path.abspath(self.build_lib) if not install_dir.endswith(os.path.sep): install_dir += os.path.sep