@@ -69,41 +69,29 @@ From the same directory, build `scale.f90` into a dedicated directory:
6969
7070``` bash
7171python3 -m x2py scale.f90 \
72- --wrap \
73- --out-dir build/verify \
74- --json
72+ --out-dir build/verify
7573```
7674
77- The JSON result must report :
75+ The command must create :
7876
79- - ` compiled ` as ` true ` ;
80- - ` module_name ` as ` scale ` ;
81- - an existing ` shared_library ` under ` build/verify ` ; and
82- - generated native bridge, object, runtime-support, and extension paths.
77+ - an importable ` scale ` extension under ` build/verify ` ; and
78+ - generated native bridge, object, runtime-support, and extension files.
8379
8480<!-- X2PY_C_DOCS_START
85- - generated bridge, C binding, object, and runtime-support paths .
81+ - generated bridge, C binding, object, and runtime-support files .
8682X2PY_C_DOCS_END -->
8783
88- Import the extension through the Python API result so the platform-specific
89- shared-library suffix does not need to be guessed:
84+ Import the extension from that build directory:
9085
9186``` python
92- from importlib.util import module_from_spec, spec_from_file_location
87+ import sys
9388
9489import numpy as np
9590
96- from x2py import build_fortran_extension
97-
98- build = build_fortran_extension(
99- " scale.f90" ,
100- output_dir = " build/verify" ,
101- )
102- spec = spec_from_file_location(build.module_name, build.shared_library)
103- extension = module_from_spec(spec)
104- spec.loader.exec_module(extension)
91+ sys.path.insert(0 , " build/verify" )
92+ import scale
10593
106- assert extension .scale(np.float64(3.0 ), np.float64(2.5 )) == np.float64(7.5 )
94+ assert scale .scale(np.float64(3.0 ), np.float64(2.5 )) == np.float64(7.5 )
10795```
10896
10997## 4. Inspect Generated Files
@@ -127,9 +115,8 @@ print(build.output_dir)
127115print (build.shared_library)
128116```
129117
130- For CLI builds, ` --json ` exposes the same fields. Add ` --verbose ` when a
131- compiler or linker command fails; it prints the exact native commands and stage
132- timings.
118+ For CLI builds, add ` --verbose ` when a compiler or linker command fails; it
119+ prints the exact native commands and stage timings.
133120
134121## Escalation Path
135122
0 commit comments