summaryrefslogtreecommitdiff
path: root/PyGan/src/setup_lcm.py
blob: 76829b471d43b62756768bb43068baa213901626 (plain)
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
#
# python3 setup_lcm.py install --home=.
#
from sys import version_info
if version_info[0] == 3 and version_info[1] >= 12:
  from setuptools import setup, Extension
elif version_info[0] > 3:
  from setuptools import setup, Extension
else:
  from distutils.core import setup, Extension
import sysconfig
import numpy

def main():
  import os
  incdir = numpy.get_include()
  mach = os.path.basename(os.getcwd())
  Compiler = os.environ.get("COMPILER", None) # Compiler selection
  if Compiler == "NVTOOLS":
    libdir="../../lib/"+mach+"_nvidia"
    libNv=os.environ.get("NVTOOLS", None)+"/../lib"
    extralink=["-lnvc","-lnvcpumath"]
  elif Compiler == "LLVMTOOLS":
    libdir="../../lib/"+mach+"_llvm"
    libNv=None
    extralink=[ ]
  elif Compiler == "INTELTOOLS":
    libdir="../../lib/"+mach+"_intel"
    libNv=None
    extralink=[ ]
  else:
    libdir="../../lib/"+mach
    libNv=None
    extralink=[ ]
  # Filter out missing/empty library dirs to avoid "-L " warnings
  def _dirs(*paths):
    out=[]
    for p in paths:
      if p and isinstance(p, str) and os.path.isdir(p):
        out.append(p)
    return out
  lib_dirs = _dirs(libdir, libNv)
  rpath_dirs = _dirs(libNv)
  setup(name="Lcm",
          version="5.0",
          description="Python interface for the lcm C library API",
          author="Alain Hebert",
          author_email="alain.hebert@polymtl.ca",
          license="LGPL",
          ext_modules=[Extension("lcm", ["lcmmodule.c"],
                      extra_link_args = extralink,
                      include_dirs=["../../../Ganlib/src",incdir],
                      library_dirs=lib_dirs,
                      runtime_library_dirs=rpath_dirs,
                      libraries=["Ganlib"] ) ])

if __name__ == "__main__":
    main()