-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·155 lines (128 loc) · 4.63 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
#!/usr/bin/env python
# To use:
# python setup.py install
#
import sys
import os
import os.path
import string
import site
from Forthon.compilers import FCompiler
import getopt
import logging
version='1.0.1'
try:
os.environ['PATH'] += os.pathsep + site.USER_BASE + '/bin'
import setuptools
import distutils
from distutils.core import setup
from distutils.core import Extension
from distutils.dist import Distribution
from distutils.command.build import build
from distutils.command.install import install
from subprocess import call
import numpy
except:
raise SystemExit("Distutils problem")
optlist, args = getopt.getopt(sys.argv[1:], 'g', ['debug'])
machine = sys.platform
debug = 0
fcomp = None
parallel = 0
petsc = 0
for o in optlist:
if o[0] == '-g':
debug = 1
if o[0] == '--debugg':
debug = 1
fcompiler = FCompiler(machine=machine,
debug=debug,
fcompname=fcomp)
class floraInstall(build):
def run(self):
install.run(self)
logging.basicConfig(stream=sys.stderr,level=logging.INFO)
log = logging.getLogger()
log.info("test")
class floraBuild(build):
def run(self):
# with python2 everything is put into a single floraC.so file
if sys.hexversion < 0x03000000:
raise SystemExit("Python versions < 3 not supported")
else:
call(['make','-i', '-f','Makefile.Forthon'])
build.run(self)
class floraClean(build):
def run(self):
if sys.hexversion < 0x03000000:
raise SystemExit("Python versions < 3 not supported")
else:
call(['make', '-f', 'Makefile.Forthon', 'clean'])
florapkgs = ['glr', 'utl']
def makeobjects(pkg):
return [pkg+'_p.o', pkg+'pymodule.o']
floraobjects = []
# add here any extra dot o files other than pkg.o, pkg_p.o
if sys.hexversion < 0x03000000:
raise SystemExit("Python versions < 3 not supported")
else:
dummydist = Distribution()
dummydist.parse_command_line()
dummybuild = dummydist.get_command_obj('build')
dummybuild.finalize_options()
builddir = dummybuild.build_temp
floraobjects = map(lambda p: os.path.join(builddir, p), floraobjects)
library_dirs = fcompiler.libdirs
libraries = fcompiler.libs
with open('pyscripts/__version__.py','w') as ff:
ff.write("__version__ = '%s'\n"%version)
with open('pyscripts/__src__.py','w') as ff:
ff.write("__src__ = '%s'\n"%os.getcwd())
define_macros=[("WITH_NUMERIC", "0"),
("FORTHON_PKGNAME", '\"floraC\"'),
("FORTHON","1")]
# check for readline
rlncom = "echo \"int main(){}\" | gcc -x c -lreadline - "
rln = os.system(rlncom)
if rln == 0:
define_macros = define_macros + [("HAS_READLINE","1")]
os.environ["READLINE"] = "-l readline"
libraries = ['readline'] + libraries
setup(name="flora",
version=version,
author='Bruce Cohen',
author_email="[email protected]",
maintainer='Bill Meyer',
maintainer_email='[email protected]',
packages=['flora'],
package_dir={'flora': 'pyscripts'},
# include_package_data=True,
scripts=['pyscripts/flora_bas2py'],
ext_modules=[Extension('flora.floraC',
['floraC_Forthon.c',
os.path.join(builddir, 'Forthon.c')],
include_dirs=[builddir, numpy.get_include()],
library_dirs=library_dirs,
libraries=libraries,
define_macros=define_macros,
extra_objects=floraobjects,
extra_link_args=['-g','-DFORTHON'] +
fcompiler.extra_link_args,
extra_compile_args=fcompiler.extra_compile_args
)],
cmdclass={'build': floraBuild, 'clean': floraClean},
test_suite="pytests",
install_requires=['forthon'],
# note that include_dirs may have to be expanded in the line above
platforms = 'any',
classifiers=[
'Programming Language :: Fortran',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Topic :: Scientific/Engineering :: Physics',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11']
)