Blob Blame History Raw
Name:           python-trimesh
Version:        3.9.34
Release:        1%{?dist}
Summary:        Import, export, process, analyze and view triangular meshes

# The entire source is MIT, except:
#
# BSD:
#   - trimesh/transformations.py
# zlib:
#   - trimesh/exchange/openctm.py
License:        MIT and BSD and zlib
URL:            https://trimsh.org

Source0:        https://github.com/mikedh/trimesh/archive/%{version}/trimesh-%{version}.tar.gz

# The odd combination of an arched package with only noarch binary packages
# makes it easier for us to detect with arch-dependent test failures, since the
# tests will always be run on every platform, and easier for us to skip failing
# tests if necessary, since we can be sure that %%ifarch macros work as
# expected.
#
# Since the package still contains no compiled machine code, we still have no
# debuginfo.
%global debug_package %{nil}

# Turn off automatic python byte-compilation. One .py file,
# trimesh/resources/templates/blender_boolean.py, is actually a *template for a
# Python source* rather than an *actual Python source*, and trying to
# byte-compile it will break the build. We will byte-compile manually instead.
%undefine __brp_python_bytecompile

BuildRequires:  python3-devel

# Workaround: https://bugzilla.redhat.com/show_bug.cgi?id=2006090
# python-Rtree does not work on s390x without spatialindex-devel
BuildRequires:  spatialindex-devel

# Meshlab Server Does Not Work With XVFB
# https://github.com/cnr-isti-vclab/meshlab/issues/237
# Upstream closed as WONTFIX
#BuildRequires:  /usr/bin/xvfb-run
#BuildRequires:  /usr/bin/meshlabserver

%global _description %{expand:
Trimesh is a pure Python library for loading and using triangular meshes with
an emphasis on watertight meshes. The goal of the library is to provide a fully
featured and well tested Trimesh object which allows for easy manipulation and
analysis, in the style of the Polygon object in the Shapely library.}

%description %{_description}


%package -n     python3-trimesh
Summary:        %{summary}
BuildArch:      noarch

# Workaround: https://bugzilla.redhat.com/show_bug.cgi?id=2006090
# python-Rtree does not work on s390x without spatialindex-devel
#
# This adds an otherwise-unnecessary dependency on other architectures, but the
# alternative would be to make this package arched and use %%ifarch to add the
# dependency. We do not want to do that.
Requires:       (spatialindex-devel if python3dist(rtree))

Recommends:     python3-trimesh+easy = %{version}-%{release}
Suggests:       python3-trimesh+all = %{version}-%{release}

# for trimesh.boolean
Recommends:     openscad
Recommends:     blender

# This probably should be in [easy] extra but isn’t in the metadata at all; see
# README.rst and trimesh/ray/. However, it cannot be packaged until it supports
# the current version (3.x) of embree
# (https://github.com/scopatz/pyembree/issues/28).
#Recommends:     python3dist(pyembree)

%description -n python3-trimesh %{_description}


%if 0%{?fedora} && 0%{?fedora} > 38
%pyproject_extras_subpkg -n python3-trimesh easy all
%else
# We base these extras metapackages
# (https://fedoraproject.org/wiki/Changes/PythonExtras#Extras_metapackages)
# on the expansion of:
#
#   %%pyproject_extras_subpkg -n python3-trimesh easy all
#
# but add Provides/Obsoletes for the corresponding old subpackages to provide a
# clean upgrade path.

%package -n python3-trimesh+easy
Summary:        Metapackage for python3-trimesh: easy extras
BuildArch:      noarch

Requires:       python3-trimesh = %{version}-%{release}

Provides:       python3-trimesh-easy = %{version}-%{release}
Obsoletes:      python3-trimesh-easy < 3.9.20-4

%description -n python3-trimesh+easy
This is a metapackage bringing in easy extras requires for python3-trimesh.
It makes sure the dependencies are installed.

