Skip to content

Commit

Permalink
Merge 4ba34e6 into dca5750
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Mar 6, 2020
2 parents dca5750 + 4ba34e6 commit c8fe115
Show file tree
Hide file tree
Showing 22 changed files with 410 additions and 197 deletions.
28 changes: 0 additions & 28 deletions .appveyor.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .circleci/config.yml

This file was deleted.

140 changes: 140 additions & 0 deletions .github/workflows/pythonpublish.yml
@@ -0,0 +1,140 @@
name: Test And Publish

on:
push:
branches:
- actions
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Formatting
run: |
python -m pip install --upgrade pip
pip install autopep8 flake8
- name: Check Formatting
run: |
flake8 tests
flake8 trimesh
flake8 examples
autopep8 --recursive --aggressive --diff --exit-code trimesh/
autopep8 --recursive --aggressive --diff --exit-code examples/
autopep8 --recursive --aggressive --diff --exit-code tests/
tests:
needs: formatting
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install APT On Linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -qq -y
sudo apt-get install -qq -y libspatialindex-dev libgeos-dev
- name: Install Brew On Mac
if: matrix.os == 'macos-latest'
run: brew install spatialindex geos
- name: Install Pytest
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
- name: Install Trimesh
run: pip install .[easy]
- name: Run Pytest
run: pytest

pypi:
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install publishing dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install Pandoc
run: |
sudo apt-get update -qq -y
sudo apt-get install -qq -y --no-install-recommends pandoc
- name: Install From Pip
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
- name: Build Docs
run: python docs/build.py
- name: Deploy To Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/html

