-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup.py
More file actions
74 lines (58 loc) · 2.12 KB
/
Copy pathsetup.py
File metadata and controls
74 lines (58 loc) · 2.12 KB
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
from pathlib import Path
import sys
from setuptools import setup, Extension
import numpy as np
from Cython.Build import cythonize
def make_extension(extpath: Path) -> Extension:
""" Make a setuptools.Extension from a Path to a pygeotess source file.
The extension location/name is a mirros the original pyx file location, with a lowercase stem.
Examples
--------
>>> make_extension(pathlib.Path('geotess/lib/GeoTessModel.pyx'))
<setuptools.extension.Extension('geotess.lib.geotessutils') at 0x107402900>
>>> make_extension(pathlib.Path('GeoTess/Lib/GeoTessModel.cpp'))
<setuptools.extension.Extension('GeoTess.Lib.geotessutils') at 0x10aba2fc0>
"""
extension = Extension(
name='.'.join(extpath.parts[:-1] + (extpath.stem.lower(),)),
sources=[str(extpath)],
language='c++',
library_dirs=[sys.prefix + '/lib'],
libraries=['geotesscpp', 'geotessamplitudecpp'],
include_dirs=[np.get_include()],
)
return extension
# Every .pyx file in the the geotess directory will produce a lowecase Python extension module in the same location.
pyxfiles = Path('geotess').glob('**/*.pyx')
cy_extensions = [make_extension(pth) for pth in pyxfiles]
compiler_directives = dict(
embedsignature=True,
language_level='3',
c_string_type='unicode', # std::string outputs are coerced from bytes to Python 3 unicode str
c_string_encoding='utf-8', # if std::string is coerced to Python 3 unicode str, use utf-8 decoding
)
extensions = cythonize(
cy_extensions,
force=True,
compiler_directives=compiler_directives
)
setup(name = 'pygeotess',
version = '0.3.0',
description = 'GeoTess access from Python.',
author = 'Jonathan K. MacCarthy',
author_email = 'jkmacc@lanl.gov',
zip_safe=False,
packages = ['geotess', 'geotess.lib', 'geotess.data'],
ext_modules = extensions,
package_data = {
'geotess.data': [
'*.geotess',
'small_model_grid.ascii',
]
},
install_requires = [
'numpy',
'setuptools',
'cython',
]
)