/
setup.py
101 lines (82 loc) · 2.79 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""
Tess
****
A 3D cell-based Voronoi library based on voro++
-----------------------------------------------
`Code available`_ on Github.
`Full documentation available`_ at Read the Docs.
.. _Code available: https://github.com/wackywendell/tess
.. _Full documentation available: https://tess.readthedocs.org
Description
-----------
Tess is a library to calculate Voronoi (and Laguerre) tessellations in 3D and analyze their
structure. The tessellation is calculated as a `list` of `Cell` objects, each of which
can give information on its volume, centroid, number of faces, surface area, etc. The library is
made with packings of spherical particles in mind, possibly with variable sizes.
"""
from setuptools import setup
from distutils.extension import Extension
from distutils.command.sdist import sdist as _sdist
try:
from Cython.Build import cythonize
except ImportError:
cythonize = None
extension_version = "0.3.1"
if cythonize is not None:
print("Building with Cython.")
ext = cythonize(
[
Extension(
"tess._voro",
sources=["tess/_voro.pyx", "src/voro++.cc"],
include_dirs=["src"],
language="c++",
)
]
)
else:
print("Cython not found, using prebuilt file.")
ext = [
Extension(
"tess._voro",
sources=["tess/_voro.cpp", "src/voro++.cc"],
include_dirs=["src"],
language="c++",
)
]
class sdist(_sdist):
# Set sdist to make the .cpp file
# from http://stackoverflow.com/a/18418524/4190270
def run(self):
# this is already imported, but the import might have failed.
# If so, raise an ImportError now.
from Cython.Build import cythonize
# Make sure the compiled Cython files in the distribution are up-to-date
cythonize(["tess/_voro.pyx"])
_sdist.run(self)
cmdclass = dict(sdist=sdist)
# create the extension and add it to the python distribution
setup(
name="tess",
version=extension_version,
author="Wendell Smith",
author_email="wackywendell@gmail.com",
description=("A module for calculating and analyzing Voronoi tessellations"),
license="BSD",
keywords="laguerre voronoi tessellation voro++",
url="https://tess.readthedocs.org",
long_description=__doc__.strip(),
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
"Intended Audience :: Science/Research",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
],
packages=["tess"],
package_dir={"tess": "tess"},
ext_modules=ext,
cmdclass=cmdclass,
)