File: setup3_mpi.py

package info (click to toggle)
adios 1.13.1-28.2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 23,688 kB
  • sloc: ansic: 133,236; f90: 8,791; sh: 7,783; python: 7,648; xml: 3,793; makefile: 2,994; cpp: 2,340; java: 626; sed: 16; perl: 8
file content (134 lines) | stat: -rw-r--r-- 4,249 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python3
# Author:  Jong Choi
# Contact: [email protected]


import os
import sys
import getopt
import numpy as np

## Credit: http://svn.apache.org/repos/asf/subversion/tags/0.20.1/subversion/bindings/swig/python/setup.py
def _do_usage():
  print ("Usage: setup.py [OPTIONS] build")
  print ("       setup.py install [--prefix PREFIX]")
  print ("       setup.py install_lib [--install-dir DIR]")
  print ("")
  print ("Options:")
  print ("   -I dir      "   \
        "search DIR for includes (multiple instances allowed)")
  print ("   -L dir      "   \
        "search DIR for libraries (multiple instances allowed)")
  print ("   -C option   "   \
        "pass OPTION to the compiler at compile time (multiple instances "   \
        "allowed)")
  print ("   -R option   "   \
        "pass OPTION to the compiler at link time (multiple instances "   \
        "allowed)")
  sys.exit(0)

# Default option values
include_dirs = ['../../src/public', np.get_include()]
library_dirs = ['../../debian/tmp/usr/lib']
extra_compile_args = []
extra_link_args = []

# No args?  Give usage.
if len(sys.argv) < 2:
  _do_usage()

# Parse the command-line arguments, keeping what we want and letting
# distutils have the rest.  Distutils parameters should come after
# the target as in 'python setup.py build --prefix=/usr/local' and
# parameters for us should appear before the target as in
# 'python setup.py -I/usr/include build'.
options, leftovers = getopt.getopt(sys.argv[1:], "I:L:C:R:h",
                                   ["help"])
for option in options:
  if option[0] == '-I':
    include_dirs.append(option[1])
  if option[0] == '-L':
    library_dirs.append(option[1])
  if option[0] == '-C':
    extra_compile_args.append(option[1])
  if option[0] == '-R':
    extra_link_args.append(option[1])
  if option[0] == '-h':
    _do_usage()

  if option[0] == '--help':
    _do_usage()

  # All long options just get passed through
  if option[0][:2] == '--':
    leftovers.append(option[0])
    leftovers.append(option[1])
sys.argv[1:] = leftovers

from distutils.extension import Extension

# Use mpi4py dist utils: https://bitbucket.org/mpi4py/mpi4py
from conf.mpidistutils import setup
#from distutils.core import setup
from distutils.spawn import find_executable
from distutils.core import Command

import subprocess

extra_compile_args.insert(0, '-Wno-uninitialized')
extra_compile_args.insert(0, '-Wno-unused-function')

m1 = Extension('adios3_mpi', 
               sources=['adios3_mpi.cpp'], 
               define_macros=[],
               include_dirs = include_dirs,
               library_dirs = library_dirs,
               libraries = [],
               extra_objects = [],
               extra_compile_args = extra_compile_args,
               extra_link_args = extra_link_args)

cmd = find_executable("adios_config")
if cmd == None:
    sys.stderr.write(
        "adios_config is not installed nor found. "
        "Please install Adios or check PATH.\n")
    sys.exit(-1)

p = subprocess.Popen(["adios_config", "-c"], stdout=subprocess.PIPE)
pp = p.communicate()[0].decode(encoding='UTF-8').strip()
for path in str(pp).split(" "):
    if path.startswith('-I'):
        m1.include_dirs.append(path.replace('-I', '', 1))

p = subprocess.Popen(["adios_config", "-l"], stdout=subprocess.PIPE)
pp = p.communicate()[0].decode(encoding='UTF-8').strip()
for path in str(pp).split(" "):
    if path.startswith('-L'):
        m1.library_dirs.append(path.replace('-L', '', 1))
    if path.startswith('-l'):
        m1.libraries.append(path.replace('-l', '', 1))

class adios_test(Command):
    user_options = []
    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        import subprocess
        import sys
        errno = subprocess.call([sys.executable, 'tests/test_adios_mpi.py', 'tests/config_mpi.xml'])
        raise SystemExit(errno)
    
setup(name = 'adios3_mpi',
      version = '1.9.0',
      description = 'Python Module for Adios MPI',
      author = 'Jong Choi',
      author_email = '[email protected]',
      url = 'http://www.olcf.ornl.gov/center-projects/adios/',
      cmdclass={'test': adios_test},
      executables = [],
      ext_modules = [m1])