Skip to content

Commit

Permalink
Merge pull request #15 from mikedh/main
Browse files Browse the repository at this point in the history
Build 3.12 Wheels And Update Pyproject
  • Loading branch information
mworchel authored Feb 11, 2024
2 parents a147723 + d963c6c commit ff6541e
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 49 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/install-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,23 @@ jobs:
build:
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, '3.10', 3.11]
platform: [windows-latest, macos-latest, ubuntu-20.04]
python-version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
platform: [windows-latest, macos-latest, ubuntu-22.04]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest trimesh wheel setuptools
- name: Build and install
run: pip install --verbose .
run: pip install --verbose .[test]

- name: Test
run: pytest tests
15 changes: 6 additions & 9 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.3
env:
# We don't support Python 2.7
CIBW_SKIP: cp27-*
uses: pypa/cibuildwheel@v2.16.5
with:
output-dir: wheelhouse

Expand All @@ -36,11 +33,11 @@ jobs:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4

- name: Install deps
run: python -m pip install twine build
Expand All @@ -62,7 +59,7 @@ jobs:
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4

- uses: actions/download-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion extern/xatlas
30 changes: 29 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,32 @@ requires = [
"ninja; sys_platform != 'win32'",
"cmake>=3.12",
]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

[project]
name = "xatlas"
requires-python = ">=3.7"
version = "0.0.9"
authors = [{name = "Markus Worchel", email = "m.worchel@campus.tu-berlin.de"}]
license = {file = "LICENSE"}
description = "Python bindings for xatlas"
urls = {Homepage = "https://github.com/mworchel/xatlas-python"}
dependencies = ["numpy"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.optional-dependencies]
test = ["trimesh",
"pytest"]

[tool.cibuildwheel]
# Run the package tests on every wheel using `pytest`
test-command = "pytest {package}/tests"

# will install pytest and other packages in the `test` extra
test-extras = ["test"]

# Skip PyPy on Windows as it doesn't appear to have numpy wheels
skip = ["pp*-win*", "*musllinux_i686"]
17 changes: 2 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# -*- coding: utf-8 -*-
import os
from pathlib import Path
import sys
import subprocess

Expand Down Expand Up @@ -62,7 +61,6 @@ def build_extension(self, ext):
cmake_args += ["-GNinja"]

else:

# Single config generators are handled "normally"
single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})

Expand Down Expand Up @@ -100,22 +98,11 @@ def build_extension(self, ext):
subprocess.check_call(
["cmake", "--build", "."] + build_args, cwd=self.build_temp
)

long_description = (Path(__file__).parent / "README.md").read_text()

# The information here can also be placed in setup.cfg - better separation of

# The information here can also be placed in pyproject.toml - better separation of
# logic and declaration, and simpler if you include description/version in a file.
setup(
name="xatlas",
version="0.0.8",
description="Python bindings for xatlas",
author="Markus Worchel",
author_email="m.worchel@campus.tu-berlin.de",
license='MIT',
url='https://github.com/mworchel/xatlas-python',
long_description=long_description,
long_description_content_type='text/markdown',
ext_modules=[CMakeExtension("xatlas")],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
)
34 changes: 24 additions & 10 deletions tests/test_atlas.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import os

import numpy as np
import pytest
import trimesh
import xatlas

# current working directory
cwd = os.path.abspath(os.path.expanduser(os.path.dirname(__file__)))


def test_add_mesh():
mesh = trimesh.load_mesh("tests/data/00190663.obj")
mesh = trimesh.load_mesh(os.path.join(cwd, "data", "00190663.obj"))

atlas = xatlas.Atlas()

Expand Down Expand Up @@ -40,31 +46,38 @@ def test_add_mesh():

# Normals have wrong shape (first dimension)
with pytest.raises(ValueError) as e:
atlas.add_mesh(mesh.vertices, mesh.faces, np.random.rand(1, 3))
atlas.add_mesh(mesh.vertices, mesh.faces, np.random.rand(1, 3))
assert "first dimension" in str(e.value)

# UVs have wrong shape (number of dimensions)
with pytest.raises(ValueError) as e:
atlas.add_mesh(mesh.vertices, mesh.faces, mesh.vertex_normals, np.random.rand(1))
atlas.add_mesh(
mesh.vertices, mesh.faces, mesh.vertex_normals, np.random.rand(1)
)
assert "Nx2" in str(e.value)

# UVs have wrong shape (second dimension)
with pytest.raises(ValueError) as e:
atlas.add_mesh(mesh.vertices, mesh.faces, mesh.vertex_normals, np.random.rand(1, 1))
atlas.add_mesh(
mesh.vertices, mesh.faces, mesh.vertex_normals, np.random.rand(1, 1)
)
assert "Nx2" in str(e.value)

# UVs have wrong shape (first dimension)
with pytest.raises(ValueError) as e:
atlas.add_mesh(mesh.vertices, mesh.faces, mesh.vertex_normals, np.random.rand(1, 2))
atlas.add_mesh(
mesh.vertices, mesh.faces, mesh.vertex_normals, np.random.rand(1, 2)
)
assert "first dimension" in str(e.value)

# Index array references out-of-bounds vertices
with pytest.raises(RuntimeError) as e:
atlas.add_mesh(np.random.rand(1, 3), mesh.faces)
assert "out of range" in str(e.value)


def test_generate():
mesh = trimesh.load_mesh("tests/data/00190663.obj")
mesh = trimesh.load_mesh(os.path.join(cwd, "data", "00190663.obj"))

atlas = xatlas.Atlas()
atlas.add_mesh(mesh.vertices, mesh.faces, mesh.vertex_normals)
Expand All @@ -85,11 +98,12 @@ def test_generate():
assert uvs.shape == (18996, 2)

assert atlas.chart_count == 70
assert atlas.width == 1057
assert atlas.height == 1057
assert atlas.width >= 900
assert atlas.height >= 900


def test_get_mesh():
mesh = trimesh.load_mesh("tests/data/00190663.obj")
mesh = trimesh.load_mesh(os.path.join(cwd, "data", "00190663.obj"))

atlas = xatlas.Atlas()

Expand All @@ -106,4 +120,4 @@ def test_get_mesh():

with pytest.raises(IndexError) as e:
atlas.get_mesh(1)
assert "out of bounds" in str(e.value)
assert "out of bounds" in str(e.value)
14 changes: 10 additions & 4 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import pytest
import os
import trimesh
import xatlas

# current working directory
cwd = os.path.abspath(os.path.expanduser(os.path.dirname(__file__)))


def test_parametrize():
mesh = trimesh.load_mesh("tests/data/00190663.obj")
mesh = trimesh.load_mesh(os.path.join(cwd, "data", "00190663.obj"))

vmapping, indices, uvs = xatlas.parametrize(mesh.vertices, mesh.faces, mesh.vertex_normals)
vmapping, indices, uvs = xatlas.parametrize(
mesh.vertices, mesh.faces, mesh.vertex_normals
)
assert vmapping.shape == (18996,)
assert indices.shape == (32668, 3)
assert uvs.shape == (18996, 2)
assert uvs.shape == (18996, 2)

0 comments on commit ff6541e

Please sign in to comment.