| 703 | |
| 704 | |
| 705 | def copy_file(target_dir, filename, rootdir): |
| 706 | # TODO(rkn): This feels very brittle. It may not handle all cases. See |
| 707 | # https://github.com/apache/arrow/blob/master/python/setup.py for an |
| 708 | # example. |
| 709 | # File names can be absolute paths, e.g. from _walk_thirdparty_dir(). |
| 710 | source = os.path.relpath(filename, rootdir) |
| 711 | destination = os.path.join(target_dir, source) |
| 712 | # Create the target directory if it doesn't already exist. |
| 713 | os.makedirs(os.path.dirname(destination), exist_ok=True) |
| 714 | if not os.path.exists(destination): |
| 715 | if sys.platform == "win32": |
| 716 | # Does not preserve file mode (needed to avoid read-only bit) |
| 717 | shutil.copyfile(source, destination, follow_symlinks=True) |
| 718 | else: |
| 719 | # Preserves file mode (needed to copy executable bit) |
| 720 | shutil.copy(source, destination, follow_symlinks=True) |
| 721 | return 1 |
| 722 | return 0 |
| 723 | |
| 724 | |
| 725 | def pip_run(build_ext): |