%files -n python3-trimesh+easy -f %{_pyproject_ghost_distinfo}

%package -n python3-trimesh+all
Summary:        Metapackage for python3-trimesh: all extras
BuildArch:      noarch

Requires:       python3-trimesh = %{version}-%{release}

Provides:       python3-trimesh-all = %{version}-%{release}
Obsoletes:      python3-trimesh-all < 3.9.20-4

%description -n python3-trimesh+all
This is a metapackage bringing in all extras requires for python3-trimesh.
It makes sure the dependencies are installed.

%files -n python3-trimesh+all -f %{_pyproject_ghost_distinfo}
%endif


# We elect not to build a documentation package, for the following reasons:
#
#  1. A (relatively simple) patch is required to build them offline without
#     pip-installing requirements from PyPI.
#  2. The documentation includes notebooks translated to HTML from .ipynb
#     using nbconvert.
#      a. Some conversions fail (wholly or on a per-cell basis, if continuing
#         on errors is requested) in architecture-dependent ways. This means
#         that the contents of the documentation package would depend on the
#         builder architecture, and it could not be noarch—an undesirable
#         situation.
#      b. An “HTML-ified” notebook contains a blob of JavaScript and other
#         web assets that is exceptionally difficult (at best, tedious) to
#         account for under current bundling guidelines.
#  3. Sphinx-generated HTML documentation is not suitable for packaging in
#     general—see https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for
#     discussion—and (because of the notebooks, if nothing else) the trimesh
#     documentation is not well-suited to building as a PDF instead of HTML.


%prep
%autosetup -n trimesh-%{version}

# Patch out unavailable dependencies from “extras”:
#
# [all]
#   glooey: not yet packaged, https://github.com/kxgames/glooey; needs autoprop
#           (https://github.com/kalekundert/autoprop) and vecrec
#           (https://github.com/kxgames/vecrec)
sed -r -i "/^[[:blank:]]*'glooey',/d" setup.py
#   mapbox-earcut: not yet packaged,
#                  https://github.com/skogler/mapbox_earcut_python; needs
#                  https://github.com/mapbox/earcut.hpp, review request:
#                  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2006590
sed -r -i "/^[[:blank:]]*'mapbox-earcut',/d" setup.py
#   meshio: not yet packaged, https://github.com/nschloe/meshio
sed -r -i "/^[[:blank:]]*'meshio',/d" setup.py
#   python-fcl: not yet packaged; upstream is not compatible with the current
#               release of fcl,
#               https://github.com/BerkeleyAutomation/python-fcl/issues/19
sed -r -i "/^[[:blank:]]*'python-fcl',/d" setup.py
#   triangle: has a nonfree dependency (Jonathan Richard Shewchuk’s “Triangle”
#             library, http://www.cs.cmu.edu/~quake/triangle.html, which
#             forbids commercial usage) so cannot be packaged
sed -r -i "/^[[:blank:]]*'triangle',/d" setup.py
#   xatlas: not yet packaged, https://github.com/mworchel/xatlas-python;
#           depends on https://github.com/jpcy/xatlas, also not yet packaged
sed -r -i "/^[[:blank:]]*'xatlas',/d" setup.py

# Patch out unavailable pyinstrument test dependency; we don’t really need to
# do profiling anyway. Note that this does mean that API function
# trimesh.viewer.windowed.SceneViewer(…) will not work with “profile=True”.
#
# Packaging pyinstrument would be difficult due to a vue.js-based HTML
# renderer. Since guidelines forbid pre-built minified or compiled JS or CSS,
# this would have to be patched out, or the web asset pipeline would have to be
# somehow executed in the RPM build environment. (Or, of course, we can
# continue to do without pyinstrument.)
sed -r -i "/'pyinstrument',/d" setup.py
sed -r -i 's/^([[:blank:]]*)(.*(pyinstrument|profiler)\b)/\1# \2/' \
    tests/regression.py

