This repository has been archived by the owner on Apr 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
114 lines (96 loc) · 2.82 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
import os
from subprocess import check_call
from setuptools import setup
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop
import subprocess
from packageinfo import VERSION, NAME
# Read description
with open('README.rst', 'r') as readme:
README_TEXT = readme.read()
# Install the compiler
subprocess.check_call(["pip", "install", "-r", "build_requirements.txt"])
def create_ontology_classes():
ontology_dir = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"ontology")
if not os.path.exists(ontology_dir):
print("Cannot find ontology dir files in {}".format(ontology_dir))
raise RuntimeError("Unrecoverable error.")
print("Building classes from ontology")
cmd_args = ["simphony-meta-generate",
ontology_dir,
"simphony",
"--overwrite"]
check_call(cmd_args)
class Build(build_py):
def run(self):
create_ontology_classes()
build_py.run(self)
class Develop(develop):
def run(self):
create_ontology_classes()
develop.run(self)
def write_version_py(filename=None):
if filename is None:
filename = os.path.join(
os.path.dirname(__file__), 'simphony', 'version.py')
ver = """\
version = '%s'
"""
fh = open(filename, 'wb')
try:
fh.write(ver % VERSION)
finally:
fh.close()
write_version_py()
# Create the directory for the classes.
# It must be present because otherwise setup will skip it.
# Using a keepdir proved tricky because the compiler cleans up the directory
# before creating new files. So we create it, let setup detect it, then let
# the compiler do its magic.
try:
os.makedirs("simphony/cuds/meta")
except OSError:
pass
# We cannot use find_packages because we are generating files during build.
packages = [
'bench',
'simphony',
'bench.tests',
'simphony.core',
'simphony.cuds',
'simphony.engine',
'simphony.io',
'simphony.pre_processing',
'simphony.testing',
'simphony.tools',
'simphony.visualisation',
'simphony.core.tests',
'simphony.cuds.meta',
'simphony.cuds.tests',
'simphony.engine.tests',
'simphony.io.tests',
'simphony.pre_processing.tests',
'simphony.testing.tests',
'simphony.tools.tests',
'simphony.visualisation.tests'
]
# main setup configuration class
setup(
name=NAME,
version=VERSION,
author='SimPhoNy, EU FP7 Project (Nr. 604005) www.simphony-project.eu',
description='The native implementation of the SimPhoNy cuds objects',
long_description=README_TEXT,
install_requires=[
"enum34>=1.0.4",
"stevedore>=1.2.0",
"numpy>=1.11",
"tables>=3.2.3.1",
],
packages=packages,
cmdclass={
'build_py': Build,
'develop': Develop,
})