containers:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Login to Docker Hub
run: echo ${{ secrets.DH_PASS }} | docker login --username mikedh --password-stdin
- name: Checkout trimesh
uses: actions/checkout@v2
- name: Build/Push to DockerHub and AWS ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
GIT_SHA: ${{ github.sha }}
run: |
# get the version of trimesh with python
export VERSION=$(python -c "exec(open('trimesh/version.py','r').read()); print(__version__)")
# tag the image with the short git sha
export GIT_SHORT=${GIT_SHA::7}
# put a whole bunch of tags on image:
# tag with version, git sha, and latest
# push to DockerHub and AWS ECR
export TAGS="trimesh/trimesh:latest; trimesh/trimesh:$VERSION; trimesh/trimesh:$GIT_SHORT; $ECR_REGISTRY/$ECR_REPOSITORY:$VERSION; $ECR_REGISTRY/$ECR_REPOSITORY:latest; $ECR_REGISTRY/$ECR_REPOSITORY:$GIT_SHORT"
# build image tagged with all our many tags
docker build -t `echo "${TAGS//;/$' -t '}"` .
# push every tag to remote registry
for i in ${TAGS//;/ }; do docker push $i; done;
- name: Logout of registries
if: always()
run: |
docker logout ${{ steps.login-ecr.outputs.registry }}
docker logout
20 changes: 10 additions & 10 deletions Dockerfile
@@ -1,31 +1,31 @@
FROM debian:buster-slim
MAINTAINER Michael Dawson-Haggerty <mikedh@kerfed.com>
LABEL maintainer="mikedh@kerfed.com"

COPY docker/builds/apt.bash /tmp/
RUN bash /tmp/apt.bash

# build draco and download vhacd
# copy compile recipies to build draco and download vhacd
COPY docker/builds/draco.bash /tmp/
COPY docker/builds/vhacd.bash /tmp/
COPY docker/builds/builds.bash /tmp/
RUN bash /tmp/builds.bash
RUN bash /tmp/draco.bash && bash /tmp/vhacd.bash

# XVFB in background if you start supervisor
COPY docker/config/xvfb.supervisord.conf /etc/supervisor/conf.d/

# copy local trimesh for install and tests
COPY . /tmp/trimesh

# switch out of root
RUN useradd -m -s /bin/bash user
# make sure user owns all of tmp
RUN chown -R user:user /tmp
# switch to non-root

# copy local trimesh for install and tests
COPY --chown=user:user . /tmp/trimesh

# switch to user
USER user

# install a conda env and trimesh
RUN bash /tmp/trimesh/docker/builds/conda.bash

USER user

# add user python to path
ENV PATH="/home/user/conda/bin:$PATH"

Expand Down
6 changes: 3 additions & 3 deletions README.md
@@ -1,7 +1,7 @@
[![trimesh](https://trimsh.org/images/logotype-a.svg)](http://trimsh.org)

-----------
[![Build Status](https://travis-ci.org/mikedh/trimesh.svg?branch=master)](https://travis-ci.org/mikedh/trimesh) [![Build status](https://ci.appveyor.com/api/projects/status/j8h3luwvst1tkghl/branch/master?svg=true)](https://ci.appveyor.com/project/mikedh/trimesh/branch/master) [![Coverage Status](https://coveralls.io/repos/github/mikedh/trimesh/badge.svg)](https://coveralls.io/github/mikedh/trimesh) [![PyPI version](https://badge.fury.io/py/trimesh.svg)](https://badge.fury.io/py/trimesh) [![CircleCI](https://circleci.com/gh/mikedh/trimesh/tree/master.svg?style=svg)](https://circleci.com/gh/mikedh/trimesh/tree/master) [![Join the chat at https://gitter.im/trimsh/Lobby](https://badges.gitter.im/trimsh/Lobby.svg)](https://gitter.im/trimsh/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/mikedh/trimesh.svg?branch=master)](https://travis-ci.org/mikedh/trimesh) [![Coverage Status](https://coveralls.io/repos/github/mikedh/trimesh/badge.svg)](https://coveralls.io/github/mikedh/trimesh) [![PyPI version](https://badge.fury.io/py/trimesh.svg)](https://badge.fury.io/py/trimesh) [![CircleCI](https://circleci.com/gh/mikedh/trimesh/tree/master.svg?style=svg)](https://circleci.com/gh/mikedh/trimesh/tree/master) [![Join the chat at https://gitter.im/trimsh/Lobby](https://badges.gitter.im/trimsh/Lobby.svg)](https://gitter.im/trimsh/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)



Expand Down Expand Up @@ -216,9 +216,9 @@ A question that comes up pretty frequently is [how to cite the library.](https:/

## Containers

If you want to deploy something in a container that uses trimesh, automated `debian:buster-slim` based builds with trimesh and dependencies are available on Docker Hub:
If you want to deploy something in a container that uses trimesh, automated `debian:buster-slim` based builds with trimesh and dependencies are available on [Docker Hub](https://hub.docker.com/repository/docker/trimesh/trimesh) with image tags for `latest`, git short hash for the commit in master (i.e. `trimesh/trimesh:0c1298d`), and version (i.e. `trimesh/trimesh:3.5.27`):

`docker pull mikedh/trimesh`
`docker pull trimesh/trimesh`

[Here's an example](https://github.com/mikedh/trimesh/tree/master/examples/dockerRender) of how to render meshes using LLVMpipe and XVFB inside a container.

10 changes: 6 additions & 4 deletions docker/builds/apt.bash
@@ -1,10 +1,12 @@
set -xe
apt-get update -qq
apt-get upgrade -y -qq --no-install-recommends
apt-get install -y -qq --no-install-recommends wget bzip2 supervisor \

apt-get update -y -qq
apt-get install -y -qq --no-install-recommends \
wget bzip2 supervisor \
libgl1-mesa-glx libgl1-mesa-dri xvfb xauth \
libassimp-dev ca-certificates zstd unzip \
freeglut3-dev
freeglut3-dev git sudo \
build-essential g++ gcc cmake

# remove garbage
apt-get clean -qq
Expand Down
18 changes: 0 additions & 18 deletions docker/builds/builds.bash

This file was deleted.

20 changes: 9 additions & 11 deletions docker/builds/conda.bash
@@ -1,17 +1,17 @@
set -xe

cd
# get versioned miniconda installer via HTTPS
wget https://repo.anaconda.com/miniconda/Miniconda3-4.6.14-Linux-x86_64.sh --quiet -O miniconda.sh
wget https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh --quiet -O /tmp/miniconda.sh

# check hash of file
echo "0d6b23895a91294a4924bd685a3a1f48e35a17970a073cd2f684ffe2c31fc4be miniconda.sh" | sha256sum --check
echo "bfe34e1fa28d6d75a7ad05fd02fa5472275673d5f5621b77380898dee1be15d2 /tmp/miniconda.sh" | sha256sum --check
# run miniconda install
bash miniconda.sh -b -p ~/conda
bash /tmp/miniconda.sh -b -p /home/user/conda
# delete installer
rm miniconda.sh
rm /tmp/miniconda.sh

# make sure conda base
export PATH="~/conda/bin:$PATH"
export PATH="/home/user/conda/bin:$PATH"
conda config --set always_yes yes --set changeps1 no
# add conda-forge as remote channel
conda config --add channels conda-forge
Expand All @@ -21,12 +21,10 @@ conda config --add channels conda-forge
# conda/numpy is compiled with intel's MKL
conda install pyembree rtree

# install trimesh from the repo
cd /tmp/trimesh
# include all soft dependencies
pip install .[all,test] pyassimp==4.1.3
pip install --no-cache-dir /tmp/trimesh[all,test] pyassimp==4.1.3

# remove archives
conda clean --all
conda clean --all -f -y
# remove pip cache and temp files
rm -rf ~/.cache/pip || true
rm -rf ~/.cache || true
9 changes: 7 additions & 2 deletions docker/builds/draco.bash
Expand Up @@ -21,5 +21,10 @@ cd /tmp/draco_build
cmake /tmp/draco-1.3.5
make
# move executables to our PATH
mv draco_encoder /usr/bin
mv draco_decoder /usr/bin
mv /tmp/draco_build/draco_encoder /usr/bin
mv /tmp/draco_build/draco_decoder /usr/bin
cd

rm -rf /tmp/draco_build
rm -rf /tmp/draco-1.3.5
rm -f /tmp/draco.zip
2 changes: 1 addition & 1 deletion tests/test_copy.py
Expand Up @@ -11,7 +11,7 @@ class CopyTests(g.unittest.TestCase):

def test_copy(self):
for mesh in g.get_meshes(raise_error=True):
if not isinstance(mesh, g.trimesh.Trimesh):
if not isinstance(mesh, g.trimesh.Trimesh) or len(mesh.faces) == 0:
continue
start = {mesh.md5(), mesh.crc()}

Expand Down
32 changes: 32 additions & 0 deletions tests/test_except.py
@@ -0,0 +1,32 @@
try:
from . import generic as g
except BaseException:
import generic as g


class ExceptionsTest(g.unittest.TestCase):

def test_module(self):
# create an ExceptionModule
try:
raise ValueError('nah')
except BaseException as E:
em = g.trimesh.exceptions.ExceptionModule(E)

# checking isinstance should always return false
# and NOT raise the error
assert not isinstance(em, dict)

try:
# should re-raise `ValueError('nah')`
em.hi()
# if we're here raise an error we don't catch
raise NameError('should not have worked!!')
except ValueError:
# should have re-raised ValueError
pass


if __name__ == '__main__':
g.trimesh.util.attach_to_log()
g.unittest.main()

0 comments on commit c8fe115

Please sign in to comment.