# Currently, python-ezdxf (https://pypi.org/project/ezdxf/,
# https://github.com/mozman/ezdxf) is not packaged. The tests are designed to
# fall back gracefully without it, but we must not generate the BuildRequires.
sed -r -i "s/'ezdxf'(\\]\\))/\\1/" setup.py


%generate_buildrequires
%pyproject_buildrequires -x test,all


%build
%pyproject_wheel


%install
%pyproject_install
# Manual byte-compile, to skip that one troublesome “.py” template file:
find '%{buildroot}%{python3_sitelib}/trimesh' -type f \
    -name '*.py' ! -name 'blender_boolean.py' |
  while read -r pyfile
  do
    %py_byte_compile %{__python3} "${pyfile}"
  done
# Cannot handle skipping byte-compilation for blender_boolean.py:
#pyproject_save_files trimesh


%check
while read -r t
do
  k="${k-}${k+ and }not ($(sed -r 's/::/ and /' <<<"${t}"))"
done < <(sed -r '/^[[:blank:]]*($|#)/d' <<'EOF'
%ifnarch x86_64
# CacheTest.test_hash fails, or may fail, because xxhash is not faster than CRC
# and/or MD5.
#
# This is not as intended, and upstream might or might not care, but it’s only
# a performance defect, so we just skip the test here.
CacheTest::test_hash
%endif

%ifarch s390x
# Several test failures remain on s390x. For now, we choose to skip these tests
# rather than excluding the architecture, even though they certainly represent
# real defects.
#
# https://github.com/mikedh/trimesh/issues/1351
# https://github.com/mikedh/trimesh/files/7385479/test-failures.log
GLTFTest::test_export_custom_attributes
OBJTest::test_vertex_color
PermutateTest::test_permutate
PlyTest::test_face_attributes
PlyTest::test_vertex_attributes
%endif

# 32-bit problems:
# https://github.com/mikedh/trimesh/issues/690
# https://github.com/mikedh/trimesh/files/7389423/test-failures.log

# E           TypeError: Cannot cast array data from dtype('int64') to
#                        dtype('int32') according to the rule 'safe'
%ifarch %{ix86} %{arm32}
BinvoxTest::test_load_save_invariance
BoundsTest::test_bounding_egg
ContainsTest::test_inside
EncodingTest::test_composite
EncodingTest::test_dense
EncodingTest::test_flat
EncodingTest::test_flipped
EncodingTest::test_reshape
EncodingTest::test_transpose
NearestTest::test_coplanar_signed_distance
RayTests::test_contains
RayTests::test_on_edge
RayTests::test_on_vertex
RleTest::test_brle_encode_decode
RleTest::test_brle_length
RleTest::test_brle_logical_not
RleTest::test_brle_to_dense
RleTest::test_brle_to_rle
RleTest::test_rle_encode_decode
VoxelGridTest::test_local
%endif
%ifarch %{ix86}
PrimitiveTest::test_cyl_buffer
%endif

# Either MemoryError or numpy.core._exceptions._ArrayMemoryError:
%ifarch %{ix86} %{arm32}
GLTFTest::test_basic
GLTFTest::test_merge_buffers
MutateTests::test_not_mutated_cube
RayTests::test_contain_single
SubDivideTest::test_subdivide
SceneTests::test_scene
%endif
%ifarch %{arm32}
ExportTest::test_svg
IdentifierTest::test_scene_id
IntegralMeanCurvatureTest::test_IMCcapsule
LoaderTest::test_fileobj
MedialTests::test_medial
MeshTests::test_meshes
MinimalTest::test_load
MutateTests::test_not_mutated_bunny
MutateTests::test_not_mutated_teapot
MutateTests::test_not_mutated_torus
NSphereTest::test_minball
NearestTest::test_helper
NearestTest::test_naive
OBJTest::test_export_path
OBJTest::test_scene
OpTest::test_add
PermutateTest::test_base
PermutateTest::test_permutate
PermutateTest::test_tesselation
PrimitiveTest::test_primitives
RasterTest::test_rasterize
RayTests::test_box
RayTests::test_multiple_hits
RayTests::test_rays
RayTests::test_rps
RenderTest::test_args
RepairTests::test_fix_normals
SampleTest::test_sample
SampleTest::test_weights
SceneTests::test_doubling
SceneTests::test_scaling
SceneTests::test_tri
SplitTest::test_split
SubDivideTest::test_sub
SubDivideTest::test_uv
TextureTest::test_fuze
TransformTest::test_tiny
TrianglesTest::test_barycentric
UnitsTest::test_conversion
UnitsTest::test_path
VectorTests::test_color
VectorTests::test_discrete
VectorTests::test_poly
VectorTests::test_text
VerticesTest::test_vertex_faces
VoxelGridTest::test_voxel
SceneTests::test_empty
%endif
EOF
)

