From 0cf3176462db28e7cfed33250cb1a372d3b65492 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Wed, 15 Dec 2021 10:34:22 -0600 Subject: open3d: add new package (#27577) --- var/spack/repos/builtin/packages/imgui/package.py | 24 +++++ var/spack/repos/builtin/packages/liblzf/package.py | 19 ++++ var/spack/repos/builtin/packages/open3d/package.py | 113 +++++++++++++++++++++ .../repos/builtin/packages/tinygltf/package.py | 17 ++++ .../builtin/packages/tinyobjloader/package.py | 17 ++++ 5 files changed, 190 insertions(+) create mode 100644 var/spack/repos/builtin/packages/imgui/package.py create mode 100644 var/spack/repos/builtin/packages/liblzf/package.py create mode 100644 var/spack/repos/builtin/packages/open3d/package.py create mode 100644 var/spack/repos/builtin/packages/tinygltf/package.py create mode 100644 var/spack/repos/builtin/packages/tinyobjloader/package.py diff --git a/var/spack/repos/builtin/packages/imgui/package.py b/var/spack/repos/builtin/packages/imgui/package.py new file mode 100644 index 0000000000..833a04a6f2 --- /dev/null +++ b/var/spack/repos/builtin/packages/imgui/package.py @@ -0,0 +1,24 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class Imgui(Package): + """Dear ImGui is a bloat-free graphical user interface library for C++. + + It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline + enabled application. It is fast, portable, renderer agnostic and self-contained + (no external dependencies).""" + + homepage = "https://github.com/ocornut/imgui" + url = "https://github.com/ocornut/imgui/archive/refs/tags/v1.85.tar.gz" + + version('1.85', sha256='7ed49d1f4573004fa725a70642aaddd3e06bb57fcfe1c1a49ac6574a3e895a77') + + def install(self, spec, prefix): + # No specific build process is required. + # You can add the .cpp files to your existing project. + install_tree('.', prefix) diff --git a/var/spack/repos/builtin/packages/liblzf/package.py b/var/spack/repos/builtin/packages/liblzf/package.py new file mode 100644 index 0000000000..35c0bcc2ad --- /dev/null +++ b/var/spack/repos/builtin/packages/liblzf/package.py @@ -0,0 +1,19 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class Liblzf(AutotoolsPackage): + """LibLZF is a very small data compression library. + + It consists of only two .c and two .h files and is very easy to incorporate into + your own programs. The compression algorithm is very, very fast, yet still written + in portable C.""" + + homepage = "http://oldhome.schmorp.de/marc/liblzf.html" + url = "http://dist.schmorp.de/liblzf/liblzf-3.6.tar.gz" + + version('3.6', sha256='9c5de01f7b9ccae40c3f619d26a7abec9986c06c36d260c179cedd04b89fb46a') diff --git a/var/spack/repos/builtin/packages/open3d/package.py b/var/spack/repos/builtin/packages/open3d/package.py new file mode 100644 index 0000000000..468f89d869 --- /dev/null +++ b/var/spack/repos/builtin/packages/open3d/package.py @@ -0,0 +1,113 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +import os + +from spack import * + + +class Open3d(CMakePackage, CudaPackage): + """Open3D: A Modern Library for 3D Data Processing.""" + + homepage = "http://www.open3d.org/" + url = "https://github.com/isl-org/Open3D/archive/refs/tags/v0.13.0.tar.gz" + git = "https://github.com/isl-org/Open3D.git" + + version('0.13.0', tag='v0.13.0', submodules=True) + + variant('python', default=False, description='Build the Python module') + + # http://www.open3d.org/docs/latest/compilation.html + + depends_on('cmake@3.19:', type='build') + # depends_on('eigen') + # depends_on('flann') + # depends_on('fmt') + # depends_on('glew') + # depends_on('glfw') + # depends_on('imgui') + # depends_on('jpeg') + # depends_on('liblzf') + # depends_on('libpng') + # depends_on('py-pybind11') + # depends_on('qhull') + # depends_on('tinygltf') + # depends_on('tinyobjloader') + + extends('python', when='+python', type=('build', 'link', 'run')) + depends_on('python@3.6:', when='+python', type=('build', 'link', 'run')) + depends_on('py-pip', when='+python', type='build') + depends_on('py-setuptools@40.8:', when='+python', type='build') + depends_on('py-wheel@0.36:', when='+python', type='build') + depends_on('py-numpy@1.18:', when='+python', type=('build', 'run')) + depends_on('py-pytest', when='+python', type='test') + depends_on('cuda@10.1:', when='+cuda') + + # C++14 compiler required + conflicts('%gcc@:4') + conflicts('%clang@:6') + + def patch(self): + # Force Python libraries to be installed to self.prefix + filter_file('pip install', 'pip install --prefix ' + self.prefix, + os.path.join('cpp', 'pybind', 'make_install_pip_package.cmake')) + + def cmake_args(self): + args = [ + self.define('BUILD_UNIT_TESTS', self.run_tests), + self.define_from_variant('BUILD_PYTHON_MODULE', 'python'), + self.define_from_variant('BUILD_CUDA_MODULE', 'cuda'), + # Use Spack-installed dependencies instead of vendored dependencies + # Numerous issues with using externally installed dependencies: + # https://github.com/isl-org/Open3D/issues/4333 + # https://github.com/isl-org/Open3D/issues/4360 + # self.define('USE_SYSTEM_EIGEN3', True), + # self.define('USE_SYSTEM_FLANN', True), + # self.define('USE_SYSTEM_FMT', True), + # self.define('USE_SYSTEM_GLEW', True), + # self.define('USE_SYSTEM_GLFW', True), + # self.define('USE_SYSTEM_IMGUI', True), + # self.define('USE_SYSTEM_JPEG', True), + # self.define('USE_SYSTEM_LIBLZF', True), + # self.define('USE_SYSTEM_PNG', True), + # self.define('USE_SYSTEM_PYBIND11', True), + # self.define('USE_SYSTEM_QHULL', True), + # self.define('USE_SYSTEM_TINYGLTF', True), + # self.define('USE_SYSTEM_TINYOBJLOADER', True), + ] + + if '+python' in self.spec: + args.append( + self.define('PYTHON_EXECUTABLE', self.spec['python'].command.path)) + + return args + + def check(self): + with working_dir(self.build_directory): + tests = Executable(os.path.join('bin', 'tests')) + tests() + + def install(self, spec, prefix): + with working_dir(self.build_directory): + make('install') + if '+python' in spec: + make('install-pip-package') + + # Tests don't pass unless all optional features are compiled, including PyTorch + # @run_after('install') + # @on_package_attributes(run_tests=True) + # def unit_test(self): + # if '+python' in self.spec: + # pytest = which('pytest') + # pytest(os.path.join('python', 'test')) + + @run_after('install') + @on_package_attributes(run_tests=True) + def test(self): + if '+python' in self.spec: + self.run_test(self.spec['python'].command.path, + ['-c', 'import open3d'], + purpose='checking import of open3d', + work_dir='spack-test') diff --git a/var/spack/repos/builtin/packages/tinygltf/package.py b/var/spack/repos/builtin/packages/tinygltf/package.py new file mode 100644 index 0000000000..7c752db898 --- /dev/null +++ b/var/spack/repos/builtin/packages/tinygltf/package.py @@ -0,0 +1,17 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class Tinygltf(CMakePackage): + """Header only C++11 tiny glTF 2.0 library.""" + + homepage = "https://github.com/syoyo/tinygltf" + url = "https://github.com/syoyo/tinygltf/archive/refs/tags/v2.5.0.tar.gz" + + version('2.5.0', sha256='5d85bd556b60b1b69527189293cfa4902957d67fabb8582b6532f23a5ef27ec1') + + depends_on('cmake@3.6:', type='build') diff --git a/var/spack/repos/builtin/packages/tinyobjloader/package.py b/var/spack/repos/builtin/packages/tinyobjloader/package.py new file mode 100644 index 0000000000..2ce32e29dc --- /dev/null +++ b/var/spack/repos/builtin/packages/tinyobjloader/package.py @@ -0,0 +1,17 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class Tinyobjloader(CMakePackage): + """Tiny but powerful single file wavefront obj loader.""" + + homepage = "https://github.com/tinyobjloader/tinyobjloader" + url = "https://github.com/tinyobjloader/tinyobjloader/archive/refs/tags/v1.0.6.tar.gz" + + version('1.0.6', sha256='19ee82cd201761954dd833de551edb570e33b320d6027e0d91455faf7cd4c341') + + depends_on('cmake@2.8.11:', type='build') -- cgit v1.2.3-70-g09d2