-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
143 lines (117 loc) · 4.57 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
import errno
import io
import os
import shutil
import sys
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.test import test as TestCommand
__version__ = '2.0.0'
here = os.path.abspath(os.path.dirname(__file__))
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
try:
shutil.copytree(s, d, symlinks, ignore)
except OSError as e:
if e.errno != errno.EEXIST:
raise
else:
shutil.copy2(s, d)
# https://stackoverflow.com/questions/15853058/run-custom-task-when-call-pip-install
class CustomInstall(install):
def run(self):
install.run(self)
# custom stuff here
# create folders to put staff in.
user_home = os.path.expanduser("~")
edam_home = os.path.join(user_home, ".edam")
edam_templates = os.path.join(edam_home, "templates")
edam_metadata = os.path.join(edam_home, "metadata")
edam_inputs = os.path.join(edam_home, "inputs")
edam_viewer = os.path.join(edam_home, ".viewer")
directories = [edam_home, edam_templates, edam_metadata,
edam_inputs, edam_viewer]
for directory in directories:
try:
os.makedirs(directory, exist_ok=True)
except OSError as e:
if e.errno != errno.EEXIST:
raise
resources = os.path.join(here, 'edam', 'resources')
resource_dirs = ['inputs', 'templates', 'metadata']
for directory in resource_dirs:
copytree(os.path.join(resources, directory),
os.path.join(edam_home, directory))
# Copy resource files
shutil.copyfile(os.path.join(resources, 'settings.yaml'),
os.path.join(edam_home, 'settings.yaml'))
shutil.copyfile(os.path.join(resources, 'edam.owl'),
os.path.join(edam_home, 'edam.owl'))
shutil.copyfile(os.path.join(resources, 'edam.owl'),
os.path.join(edam_home, 'backup.owl'))
# Copy flask_related contents into edam_home
copytree(os.path.join(resources, 'flask_related'),
os.path.join(edam_home, '.viewer/'))
shutil.rmtree(os.path.join(edam_home, '.viewer/', 'templates', 'edam'),
ignore_errors=True)
# Create symlink templates into flask edam/templates
os.symlink(os.path.join(edam_home, 'templates'),
os.path.join(edam_home, '.viewer', 'templates', 'edam'))
def read(*filenames, **kwargs):
encoding = kwargs.get('encoding', 'utf-8')
sep = kwargs.get('sep', '\n')
buf = []
for filename in filenames:
with io.open(filename, encoding=encoding) as f:
buf.append(f.read())
return sep.join(buf)
long_description = read('README.md')
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
errcode = pytest.main(self.test_args)
sys.exit(errcode)
with open('requirements.txt') as f:
required = f.read().splitlines()
setup(
name='edam',
version=__version__,
url='https://github.com/BigDataWUR/EDAM',
description='An input template framework',
long_description=long_description,
long_description_content_type="text/markdown",
license='GNU General Public License v3.0',
author='Argyrios Samourkasidis',
setup_requires=['pytest-runner'],
tests_require=['pytest'],
include_package_data=True,
install_requires=required,
cmdclass={'test': PyTest, 'install': CustomInstall},
python_requires='>=3.10',
packages=find_packages(exclude=["tests.*", "tests"]),
author_email='[email protected]',
package_data={
'edam': ['resources/metadata/*', 'resources/inputs/*',
'resources/templates/*',
'resources/settings.yaml',
'resources/flask_related/static/*/*',
'resources/flask_related/templates/*/*', ],
},
entry_points={
'console_scripts':
['edam=bin.read:cli', 'viewer=bin.viewer:run'],
},
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
)