MCPcopy Index your code
hub / github.com/python/mypy / SourceDep

Class SourceDep

mypyc/ir/deps.py:45–73  ·  view source on GitHub ↗

Defines a C source file that a primitive may require. Each source file must also have a corresponding .h file (replace .c with .h) that gets implicitly #included if the source is used. include_dirs are passed to the C compiler when the file is compiled as a shared library separate f

Source from the content-addressed store, hash-verified

43
44
45class SourceDep:
46 """Defines a C source file that a primitive may require.
47
48 Each source file must also have a corresponding .h file (replace .c with .h)
49 that gets implicitly #included if the source is used.
50 include_dirs are passed to the C compiler when the file is compiled as a
51 shared library separate from the C extension.
52 """
53
54 def __init__(
55 self, path: str, *, include_dirs: list[str] | None = None, internal: bool = True
56 ) -> None:
57 # Relative path from mypyc/lib-rt, e.g. 'bytes_extra_ops.c'
58 self.path: Final = path
59 self.include_dirs: Final = include_dirs or []
60 self.internal: Final = internal
61
62 def __repr__(self) -> str:
63 return f"SourceDep(path={self.path!r})"
64
65 def __eq__(self, other: object) -> bool:
66 return isinstance(other, SourceDep) and self.path == other.path
67
68 def __hash__(self) -> int:
69 return hash(("SourceDep", self.path))
70
71 def get_header(self) -> str:
72 """Get the header file path by replacing .c with .h"""
73 return self.path.replace(".c", ".h")
74
75
76class HeaderDep:

Callers 4

mypyc_buildFunction · 0.90
deserializeMethod · 0.90
internal_depMethod · 0.85
deps.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…