| 41 | |
| 42 | |
| 43 | class PythonTrait(object): |
| 44 | def __init__(self, build_system, arc_root, out_root, tail_args): |
| 45 | self.build_system = build_system |
| 46 | self.arc_root = arc_root |
| 47 | self.out_root = out_root |
| 48 | self.tail_args = tail_args |
| 49 | self.python_version = mine_system_python_ver(self.tail_args) |
| 50 | self.platform_tag_string = mine_platform_tag_string(self.tail_args) |
| 51 | self.py_config, self.lang = self.get_python_info() |
| 52 | |
| 53 | def gen_cmd(self, arc_path, module_name, task_type): |
| 54 | if self.build_system == BUILD_SYSTEM.CMAKE: |
| 55 | cmd = ([ |
| 56 | 'cd', arc_root, |
| 57 | 'cmake', |
| 58 | '-B', self.out_root, |
| 59 | '-G', '"Unix Makefiles"', |
| 60 | '-DCMAKE_BUILD_TYPE=Release', |
| 61 | '-DCMAKE_TOOLCHAIN_FILE=' + os.path.join(self.arc_root, 'catboost', 'build', 'toolchains', 'clang.toolchain'), |
| 62 | '-DCMAKE_POSITION_INDEPENDENT_CODE=On' |
| 63 | ] + self.tail_args + [ |
| 64 | '&&' |
| 65 | 'cd', self.tmp_build_dir, |
| 66 | '&&', |
| 67 | 'make', module_name |
| 68 | ]) |
| 69 | elif self.build_system == BUILD_SYSTEM.YA: |
| 70 | cmd = [ |
| 71 | sys.executable, arc_root + '/ya', 'make', os.path.join(arc_root, arc_path), |
| 72 | '--no-src-links', '-r', '--output', out_root, '-DPYTHON_CONFIG=' + self.py_config, '-DNO_DEBUGINFO', '-DOS_SDK=local', |
| 73 | '-DHAVE_CUDA=yes' if task_type == 'GPU' else '-DHAVE_CUDA=no' |
| 74 | ] |
| 75 | |
| 76 | if not self.python_version.from_sandbox: |
| 77 | cmd += ['-DUSE_ARCADIA_PYTHON=no'] |
| 78 | cmd += extra_opts(self._on_win()) |
| 79 | |
| 80 | cmd += self.tail_args |
| 81 | return cmd |
| 82 | |
| 83 | def get_python_info(self): |
| 84 | if self.python_version.major == 2: |
| 85 | py_config = 'python-config' |
| 86 | lang = 'cp27' |
| 87 | else: |
| 88 | py_config = 'python3-config' |
| 89 | lang = 'cp3' + str(self.python_version.minor) |
| 90 | return py_config, lang |
| 91 | |
| 92 | def built_so_name(self, module_name): |
| 93 | if self._on_win(): |
| 94 | return module_name + '.pyd' |
| 95 | |
| 96 | if self.build_system == BUILD_SYSTEM.CMAKE: |
| 97 | return 'lib' + module_name + '.so' |
| 98 | elif self.build_system == BUILD_SYSTEM.YA: |
| 99 | return module_name + '.so' |
| 100 |
no outgoing calls
no test coverage detected