options.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. from __future__ import annotations
  2. import sys
  3. class CompilerOptions:
  4. def __init__(
  5. self,
  6. strip_asserts: bool = False,
  7. multi_file: bool = False,
  8. verbose: bool = False,
  9. separate: bool = False,
  10. target_dir: str | None = None,
  11. include_runtime_files: bool | None = None,
  12. capi_version: tuple[int, int] | None = None,
  13. python_version: tuple[int, int] | None = None,
  14. ) -> None:
  15. self.strip_asserts = strip_asserts
  16. self.multi_file = multi_file
  17. self.verbose = verbose
  18. self.separate = separate
  19. self.global_opts = not separate
  20. self.target_dir = target_dir or "build"
  21. self.include_runtime_files = (
  22. include_runtime_files if include_runtime_files is not None else not multi_file
  23. )
  24. # The target Python C API version. Overriding this is mostly
  25. # useful in IR tests, since there's no guarantee that
  26. # binaries are backward compatible even if no recent API
  27. # features are used.
  28. self.capi_version = capi_version or sys.version_info[:2]
  29. self.python_version = python_version