GeezerVison is showing github.com — Use setuptools and provide README to python binding for PyPI hosting. · YoshiDesign/tinyobjloader@b3ca787
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +21Lines changed: 21 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +The MIT License (MIT) | | 2 | + | | 3 | +Copyright (c) 2012-2019 Syoyo Fujita and many contributors. | | 4 | + | | 5 | +Permission is hereby granted, free of charge, to any person obtaining a copy | | 6 | +of this software and associated documentation files (the "Software"), to deal | | 7 | +in the Software without restriction, including without limitation the rights | | 8 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | | 9 | +copies of the Software, and to permit persons to whom the Software is | | 10 | +furnished to do so, subject to the following conditions: | | 11 | + | | 12 | +The above copyright notice and this permission notice shall be included in | | 13 | +all copies or substantial portions of the Software. | | 14 | + | | 15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | | 16 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | | 17 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | | 18 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | | 19 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | | 20 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | | 21 | +THE SOFTWARE. |
Collapse file Copy file name to clipboard +61Lines changed: 61 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# tinyobj, Wavefront .obj loader | | 2 | + | | 3 | +tinyobj is a python wrapper for C++ wavefront .obj loader. | | 4 | +tinyobj is rather fast and feature rich than other pure python version of .obj loader. | | 5 | + | | 6 | +## Quick tutorial | | 7 | + | | 8 | +```py | | 9 | +import sys | | 10 | +import tinyobj | | 11 | + | | 12 | +# Create reader. | | 13 | +reader = tinyobj.ObjReader() | | 14 | + | | 15 | +filename = "cornellbox.obj" | | 16 | + | | 17 | +# Load .obj(and .mtl) using default configuration | | 18 | +ret = reader.ParseFromFile(filename) | | 19 | + | | 20 | +if ret == False: | | 21 | + print("Warn:", reader.Warning()) | | 22 | + pint("Err:", reader.Error()) | | 23 | + print("Failed to load : ", filename) | | 24 | + | | 25 | + sys.exit(-1) | | 26 | + | | 27 | +if reader.Warning(): | | 28 | + print("Warn:", reader.Warning()) | | 29 | + | | 30 | +attrib = reader.GetAttrib() | | 31 | +print("attrib.vertices = ", len(attrib.vertices)) | | 32 | +print("attrib.normals = ", len(attrib.normals)) | | 33 | +print("attrib.texcoords = ", len(attrib.texcoords)) | | 34 | + | | 35 | +materials = reader.GetMaterials() | | 36 | +print("Num materials: ", len(materials)) | | 37 | +for m in materials: | | 38 | + print(m.name) | | 39 | + print(m.diffuse) | | 40 | + | | 41 | +shapes = reader.GetShapes() | | 42 | +print("Num shapes: ", len(shapes)) | | 43 | +for shape in shapes: | | 44 | + print(shape.name) | | 45 | + print("num_indices = {}".format(len(shape.mesh.indices))) | | 46 | + | | 47 | +``` | | 48 | + | | 49 | +## More detailed usage | | 50 | + | | 51 | +Please take a look at `python/sample.py` file in tinyobjloader git repo. | | 52 | + | | 53 | +https://github.com/syoyo/tinyobjloader/blob/master/python/sample.py | | 54 | + | | 55 | +## License | | 56 | + | | 57 | +MIT license. | | 58 | + | | 59 | +## TODO | | 60 | + * [ ] Writer saver | | 61 | + |
Collapse file Copy file name to clipboardExpand all lines: python/sample.py +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 |
| 17 | 17 | if ret == False: | 18 | 18 | print("Failed to load : ", filename) | | 19 | + print("Warn:", reader.Warning()) | | 20 | + print("Err:", reader.Error()) | 19 | 21 | sys.exit(-1) | 20 | 22 |
| 21 | | -print("Warn:", reader.Warning()) | 22 | | -print("Err:", reader.Error()) | | 23 | +if reader.Warning(): | | 24 | + print("Warn:", reader.Warning()) | 23 | 25 |
| 24 | 26 | attrib = reader.GetAttrib() | 25 | 27 | print("attrib.vertices = ", len(attrib.vertices)) | |
Collapse file Copy file name to clipboard +14-3Lines changed: 14 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from distutils.core import setup, Extension | | 1 | +import setuptools | 2 | 2 |
| | 3 | +with open("README.md", "r") as fh: | | 4 | + long_description= fh.read() | 3 | 5 |
| 4 | 6 | # `tiny_obj_loader.cc` contains implementation of tiny_obj_loader. | 5 | | -m = Extension('tinyobj', | | 7 | +m = setuptools.Extension('tinyobj', | 6 | 8 | sources = ['bindings.cc', 'tiny_obj_loader.cc'], | 7 | 9 | extra_compile_args=['-std=c++11'], | 8 | 10 | include_dirs = ['../', '../pybind11/include'] | 9 | 11 | ) | 10 | 12 |
| 11 | 13 |
| 12 | | -setup (name = 'tinyobj', | | 14 | +setuptools.setup (name = 'tinyobj', | 13 | 15 | version = '0.1', | 14 | 16 | description = 'Python module for tinyobjloader', | | 17 | + long_description = long_description, | | 18 | + long_description_content_type = "text/markdown", | | 19 | + author="Syoyo Fujita", | | 20 | + | | 21 | + url="https://github.com/syoyo/tinyobjloader", | | 22 | + classifiers=[ | | 23 | + "License :: OSI Approved :: MIT License", | | 24 | + ], | | 25 | + packages=setuptools.find_packages(), | 15 | 26 | ext_modules = [m]) | 16 | 27 |
| 17 | 28 |
|
|