MCPcopy Create free account
hub / github.com/libgit2/pygit2 / BuildWithDLLs

Class BuildWithDLLs

setup.py:99–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98# On Windows, we install the git2.dll too.
99class 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)
126 for s, d in self._get_dlls():
127 self.copy_file(s, d)
128
129
130# On Windows we package up the dlls with the plugin.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…