prik 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. prik/__init__.py +157 -0
  2. prik/__main__.py +3 -0
  3. prik/binding_support/LICENSE +21 -0
  4. prik/binding_support/__init__.py +1 -0
  5. prik/binding_support/prik_binding.h +776 -0
  6. prik/cli.py +2460 -0
  7. prik/compiling/__init__.py +0 -0
  8. prik/compiling/compiler_profiles.py +307 -0
  9. prik/compiling/compilers.py +352 -0
  10. prik/compiling/native_support.py +41 -0
  11. prik/compiling/objects.py +37 -0
  12. prik/contracts/__init__.py +352 -0
  13. prik/extensions/__init__.py +1 -0
  14. prik/naming/__init__.py +19 -0
  15. prik/naming/policy.py +409 -0
  16. prik/parsers/__init__.py +3 -0
  17. prik/parsers/c/__init__.py +107 -0
  18. prik/parsers/c/__main__.py +6 -0
  19. prik/parsers/c/cli.py +232 -0
  20. prik/parsers/c/lexer.py +802 -0
  21. prik/parsers/c/models.py +563 -0
  22. prik/parsers/c/parser.py +3155 -0
  23. prik/parsers/c/preprocessor.py +117 -0
  24. prik/parsers/c/type_resolver.py +149 -0
  25. prik/parsers/fortran/__init__.py +1 -0
  26. prik/parsers/fortran/__main__.py +3 -0
  27. prik/parsers/fortran/cli.py +345 -0
  28. prik/parsers/fortran/lexer.py +122 -0
  29. prik/parsers/fortran/models.py +538 -0
  30. prik/parsers/fortran/parser.py +4969 -0
  31. prik/parsers/fortran/type_resolver.py +26 -0
  32. prik/parsers/fortran/utils.py +60 -0
  33. prik/parsers/pyi/__init__.py +5 -0
  34. prik/parsers/pyi/parser.py +26 -0
  35. prik/pipeline/__init__.py +1 -0
  36. prik/pipeline/build.py +2297 -0
  37. prik/pipeline/preprocessing.py +1306 -0
  38. prik/pipeline/pyi.py +130 -0
  39. prik/pipeline/wrapper_artifacts.py +58 -0
  40. prik/probes/__init__.py +1 -0
  41. prik/probes/c_types.py +545 -0
  42. prik/probes/fortran_types.py +669 -0
  43. prik/probes/report.py +321 -0
  44. prik/runtime/__init__.py +1 -0
  45. prik/runtime/handles.py +1588 -0
  46. prik/semantics/__init__.py +39 -0
  47. prik/semantics/c2ir.py +1567 -0
  48. prik/semantics/fortran2ir.py +2639 -0
  49. prik/semantics/metadata.py +17 -0
  50. prik/semantics/models.py +642 -0
  51. prik/semantics/native_array_handles.py +442 -0
  52. prik/semantics/native_contract.py +272 -0
  53. prik/semantics/ownership.py +1962 -0
  54. prik/semantics/policy_completion.py +1681 -0
  55. prik/semantics/pyi2ir.py +2955 -0
  56. prik/semantics/pyi_metadata.py +5 -0
  57. prik/semantics/wrapper_exports.py +103 -0
  58. prik/semantics/wrapper_policy.py +6471 -0
  59. prik/stage_values.py +50 -0
  60. prik/types/__init__.py +1 -0
  61. prik/types/numpy.py +84 -0
  62. prik/utilities/__init__.py +1 -0
  63. prik/utilities/strings.py +45 -0
  64. prik/utilities/visitor.py +39 -0
  65. prik/wrapper_codegen/__init__.py +167 -0
  66. prik/wrapper_codegen/c/__init__.py +1 -0
  67. prik/wrapper_codegen/c/binding.py +11846 -0
  68. prik/wrapper_codegen/checks.py +275 -0
  69. prik/wrapper_codegen/docstrings.py +646 -0
  70. prik/wrapper_codegen/fortran/__init__.py +1 -0
  71. prik/wrapper_codegen/fortran/bridge.py +7247 -0
  72. prik/wrapper_codegen/generator.py +4476 -0
  73. prik/wrapper_codegen/naming.py +18 -0
  74. prik/wrapper_codegen/nodes.py +428 -0
  75. prik/wrapper_codegen/plan.py +812 -0
  76. prik/wrapper_codegen/planner.py +1990 -0
  77. prik/wrapper_codegen/primitive_scalar_types.py +122 -0
  78. prik/wrapper_codegen/printers/__init__.py +13 -0
  79. prik/wrapper_codegen/printers/pyi_printer.py +2112 -0
  80. prik/wrapper_codegen/printers/source_printers.py +772 -0
  81. prik/wrapper_codegen/visitor.py +44 -0
  82. prik-0.1.0.dist-info/METADATA +591 -0
  83. prik-0.1.0.dist-info/RECORD +87 -0
  84. prik-0.1.0.dist-info/WHEEL +5 -0
  85. prik-0.1.0.dist-info/entry_points.txt +2 -0
  86. prik-0.1.0.dist-info/licenses/LICENSE +21 -0
  87. prik-0.1.0.dist-info/top_level.txt +1 -0
