-
Notifications
You must be signed in to change notification settings - Fork 62
/
setup.py
165 lines (154 loc) · 6.22 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# encoding=UTF-8
"""setup.py module for natcap.invest.
InVEST - Integrated Valuation of Ecosystem Services and Tradeoffs
Common functionality provided by setup.py:
build_sphinx
For other commands, try `python setup.py --help-commands`
"""
import os
import platform
import subprocess
import Cython.Build
import numpy
from setuptools import find_namespace_packages, setup
from setuptools.command.build_py import build_py as _build_py
from setuptools.extension import Extension
# Read in requirements.txt and populate the python readme with the
# non-comment, non-environment-specifier contents.
_REQUIREMENTS = [req.split(';')[0].split('#')[0].strip() for req in
open('requirements.txt').readlines()
if (not req.startswith(('#', 'hg+', 'git+'))
and len(req.strip()) > 0)]
_GUI_REQUIREMENTS = [req.split(';')[0].split('#')[0].strip() for req in
open('requirements-gui.txt').readlines()
if not (req.startswith(('#', 'hg+'))
and len(req.strip()) > 0)]
README = open('README_PYTHON.rst').read().format(
requirements='\n'.join([' ' + r for r in _REQUIREMENTS]))
# Since OSX Mavericks, the stdlib has been renamed. So if we're on OSX, we
# need to be sure to define which standard c++ library to use. I don't have
# access to a pre-Mavericks mac, so hopefully this won't break on someone's
# older system. Tested and it works on Mac OSX Catalina.
compiler_and_linker_args = []
if platform.system() == 'Darwin':
compiler_and_linker_args = ['-stdlib=libc++']
class build_py(_build_py):
"""Command to compile translation message catalogs before building."""
def run(self):
# NOTE: un-comment this when we get message catalogs.
#
# internationalization: compile human-readable PO message catalogs
# into machine-readable MO message catalogs used by gettext
# the MO files are included as package data
# locale_dir = os.path.abspath(os.path.join(
# os.path.dirname(__file__),
# 'src/natcap/invest/internationalization/locales'))
# for locale in os.listdir(locale_dir):
# subprocess.run([
# 'pybabel',
# 'compile',
# '--input-file', f'{locale_dir}/{locale}/LC_MESSAGES/messages.po',
# '--output-file', f'{locale_dir}/{locale}/LC_MESSAGES/messages.mo'])
# then execute the original run method
_build_py.run(self)
setup(
name='natcap.invest',
description="InVEST Ecosystem Service models",
long_description=README,
maintainer='James Douglass',
maintainer_email='jdouglass@stanford.edu',
url='http://github.com/natcap/invest',
packages=find_namespace_packages('src'),
package_dir={
'natcap': 'src/natcap'
},
include_package_data=True,
install_requires=_REQUIREMENTS,
python_requires='>=3.8,<3.11',
license='BSD',
long_description_content_type='text/x-rst',
zip_safe=False,
keywords='gis invest',
classifiers=[
'Intended Audience :: Developers',
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft',
'Operating System :: POSIX',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Cython',
'License :: OSI Approved :: BSD License',
'Topic :: Scientific/Engineering :: GIS'
],
ext_modules=[
Extension(
name="natcap.invest.delineateit.delineateit_core",
sources=['src/natcap/invest/delineateit/delineateit_core.pyx'],
include_dirs=[numpy.get_include()],
extra_compile_args=compiler_and_linker_args,
extra_link_args=compiler_and_linker_args,
language="c++"),
Extension(
name="natcap.invest.recreation.out_of_core_quadtree",
sources=[
'src/natcap/invest/recreation/out_of_core_quadtree.pyx'],
include_dirs=[numpy.get_include()],
extra_compile_args=compiler_and_linker_args,
extra_link_args=compiler_and_linker_args,
language="c++"),
Extension(
name="natcap.invest.scenic_quality.viewshed",
sources=[
'src/natcap/invest/scenic_quality/viewshed.pyx'],
include_dirs=[numpy.get_include(),
'src/natcap/invest/scenic_quality'],
extra_compile_args=compiler_and_linker_args,
extra_link_args=compiler_and_linker_args,
language="c++"),
Extension(
name="natcap.invest.ndr.ndr_core",
sources=['src/natcap/invest/ndr/ndr_core.pyx'],
include_dirs=[numpy.get_include()],
extra_compile_args=compiler_and_linker_args,
extra_link_args=compiler_and_linker_args,
language="c++"),
Extension(
name="natcap.invest.sdr.sdr_core",
sources=['src/natcap/invest/sdr/sdr_core.pyx'],
include_dirs=[numpy.get_include()],
extra_compile_args=compiler_and_linker_args,
extra_link_args=compiler_and_linker_args,
language="c++"),
Extension(
name=("natcap.invest.seasonal_water_yield."
"seasonal_water_yield_core"),
sources=[
("src/natcap/invest/seasonal_water_yield/"
"seasonal_water_yield_core.pyx")],
include_dirs=[numpy.get_include()],
extra_compile_args=compiler_and_linker_args,
extra_link_args=compiler_and_linker_args,
language="c++"),
],
cmdclass={
'build_ext': Cython.Build.build_ext,
'build_py': build_py},
entry_points={
'console_scripts': [
'invest = natcap.invest.cli:main'
],
},
extras_require={
'ui': _GUI_REQUIREMENTS,
},
package_data={
'natcap.invest': [
'internationalization/locales/en/.gitignore'
]
}
)