| 90 | _finalize_mjbindings_options(self) |
| 91 | |
| 92 | def run(self): |
| 93 | cwd = os.path.realpath(os.curdir) |
| 94 | if self.inplace: |
| 95 | dist_root = cwd |
| 96 | else: |
| 97 | build_cmd = self.get_finalized_command('build') |
| 98 | dist_root = os.path.realpath(build_cmd.build_lib) |
| 99 | output_dir = os.path.join(dist_root, MJBINDINGS_DIR) |
| 100 | command = [ |
| 101 | sys.executable or 'python', |
| 102 | AUTOWRAP_PATH, |
| 103 | '--header_paths={}'.format(self.header_paths), |
| 104 | '--output_dir={}'.format(output_dir), |
| 105 | ] |
| 106 | self.announce('Running command: {}'.format(command), level=logging.DEBUG) |
| 107 | try: |
| 108 | # Prepend the current directory to $PYTHONPATH so that internal imports |
| 109 | # in `autowrap` can succeed before we've installed anything. |
| 110 | old_environ = os.environ.copy() |
| 111 | new_pythonpath = [cwd] |
| 112 | if 'PYTHONPATH' in old_environ: |
| 113 | new_pythonpath.append(old_environ['PYTHONPATH']) |
| 114 | os.environ['PYTHONPATH'] = ':'.join(new_pythonpath) |
| 115 | subprocess.check_call(command) |
| 116 | finally: |
| 117 | os.environ = old_environ |
| 118 | |
| 119 | |
| 120 | class InstallCommand(install.install): |