prik/__init__.py ADDED
@@ -0,0 +1,157 @@
1
+ """Public PRIK API."""
2
+
3
+ from importlib import import_module
4
+ from importlib.metadata import version as _distribution_version
5
+
6
+ from prik.parsers.c.models import CFile, CParseError, CProject
7
+ from prik.parsers.c.parser import parse_c_file, parse_c_project
8
+ from prik.parsers.fortran.models import (
9
+ FortranArgument,
10
+ FortranBlockData,
11
+ FortranDerivedType,
12
+ FortranFile,
13
+ FortranInterface,
14
+ FortranModule,
15
+ FortranParseError,
16
+ FortranProcedureSignature,
17
+ FortranProgram,
18
+ FortranProject,
19
+ FortranSubmodule,
20
+ )
21
+ from prik.parsers.fortran.parser import parse_fortran_file, parse_fortran_project
22
+ from prik.parsers.pyi import parse_pyi_file, parse_pyi_text
23
+ from prik.semantics.fortran2ir import (
24
+ collect_semantic_compile_time_requirements,
25
+ fortran_file_to_semantic_modules,
26
+ fortran_module_to_semantic_module,
27
+ fortran_project_to_semantic_modules,
28
+ resolve_semantic_compile_time_values,
29
+ )
30
+ from prik.semantics.c2ir import (
31
+ CToIRConverter,
32
+ c_file_to_semantic_module,
33
+ c_file_to_semantic_modules,
34
+ c_function_to_semantic_function,
35
+ c_parameter_to_semantic_argument,
36
+ c_project_to_semantic_module,
37
+ c_project_to_semantic_modules,
38
+ c_struct_to_semantic_class,
39
+ c_type_to_semantic_type,
40
+ )
41
+ from prik.semantics.pyi2ir import convert_pyi_to_ir
42
+ from prik.pipeline.pyi import pyi_file_to_semantic_module, pyi_paths_to_semantic_modules, pyi_text_to_semantic_module
43
+ from prik.wrapper_codegen.printers import emit_module_stubs, opaque_dependency_modules
44
+ from prik.runtime.handles import AllocatableArray, NativeArrayHandleBase, PointerArray
45
+
46
+ __version__ = _distribution_version("prik")
47
+
48
+ _CLI_EXPORTS = {"main"}
49
+ _FORTRAN_TYPE_PROBE_EXPORTS = {
50
+ "FortranTypeProbeError",
51
+ "FortranTypeProbeReport",
52
+ "build_fortran_type_probe_source",
53
+ "evaluate_fortran_type_requirements",
54
+ "fortran_type_probe_expressions",
55
+ "probe_fortran_type_expressions",
56
+ }
57
+ _NUMPY_TYPE_EXPORTS = {
58
+ "SEMANTIC_DTYPE_TO_NUMPY_DTYPE",
59
+ "numpy_dtype_expression",
60
+ "semantic_dtype_to_numpy_dtype",
61
+ "semantic_dtype_to_numpy_dtype_map",
62
+ "semantic_type_to_numpy_dtype",
63
+ }
64
+ _WRAPPING_EXPORTS = {
65
+ "NativeBuildPlan",
66
+ "NativeCompilationUnit",
67
+ "NativeLinkItem",
68
+ "NativePrebuiltArtifact",
69
+ "WrapperBuildResult",
70
+ "build_fortran_extension",
71
+ "build_pyi_extension",
72
+ "build_pyi_extension_from_manifest",
73
+ }
74
+
75
+
76
+ def __getattr__(name: str):
77
+ if name in _CLI_EXPORTS:
78
+ module = import_module("prik.cli")
79
+ return getattr(module, name)
80
+ if name in _FORTRAN_TYPE_PROBE_EXPORTS:
81
+ module = import_module("prik.probes.fortran_types")
82
+ return getattr(module, name)
83
+ if name in _NUMPY_TYPE_EXPORTS:
84
+ module = import_module("prik.types.numpy")
85
+ return getattr(module, name)
86
+ if name in _WRAPPING_EXPORTS:
87
+ module = import_module("prik.pipeline.build")
88
+ return getattr(module, name)
89
+ raise AttributeError(f"module 'prik' has no attribute {name!r}")
90
+
91
+
92
+ __all__ = (
93
+ "SEMANTIC_DTYPE_TO_NUMPY_DTYPE",
94
+ "AllocatableArray",
95
+ "CFile",
96
+ "CParseError",
97
+ "CProject",
98
+ "CToIRConverter",
99
+ "FortranArgument",
100
+ "FortranBlockData",
101
+ "FortranDerivedType",
102
+ "FortranFile",
103
+ "FortranInterface",
104
+ "FortranModule",
105
+ "FortranParseError",
106
+ "FortranProcedureSignature",
107
+ "FortranProgram",
108
+ "FortranProject",
109
+ "FortranSubmodule",
110
+ "FortranTypeProbeError",
111
+ "FortranTypeProbeReport",
112
+ "NativeArrayHandleBase",
113
+ "NativeBuildPlan",
114
+ "NativeCompilationUnit",
115
+ "NativeLinkItem",
116
+ "NativePrebuiltArtifact",
117
+ "PointerArray",
118
+ "WrapperBuildResult",
119
+ "__version__",
120
+ "build_fortran_extension",
121
+ "build_fortran_type_probe_source",
122
+ "build_pyi_extension",
123
+ "build_pyi_extension_from_manifest",
124
+ "c_file_to_semantic_module",
125
+ "c_file_to_semantic_modules",
126
+ "c_function_to_semantic_function",
127
+ "c_parameter_to_semantic_argument",
128
+ "c_project_to_semantic_module",
129
+ "c_project_to_semantic_modules",
130
+ "c_struct_to_semantic_class",
131
+ "c_type_to_semantic_type",
132
+ "collect_semantic_compile_time_requirements",
133
+ "convert_pyi_to_ir",
134
+ "emit_module_stubs",
135
+ "evaluate_fortran_type_requirements",
136
+ "fortran_file_to_semantic_modules",
137
+ "fortran_module_to_semantic_module",
138
+ "fortran_project_to_semantic_modules",
139
+ "fortran_type_probe_expressions",
140
+ "main",
141
+ "numpy_dtype_expression",
142
+ "opaque_dependency_modules",
143
+ "parse_c_file",
144
+ "parse_c_project",
145
+ "parse_fortran_file",
146
+ "parse_fortran_project",
147
+ "parse_pyi_file",
148
+ "parse_pyi_text",
149
+ "probe_fortran_type_expressions",
150
+ "pyi_file_to_semantic_module",
151
+ "pyi_paths_to_semantic_modules",
152
+ "pyi_text_to_semantic_module",
153
+ "resolve_semantic_compile_time_values",
154
+ "semantic_dtype_to_numpy_dtype",
155
+ "semantic_dtype_to_numpy_dtype_map",
156
+ "semantic_type_to_numpy_dtype",
157
+ )
prik/__main__.py ADDED
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Said Hadjout
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ """Bundled header-only C support used by generated CPython bindings."""