forked from locationtech/rasterframes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
155 lines (125 loc) · 4.52 KB
/
Copy pathsetup.py
File metadata and controls
155 lines (125 loc) · 4.52 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
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
"""
The operations in this file are designed for development and testing only.
"""
from setuptools import setup, find_packages
import distutils.log
import importlib
def _extract_module(mod):
module = importlib.import_module(mod)
if hasattr(module, '__all__'):
globals().update({n: getattr(module, n) for n in module.__all__})
else:
globals().update({k: v for (k, v) in module.__dict__.items() if not k.startswith('_')})
class ExampleCommand(distutils.cmd.Command):
"""A custom command to run pyrasterframes examples."""
description = 'run pyrasterframes examples'
user_options = [
# The format is (long option, short option, description).
('examples=', 'e', 'examples to run'),
]
def initialize_options(self):
from pathlib import Path
"""Set default values for options."""
# Each user option must be listed here with their default value.
self.examples = filter(lambda x: not x.name.startswith('_'),
list(Path('./examples').resolve().glob('*.py')))
def _check_ex_path(self, ex):
from pathlib import Path
file = Path(ex)
if not file.suffix:
file = file.with_suffix('.py')
file = (Path('./examples') / file).resolve()
assert file.is_file(), ('Invalid example %s' % file)
return file
def finalize_options(self):
"""Post-process options."""
import re
if isinstance(self.examples, str):
self.examples = re.split('\W+', self.examples)
self.examples = map(lambda x: 'examples.' + x.stem,
map(self._check_ex_path, self.examples))
def run(self):
"""Run the examples."""
import traceback
for ex in self.examples:
print(('-' * 50) + '\nRunning %s' % ex + '\n' + ('-' * 50))
try:
_extract_module(ex)
except Exception:
print(('-' * 50) + '\n%s Failed:' % ex + '\n' + ('-' * 50))
print(traceback.format_exc())
class ZipCommand(distutils.cmd.Command):
"""A custom command to create a minimal zip distribution."""
description = 'create a minimal pyrasterframes source zip file'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
"""Create the zip."""
import zipfile
from pathlib import Path
import os
zfile = 'pyrasterframes.zip'
if os.path.isfile(zfile):
os.remove(zfile)
with zipfile.ZipFile(zfile, 'w') as przip:
przip.write('pyrasterframes')
# Bring in source files and readme
patterns = ['*.py', '*.rst', '*.jar']
root = Path('.').resolve()
for pattern in patterns:
for file in list(root.glob('pyrasterframes/' + pattern)):
przip.write(str(file.relative_to(root)))
# Put a copy of the license in the zip
przip.write('LICENSE.md', 'pyrasterframes/LICENSE.md')
with open('README.rst') as f:
readme = f.read()
pyspark_ver = 'pyspark>=2.1.0,<2.2'
#pyspark_ver = 'pyspark>=2.3.0'
setup_args = dict(
name='pyrasterframes',
description='Python bindings for RasterFrames',
long_description=readme,
version='0.0.1',
url='http://rasterframes.io',
author='D. Benjamin Guseman',
author_email='guseman@astraea.io',
license='Apache 2',
setup_requires=['pytest-runner', pyspark_ver, 'pathlib'],
install_requires=[
# pyspark_ver,
# 'pathlib'
],
tests_require=[
pyspark_ver,
'pytest==3.4.2',
'pypandoc',
'numpy>=1.7'
],
test_suite="pytest-runner",
packages=find_packages(exclude=['tests', 'examples']),
include_package_data=True,
package_data={'.':['LICENSE.md'], 'pyrasterframes':['*.jar']},
exclude_package_data={'.':['setup.*', 'README.*']},
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Other Environment',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: Unix',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries'
],
zip_safe=False,
cmdclass={
'examples': ExampleCommand,
'minzip': ZipCommand
}
# entry_points={
# "console_scripts": ['pyrasterframes=pyrasterframes:console']
# }
)
if __name__ == "__main__":
setup(**setup_args)