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
| 43 | |
| 44 | |
| 45 | class 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 | |
| 76 | class HeaderDep: |
no outgoing calls
no test coverage detected
searching dependent graphs…