Skip to content

Commit 9900173

Browse files
authored
Create main.yml (#2)
* Create main.yml * add openctm as submodule, update dev environment * fix config, fix linux build, ... * fix config * debug config * debug further * this should fix it * test package publish * fix config typo * make setup.py python 2.7 compatible * remove travis * fix typo * remove pathlib * fix pipfile * fix win32 lib path * debug * fix windows build * debug * debug * debug * fix paths * this should fix it * fix publish * try and fix build * fix config * clean up * skip testing 3.5 and 3.4 * fix build * fix build * change test versions * update readme and worflow
1 parent 5681d11 commit 9900173

14 files changed

Lines changed: 237 additions & 115 deletions

File tree

.github/workflows/main.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: OpenCTM Release
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ubuntu-latest, macos-latest, windows-latest]
12+
python: [3.8, 3.7, 3.6, 3.5]
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
submodules: true
17+
- uses: actions/setup-python@v1
18+
with:
19+
python-version: ${{ matrix.python }}
20+
- name: Run tests
21+
run: |
22+
python -m pip install pipenv==2018.11.26
23+
pipenv install -d --python ${{ matrix.python }}
24+
pipenv run pytest tests
25+
shell: bash
26+
27+
package-source:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
with:
32+
submodules: true
33+
- uses: actions/setup-python@v1
34+
with:
35+
python-version: 3.7
36+
- name: Build source package
37+
run: python setup.py sdist
38+
- name: Upload source package
39+
uses: actions/upload-artifact@v1
40+
with:
41+
name: dist
42+
path: dist/
43+
44+
package-wheel:
45+
runs-on: ${{ matrix.os }}
46+
needs: [test]
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
os: [ubuntu-latest, macos-latest, windows-latest]
51+
steps:
52+
- uses: actions/checkout@v2
53+
with:
54+
submodules: true
55+
- uses: actions/setup-python@v1
56+
with:
57+
python-version: 3.7
58+
- name: Build wheels
59+
env:
60+
CIBW_SKIP: cp27-* pp27-* cp34-*
61+
run: |
62+
pip install cibuildwheel
63+
cibuildwheel --output-dir dist
64+
shell: bash
65+
- name: Upload wheels
66+
uses: actions/upload-artifact@v1
67+
with:
68+
name: dist
69+
path: dist/
70+
71+
publish:
72+
runs-on: ubuntu-latest
73+
needs: [test, package-source, package-wheel]
74+
steps:
75+
- uses: actions/checkout@v2
76+
- uses: actions/download-artifact@v1
77+
with:
78+
name: dist
79+
path: dist/
80+
- name: Publish to PyPI
81+
if: github.event_name == 'push' && contains(github.event.ref, 'master')
82+
uses: pypa/gh-action-pypi-publish@master
83+
with:
84+
user: ${{ secrets.pypi_user }}
85+
password: ${{ secrets.pypi_password }}

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "submodules/OpenCTM"]
2+
path = submodules/OpenCTM
3+
url = https://github.com/Danny02/OpenCTM.git

.travis.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

Pipfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[dev-packages]
7+
openctm = { path="." }
8+
trimesh = "*"
9+
pytest = "*"
10+
importlib-metadata = { version= ">=0.12", markers = "python_version < '3.8'"}
11+
atomicwrites = { version = ">=1.0", markers = "sys_platform=='win32'"}

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
Python-OpenCTM
22
==============
3-
[![Build Status](https://travis-ci.org/lejafar/Python-OpenCTM.svg?branch=master)](https://travis-ci.org/lejafar/Python-OpenCTM) [![PyPI version](https://badge.fury.io/py/python-openctm.svg)](https://badge.fury.io/py/python-openctm)
3+
![](https://github.com/lejafar/python-openctm/workflows/OpenCTM%20Release/badge.svg) [![PyPI version](https://badge.fury.io/py/python-openctm.svg)](https://badge.fury.io/py/python-openctm)
44
### Python Interface for the Open-CTM File Format
55

66
Python-OpenCTM is a Python interface for the [OpenCTM](https://github.com/Danny02/OpenCTM) file format. A format that allows a geometry to be compressed to a fraction of comparable file formats (3DS, STL, COLLADA...).
77

8+
Pre-built python (**3.5**-**3.8**) wheels available for **Linux**, **MacOS** and **Windows**
9+
810
## Installation
911

1012
```shell

openctm/io.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ class CTM:
66
"""
77
Object that encapsulates a CTM file
88
"""
9-
109
def __init__(self, _vertices, _faces, _normals=None):
1110
self.vertices = _vertices
1211
self.faces = _faces
1312
self.normals = _normals
1413

1514
def __eq__(self, other):
16-
return (self.vertices == other.vertices).all() and (self.faces == other.faces).all()
15+
return (self.vertices == other.vertices).all() and (
16+
self.faces == other.faces).all()
1717

1818

1919
def import_mesh(_filename):
@@ -35,8 +35,7 @@ def import_mesh(_filename):
3535
# read faces
3636
face_count = ctmGetInteger(ctm_context, CTM_TRIANGLE_COUNT)
3737
face_ctm = ctmGetIntegerArray(ctm_context, CTM_INDICES)
38-
faces = np.fromiter(face_ctm,
39-
dtype=np.int,
38+
faces = np.fromiter(face_ctm, dtype=np.int,
4039
count=face_count * 3).reshape((-1, 3))
4140

4241
# read face normals
@@ -54,37 +53,42 @@ def import_mesh(_filename):
5453

5554
def export_mesh(_ctm, _filename):
5655
ctm_context = ctmNewContext(CTM_EXPORT)
57-
56+
5857
if not str(_filename).lower().endswith('.ctm'):
5958
_filename += '.ctm'
6059

6160
try:
6261
vertex_count = len(_ctm.vertices)
6362
vertices = _ctm.vertices.reshape((-1, 1))
64-
p_vertices = ctypes.cast((CTMfloat * vertex_count * 3)(), ctypes.POINTER(CTMfloat))
63+
p_vertices = ctypes.cast((CTMfloat * vertex_count * 3)(),
64+
ctypes.POINTER(CTMfloat))
6565
for i in range(vertex_count * 3):
66-
p_vertices[i] = CTMfloat(vertices[i])
66+
p_vertices[i] = CTMfloat(vertices[i].item())
6767

6868
face_count = len(_ctm.faces)
6969
faces = _ctm.faces.reshape((-1, 1))
70-
p_faces = ctypes.cast((CTMuint * face_count * 3)(), ctypes.POINTER(CTMuint))
70+
p_faces = ctypes.cast((CTMuint * face_count * 3)(),
71+
ctypes.POINTER(CTMuint))
7172
for i in range(face_count * 3):
72-
p_faces[i] = CTMuint(faces[i])
73+
p_faces[i] = CTMuint(faces[i].item())
7374

7475
if _ctm.normals is not None:
7576
normal_count = len(_ctm.normals)
7677
normals = _ctm.normals.reshape((-1, 1))
77-
p_normals = ctypes.cast((CTMfloat * normal_count * 3)(), ctypes.POINTER(CTMfloat))
78+
p_normals = ctypes.cast((CTMfloat * normal_count * 3)(),
79+
ctypes.POINTER(CTMfloat))
7880
for i in range(normal_count * 3):
79-
p_normals[i] = CTMfloat(normals[i])
81+
p_normals[i] = CTMfloat(normals[i].item())
8082
else:
8183
p_normals = None
8284

83-
ctmDefineMesh(ctm_context, p_vertices, CTMuint(vertex_count), p_faces, CTMuint(face_count), p_normals)
85+
ctmDefineMesh(ctm_context, p_vertices, CTMuint(vertex_count), p_faces,
86+
CTMuint(face_count), p_normals)
8487
ctmSave(ctm_context, ctypes.c_char_p(_encode(_filename)))
8588
finally:
8689
ctmFreeContext(ctm_context)
8790

91+
8892
def _encode(_filename):
8993
try:
9094
return str(_filename).encode("utf-8")
@@ -98,4 +102,3 @@ def _encode(_filename):
98102
pass
99103

100104
return str(_filename).encode("utf-8", "surrogateescape")
101-

openctm/openctm.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@
9494

9595
# depending on os chose you binary ...
9696
if sys.platform == 'darwin':
97-
_ctm_lib_path = os.path.join(os.path.dirname(__file__), 'libs/libopenctm.dylib')
97+
_ctm_lib_path = os.path.join(os.path.dirname(__file__), 'libs', 'libopenctm.dylib')
9898
elif sys.platform.startswith('linux'):
99-
_ctm_lib_path = os.path.join(os.path.dirname(__file__), 'libs/libopenctm.so')
99+
_ctm_lib_path = os.path.join(os.path.dirname(__file__), 'libs', 'libopenctm.so')
100+
elif sys.platform.startswith('win32'):
101+
_ctm_lib_path = os.path.join(os.path.dirname(__file__), 'libs', 'openctm.dll')
100102
else:
101103
raise NotImplementedError(sys.platform)
102104

@@ -187,14 +189,24 @@
187189
ctmFileComment.argtypes = [CTMcontext, ctypes.c_char_p]
188190

189191
ctmDefineMesh = _ctm_lib.ctmDefineMesh
190-
ctmDefineMesh.argtypes = [CTMcontext, ctypes.POINTER(CTMfloat), CTMuint, ctypes.POINTER(CTMuint), CTMuint, ctypes.POINTER(CTMfloat)]
192+
ctmDefineMesh.argtypes = [
193+
CTMcontext,
194+
ctypes.POINTER(CTMfloat), CTMuint,
195+
ctypes.POINTER(CTMuint), CTMuint,
196+
ctypes.POINTER(CTMfloat)
197+
]
191198

192199
ctmAddUVMap = _ctm_lib.ctmAddUVMap
193-
ctmAddUVMap.argtypes = [CTMcontext, ctypes.POINTER(CTMfloat), ctypes.c_char_p, ctypes.c_char_p]
200+
ctmAddUVMap.argtypes = [
201+
CTMcontext,
202+
ctypes.POINTER(CTMfloat), ctypes.c_char_p, ctypes.c_char_p
203+
]
194204
ctmAddUVMap.restype = CTMenum
195205

196206
ctmAddAttribMap = _ctm_lib.ctmAddAttribMap
197-
ctmAddAttribMap.argtypes = [CTMcontext, ctypes.POINTER(CTMfloat), ctypes.c_char_p]
207+
ctmAddAttribMap.argtypes = [
208+
CTMcontext, ctypes.POINTER(CTMfloat), ctypes.c_char_p
209+
]
198210
ctmAddAttribMap.restype = CTMenum
199211

200212
ctmLoad = _ctm_lib.ctmLoad

openctm/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.10'
1+
__version__ = '1.0.11'

0 commit comments

Comments
 (0)