%pytest -v -k "${k-}"


%files -n python3-trimesh
%license LICENSE.md
%doc README.md
# %%pyproject_save_files cannot handle skipping byte-compilation for
# blender_boolean.py, so we list files manually:
%{python3_sitelib}/trimesh
%{python3_sitelib}/trimesh-%{version}.dist-info


%changelog
* Wed Oct 20 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.9.34-1
- Update to 3.9.34
- Use pyproject-rpm-macros
- Update metapackages for PythonExtras Change
  (https://fedoraproject.org/wiki/Changes/PythonExtras#Extras_metapackages)
- [easy] and [all] extras now require python3dist(xxhash)
- Handle arch-specific test failures methodically
- Update/correct license from “MIT” to “MIT and BSD and zlib”

* Tue Jul 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.9.20-3
- Second attempt - Rebuilt for
  https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Sat Jun 26 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 3.9.20-2
- Fix build: omit tests on 32 bit architectures

* Thu Jun 17 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 3.9.20-1
- Update to latest release

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 3.8.17-3
- Rebuilt for Python 3.10

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.8.17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Sat Dec 05 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 3.8.17-1
- Update to latest patch release

* Thu Oct 01 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 3.8.10-1
- Update to latest release

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.6.34-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 3.6.34-2
- Rebuilt for Python 3.9

* Fri May 01 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 3.6.34-1
- Update to latest release

* Fri Feb 21 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 3.5.23-2
- Temporarily disable tests that fail on 32 bit builders
- https://github.com/mikedh/trimesh/issues/690

* Fri Feb 21 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 3.5.23-1
- Update to latest release

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.37.12-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Tue Oct 29 2019 Miro Hrončok <mhroncok@redhat.com> - 2.37.12-5
- Drop weak dependencies on packages not available in Fedora

* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 2.37.12-4
- Rebuilt for Python 3.8.0rc1 (#1748018)

* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 2.37.12-3
- Rebuilt for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.37.12-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sat Mar 16 2019 Miro Hrončok <mhroncok@redhat.com> - 2.37.12-1
- Update to 2.37.12 (#1678964)

* Mon Feb 18 2019 Lumír Balhar <lbalhar@redhat.com> - 2.36.29-1
- Update to 2.36.29 (#1678054)

* Sat Feb 16 2019 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.36.28-1
- Update to 2.36.28 (#1677725)

* Sun Feb 10 2019 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.36.24-1
- Update to 2.36.24 (#1668080)

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.36.13-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Mon Jan 21 2019 Miro Hrončok <mhroncok@redhat.com> - 2.36.13-1
- Update to 2.36.13 (#1667470)

* Fri Nov 09 2018 Miro Hrončok <mhroncok@redhat.com> - 2.35.24-1
- Update to 2.35.24 (#1648477)

* Mon Sep 03 2018 Miro Hrončok <mhroncok@redhat.com> - 2.33.12-1
- Update to 2.33.12

* Mon Sep 03 2018 Miro Hrončok <mhroncok@redhat.com> - 2.33.11-1
- Initial package