-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathsetup.py
executable file
·70 lines (62 loc) · 2.19 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
from setuptools import setup
from subprocess import call
import os
import shutil
def warningOrError(errorOnFailure, msg):
if errorOnFailure:
raise Exception(msg)
else:
print(msg)
def generateIDL():
errorOnFailure = not os.path.exists(os.path.join(os.path.dirname(__file__), 'OMPythonIDL', '__init__.py'))
try:
path_to_omc = shutil.which("omc")
omhome = os.path.dirname(os.path.dirname(os.path.split(path_to_omc)))
except BaseException:
omhome = None
omhome = omhome or os.environ.get('OPENMODELICAHOME')
if omhome is None:
warningOrError(errorOnFailure, "Failed to find OPENMODELICAHOME (searched for environment variable as well as the omc executable)")
return
idl = os.path.join(omhome, "share", "omc", "omc_communication.idl")
if not os.path.exists(idl):
warningOrError(errorOnFailure, "Path not found: %s" % idl)
return
if 0 != call(["omniidl", "-bpython", "-Wbglobal=_OMCIDL", "-Wbpackage=OMPythonIDL", idl]):
warningOrError(errorOnFailure, "omniidl command failed")
return
print("Generated OMPythonIDL files")
try:
# if we don't have omniidl or omniORB then don't try to generate OMPythonIDL files.
try:
import omniidl
except ImportError:
import omniORB
hasomniidl = True
generateIDL()
except ImportError:
hasomniidl = False
OMPython_packages = ['OMPython', 'OMPython.OMParser']
if hasomniidl:
OMPython_packages.extend(['OMPythonIDL', 'OMPythonIDL._OMCIDL', 'OMPythonIDL._OMCIDL__POA'])
setup(name='OMPython',
version='3.6.0',
description='OpenModelica-Python API Interface',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Anand Kalaiarasi Ganeson',
author_email='[email protected]',
maintainer='Adeel Asghar',
maintainer_email='[email protected]',
license="BSD, OSMC-PL 1.2, GPL (user's choice)",
url='http://openmodelica.org/',
packages=OMPython_packages,
install_requires=[
'future',
'numpy',
'psutil',
'pyparsing',
'pyzmq'
],
python_requires='>=3.8',
)