COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
setup.CMakeBuildExt Class Reference
Inheritance diagram for setup.CMakeBuildExt:
Collaboration diagram for setup.CMakeBuildExt:

Public Member Functions

def run (self)
 
def build_extension (self, ext)
 

Detailed Description

Definition at line 26 of file setup.py.

Member Function Documentation

◆ build_extension()

def setup.CMakeBuildExt.build_extension (   self,
  ext 
)

Definition at line 45 of file setup.py.

45  def build_extension(self, ext):
46 
47  extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
48  cmake_args = [
49  '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
50  '-DPYTHON_EXECUTABLE=' + sys.executable,
51  # '-DCMAKE_INSTALL_PREFIX:PATH=.'
52  ]
53 
54  cfg = 'Debug' if self.debug else 'Release'
55  build_args = ['--config', cfg]
56 
57  if platform.system() == "Windows":
58  cmake_args += [
59  '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)
60  ]
61  if sys.maxsize > 2**32:
62  cmake_args += ['-A', 'x64']
63  build_args += ['--', '/m']
64  else:
65  cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
66  build_args += ['--', '-j%d' % multiprocessing.cpu_count()]
67  # build_args += ['--', 'VERBOSE=1']
68 
69  if not os.path.exists(self.build_temp):
70  os.makedirs(self.build_temp)
71 
72  if "CUDA_ROOT" in os.environ:
73  if os.path.isfile('{}/bin/gcc'.format(os.environ["CUDA_ROOT"])):
74  cmake_args += [
75  '-DCMAKE_C_COMPILER={}/bin/gcc'.format(os.environ["CUDA_ROOT"])
76  ]
77  if os.path.isfile('{}/bin/g++'.format(os.environ["CUDA_ROOT"])):
78  cmake_args += [
79  '-DCMAKE_CXX_COMPILER={}/bin/g++'.format(os.environ["CUDA_ROOT"])
80  ]
81 
82  cmake_args += ['-DVERSION_INFO={}'.format(self.distribution.get_version())]
83  cmake_args += ['-Ddo_half=OFF']
84 
85  subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp)
86  subprocess.check_call(['cmake', '--build', '.'] + build_args,
87  cwd=self.build_temp)
88  # subprocess.check_call(['cmake', '--build', '.', "--target", "install"] + build_args,
89  # cwd=self.build_temp)
90 
91 
92 setup(
93  name='compass-sim',
94  version=shesha_version,
95  # author=['Arnaud Sevin'],
96  # author_email=['arnaud.sevin@obspm.fr'],
97  # description='',
98  # long_description='',
99  # package_data={'compass-sim': ['lib/pkgconfig/carma.pc', 'lib/pkgconfig/sutra.pc']},
100  ext_modules=[CMakeExtension('compass-sim')],
101  cmdclass={'build_ext': CMakeBuildExt},
102  zip_safe=False,
103 )
104 
105 # setup(
106 # name='shesha',
107 # version='3.0.0',
108 # # author=['Arnaud Sevin'],
109 # # author_email=['arnaud.sevin@obspm.fr'],
110 # # description='',
111 # # long_description='',
112 # packages=[
113 # 'data', 'data.par', 'data.par.par4bench', 'shesha', 'shesha.ao',
114 # 'shesha.config', 'shesha.init', 'shesha.scripts', 'shesha.sim',
115 # 'shesha.supervisor', 'shesha.util', 'shesha.widgets'
116 # ],
117 # # packages=find_packages("shesha"),
118 # package_dir={
119 # 'data': 'shesha/data',
120 # # 'data.par': 'shesha/data/par',
121 # # 'data.par.par4bench': 'shesha/data/par/par4bench',
122 # 'shesha': 'shesha/shesha',
123 # # 'shesha.ao': 'shesha/shesha/ao',
124 # # 'shesha.config': 'shesha/shesha/config',
125 # # 'shesha.init': 'shesha/shesha/init',
126 # # 'shesha.scripts': 'shesha/shesha/scripts',
127 # # 'shesha.sim': 'shesha/shesha/sim',
128 # # 'shesha.supervisor': 'shesha/shesha/supervisor',
129 # # 'shesha.sutra_pybind': 'shesha/shesha/sutra_pybind',
130 # # 'shesha.util': 'shesha/shesha/util',
131 # # 'shesha.widgets': 'shesha/shesha/widgets',
132 # },
133 # package_data={'data': ['layouts/SCAO_PYR.area', 'layouts/SCAO_SH.area']},
134 # include_package_data=True,
135 # # install_requires=['compass_sim'],
136 # zip_safe=False, )
Here is the caller graph for this function:

◆ run()

def setup.CMakeBuildExt.run (   self)

Definition at line 28 of file setup.py.

28  def run(self):
29  try:
30  out = subprocess.check_output(['cmake', '--version'])
31  except OSError:
32  raise RuntimeError(
33  "CMake must be installed to build the following extensions: " +
34  ", ".join(e.name for e in self.extensions))
35 
36  if platform.system() == "Windows":
37  cmake_version = LooseVersion(
38  re.search(r'version\s*([\d.]+)', out.decode()).group(1))
39  if cmake_version < '3.1.0':
40  raise RuntimeError("CMake >= 3.1.0 is required on Windows")
41 
42  for ext in self.extensions:
43  self.build_extension(ext)
44 
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file:
setup
Definition: setup.py:1