-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathsetup.py
245 lines (228 loc) · 8.78 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import os
from distutils.core import setup
import distutils.command.build
import distutils.command.sdist
import subprocess
from os import path as osp
from fnmatch import fnmatch
from whyis._version import __version__
def package_data_with_recursive_dirs(package_data_spec, exclude=[]):
"""converts modified package_data dict to a classic package_data dict
Where normal package_data entries can only specify globs, the
modified package_data dict can have
a) directory names or
b) tuples of a directory name and a pattern
as entries in addition to normal globs.
When one of a) or b) is encountered, the entry is expanded so
that the resulting package_data contains all files (optionally
filtered by pattern) encountered by recursively searching the
directory.
Usage:
setup(
...
package_data = package_data_with_recursive_dirs({
'module': ['dir1', ('dir2', '*.xyz')],
'module2': ['dir3/file1.txt']
})
)
"""
out_spec = {}
for package_name, spec in package_data_spec.items():
# replace dots by operating system path separator
package_path = osp.join(*package_name.split('.'))
out_entries = []
for entry in spec:
directory = None # full path to data dir
pattern = None # pattern to append
datadir = None # data dir relative to package (as specified)
try: # entry is just a string
directory = osp.join(package_path, entry)
datadir = entry
pattern = None
except (TypeError, AttributeError): # entry has additional pattern spec
directory = osp.join(package_path, entry[0])
pattern = entry[1]
datadir = entry[0]
if osp.isdir(directory): # only apply if it is really a directory
for (dirpath, dirnames, filenames) in os.walk(directory):
for filename in (osp.join(dirpath, f) for f in filenames):
filename_parts = set(filename.split(os.path.sep))
for ex in exclude:
if ex in filename_parts:
continue
if not pattern or fnmatch(filename, pattern):
relname = osp.normpath(osp.join(datadir, osp.relpath(filename, directory)))
out_entries.append(relname)
else: # datadir is not really a datadir but a glob or something else
out_entries.append(datadir) # we just copy the entry
out_spec[package_name] = out_entries
print(out_spec)
return out_spec
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
def build_js():
subprocess.run('npm install',shell=True,cwd='whyis/static')
subprocess.run('npm run build-dev',shell=True,cwd='whyis/static')
def download_file(url, filename=None):
import requests
filename = url.split('/')[-1] if filename is None else filename
# NOTE the stream=True parameter below
with requests.get(url, stream=True) as r:
r.raise_for_status()
with open(filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
# If you have chunk encoded response uncomment if
# and set chunk_size parameter to None.
#if chunk:
f.write(chunk)
return filename
def download_files():
files = {
'whyis/fuseki/jars/fuseki-server.jar' : 'https://search.maven.org/remotecontent?filepath=org/apache/jena/jena-fuseki-fulljar/4.3.2/jena-fuseki-fulljar-4.3.2.jar',
# 'whyis/fuseki/jars/jena-spatial.jar': 'https://repo1.maven.org/maven2/org/apache/jena/jena-spatial/3.12.0/jena-spatial-3.12.0.jar'
# TODO: https://jena.apache.org/documentation/query/spatial-query.html#spatial-dataset-assembler
}
for dest, url in files.items():
print("Downloading %s..." % dest)
download_file(url, dest)
print("Downloads complete.")
class BuildCommand(distutils.command.build.build):
"""Custom build command."""
def run(self):
print('boo')
if os.path.exists('.git'): # build these if we are building from repo
print('Building JavaScript...')
build_js()
print('Downloading Fuseki Jars...')
download_files()
distutils.command.build.build.run(self)
class SdistCommand(distutils.command.sdist.sdist):
"""Custom sdist command."""
def run(self):
print('Building JavaScript...')
build_js()
print('Downloading Fuseki Jars...')
download_files()
distutils.command.sdist.sdist.run(self)
# mvn -q clean compile assembly:single -PwhyisProfile
setup(
name = "whyis",
version = __version__,
author = "Jamie McCusker",
author_email = "[email protected]",
description = ("Whyis is a nano-scale knowledge graph publishing, management, and analysis framework."),
license = "Apache License 2.0",
keywords = "rdf semantic knowledge graph",
url = "http://tetherless-world.github.io/whyis",
packages=['whyis'],
long_description='''Whyis is a nano-scale knowledge graph publishing,
management, and analysis framework. Whyis aims to support domain-aware management
and curation of knowledge from many different sources. Its primary goal is to enable
creation of useful domain- and data-driven knowledge graphs. Knowledge can be
contributed and managed through direct user interaction, statistical analysis,
or data ingestion from many different kinds of data sources. Every contribution to
the knowledge graph is managed as a separate entity so that its provenance
(publication status, attribution, and justification) is transparent and can
be managed and used.''',
cmdclass={
'build': BuildCommand,
# 'sdist': SdistCommand,
},
setup_requires = [
'wheel',
'requests'
],
install_requires = [
'beautifulsoup4==4.7.1',
'bibtexparser==1.1.0',
'celery<6.0.0',
'celery_once==3.0.1',
'cookiecutter==1.7.3',
'email_validator==1.1.3',
'eventlet==0.33.0',
'dnspython==2.2.1',
'filedepot==0.10.0',
# Upgrade to 2.0 when Celery can use click 8.0
'Flask<2.0',
'Flask-Login==0.5.0',
'Flask-Script==2.0.6',
'Flask-Security==3.0.0',
'itsdangerous<2.0,>=0.24',
'Flask-PluginEngine==0.5',
# remove version when upgrading to Flask 2.0
'Flask-WTF<0.15',
'html5lib==1.1',
'ijson==2.4',
'itsdangerous<2.0,>=0.24',
'jinja2-time',
'Jinja2==2.11.3',
#'keepalive',
'lxml',
'Markdown',
'markupsafe==2.0.1',
#'mod-wsgi==4.9.0',
'nltk==3.6.5',
'nose',
'numpy',
'oxrdflib==0.3.1',
'pandas',
'PyJWT',
'pyparsing',
'pyshp',
'python-dateutil',
'puremagic==1.14',
'python-slugify',
'rdflib==6.3.2',
'rdflib-jsonld==0.6.2',
'redislite>=6',
'requests[security]',
'sadi',
'scipy',
'setlr>=1.0.1',
'sdd2rdf>=1.3.2',
'xlrd==2.0.1',
'werkzeug==2.0.3',
'Flask-Caching==1.10.1'
],
tests_require=[
'pytest-flask',
'coverage==4.5.3',
'flask-testing',
'unittest-xml-reporting==2.5.1'
],
python_requires='>=3.7',
include_package_data=True,
# package_data=package_data_with_recursive_dirs({
# 'whyis.fuseki': ['jars/*.jar','webapp'],
# 'whyis': [
# 'config-template',
# 'static',
# 'templates'
# ]
# }, exclude=['node_modules']),
entry_points = {
'console_scripts': [
'whyis=whyis.manager:main',
'fuseki-server=whyis.fuseki:main',
],
'rdf.plugins.resultparser' : [
'text/turtle = rdflib.plugins.sparql.results.graph:GraphResultParser'
],
'whyis': [
'whyis_sparql_entity_resolver = whyis.plugins.sparql_entity_resolver:SPARQLEntityResolverPlugin',
'whyis_knowledge_explorer = whyis.plugins.knowledge_explorer:KnowledgeExplorerPlugin'
]
},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Framework :: Flask",
"Environment :: Web Environment",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Content Management System",
"License :: OSI Approved :: Apache Software License",
],
)