-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathsetup.py
94 lines (88 loc) · 3.76 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
import setuptools
import os
import sys
from skbuild import setup
from skbuild.constants import CMAKE_INSTALL_DIR, skbuild_plat_name
from packaging.version import LegacyVersion
from skbuild.exceptions import SKBuildError
from skbuild.cmaker import get_cmake_version
def read(fname):
with open(os.path.join(os.path.dirname(__file__), fname), 'rt') as f:
return f.read()
# Add CMake as a build requirement if cmake is not installed or is too low a version
setup_requires = []
try:
cmake_version = LegacyVersion(get_cmake_version())
if cmake_version < LegacyVersion("3.5") or cmake_version >= LegacyVersion("3.20"):
setup_requires.append('cmake<3.20')
except SKBuildError:
setup_requires.append('cmake<3.20')
# If you want to re-build the cython cpp file (DracoPy.cpp), run:
# cython --cplus -3 -I./_skbuild/linux-x86_64-3.6/cmake-install/include/draco/ ./src/DracoPy.pyx
# Replace "linux-x86_64-3.6" with the directory under _skbuild in your system
# Draco must already be built/setup.py already be run before running the above command
src_dir = './src'
lib_dir = os.path.abspath(os.path.join(CMAKE_INSTALL_DIR(), 'lib/'))
cmake_args = []
if sys.platform == 'darwin':
plat_name = skbuild_plat_name()
sep = [pos for pos, char in enumerate(plat_name) if char == '-']
assert len(sep) == 2
cmake_args = ['-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING='+plat_name[sep[0]+1:sep[1]],'-DCMAKE_OSX_ARCHITECTURES:STRING='+plat_name[sep[1]+1:]]
library_link_args = ['-l{0}'.format(lib) for lib in ('dracoenc', 'draco', 'dracodec')]
elif sys.platform == 'win32':
library_link_args = ['{0}'.format(lib) for lib in ('dracoenc.lib', 'draco.lib', 'dracodec.lib')]
else:
library_link_args = ['-l:{0}'.format(lib) for lib in ('libdracoenc.a', 'libdraco.a', 'libdracodec.a')]
if sys.platform == 'win32':
extra_link_args = ['/LIBPATH:{0}'.format(lib_dir)] + library_link_args
extra_compile_args = [
'/std:c++17','-O3'
]
else:
extra_link_args = ['-L{0}'.format(lib_dir)] + library_link_args
extra_compile_args = [
'-std=c++11','-O3'
]
setup(
name='DracoPy',
version='0.0.19',
description = 'Python wrapper for Google\'s Draco Mesh Compression Library',
author = 'Manuel Castro :: Contributors :: Fatih Erol, Faru Nuri Sonmez',
author_email = '[email protected]',
url = 'https://github.com/seung-lab/DracoPy',
long_description=read('README.md'),
long_description_content_type="text/markdown",
license = "License :: OSI Approved :: Apache Software License",
cmake_source_dir='./draco',
cmake_args=cmake_args,
setup_requires=setup_requires,
install_requires=['pytest'],
ext_modules=[
setuptools.Extension(
'DracoPy',
sources=[ os.path.join(src_dir, 'DracoPy.cpp') ],
depends=[ os.path.join(src_dir, 'DracoPy.h'), os.path.join(src_dir, 'DracoPy.pyx')],
language='c++',
include_dirs = [ os.path.join(CMAKE_INSTALL_DIR(), 'include/')],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
],
classifiers=[
"Intended Audience :: Developers",
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Scientific/Engineering",
"Operating System :: POSIX",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows :: Windows 10",
"Topic :: Utilities",
]
)