| 98 | # On Windows, we install the git2.dll too. |
| 99 | class BuildWithDLLs(build): |
| 100 | def _get_dlls(self) -> list[tuple[Path, Path]]: |
| 101 | # return a list of (FQ-in-name, relative-out-name) tuples. |
| 102 | ret = [] |
| 103 | bld_ext = self.distribution.get_command_obj('build_ext') |
| 104 | compiler_type = bld_ext.compiler.compiler_type # type: ignore[attr-defined] |
| 105 | libgit2_dlls = [] |
| 106 | if compiler_type == 'msvc': |
| 107 | libgit2_dlls.append('git2.dll') |
| 108 | elif compiler_type == 'mingw32': |
| 109 | libgit2_dlls.append('libgit2.dll') |
| 110 | look_dirs = [libgit2_bin] + os.getenv('PATH', '').split(os.pathsep) |
| 111 | |
| 112 | target = Path(self.build_lib).absolute() / 'pygit2' |
| 113 | for dll in libgit2_dlls: |
| 114 | for look in look_dirs: |
| 115 | f = Path(look) / dll |
| 116 | if f.is_file(): |
| 117 | ret.append((f, target)) |
| 118 | break |
| 119 | else: |
| 120 | log.warn(f'Could not find required DLL {dll} to include') |
| 121 | log.debug(f'(looked in {look_dirs})') |
| 122 | return ret |
| 123 | |
| 124 | def run(self) -> None: |
| 125 | build.run(self) |