@@ -442,12 +442,42 @@ def run_stubgen(self):
442442 f"Warning: Stub file not found at { stub_file } and no package dir at { package_stub_dir } "
443443 )
444444
445+ # Copy all .pyi files from source to build_lib so they're included in the wheel
446+ build_lib_dsf = Path (self .build_lib ) / "dsf"
447+ build_lib_dsf .mkdir (parents = True , exist_ok = True )
448+ for pyi_file in source_pkg_dir .glob ("**/*.pyi" ):
449+ rel_path = pyi_file .relative_to (source_pkg_dir )
450+ dest_file = build_lib_dsf / rel_path
451+ dest_file .parent .mkdir (parents = True , exist_ok = True )
452+ print (f"Copying stub to build_lib: { pyi_file } -> { dest_file } " )
453+ shutil .copy2 (pyi_file , dest_file )
454+
445455 except subprocess .CalledProcessError as e :
446456 print (f"Warning: Stub generation failed: { e } " )
447457 print (f"stdout: { e .stdout } " )
448458 print (f"stderr: { e .stderr } " )
449459 # Don't fail the build if stub generation fails
450460
461+ # Always copy existing .pyi files from source to build_lib (even if stubgen failed)
462+ # This ensures pre-existing stubs like mdt.pyi and mobility.pyi are included in the wheel
463+ source_pkg_dir = Path (__file__ ).parent / "src" / "dsf"
464+ build_lib_dsf = Path (self .build_lib ) / "dsf"
465+ build_lib_dsf .mkdir (parents = True , exist_ok = True )
466+ for pyi_file in source_pkg_dir .glob ("**/*.pyi" ):
467+ rel_path = pyi_file .relative_to (source_pkg_dir )
468+ dest_file = build_lib_dsf / rel_path
469+ dest_file .parent .mkdir (parents = True , exist_ok = True )
470+ if not dest_file .exists ():
471+ print (f"Copying existing stub to build_lib: { pyi_file } -> { dest_file } " )
472+ shutil .copy2 (pyi_file , dest_file )
473+
474+ # Copy py.typed marker for PEP 561 compliance
475+ py_typed_src = source_pkg_dir / "py.typed"
476+ py_typed_dest = build_lib_dsf / "py.typed"
477+ if py_typed_src .exists () and not py_typed_dest .exists ():
478+ print (f"Copying py.typed marker to build_lib: { py_typed_dest } " )
479+ shutil .copy2 (py_typed_src , py_typed_dest )
480+
451481
452482# Read long description from README.md if available
453483LONG_DESCRIPTION = ""
@@ -508,7 +538,7 @@ def run_stubgen(self):
508538 package_dir = {"" : "src" },
509539 cmdclass = {"build_ext" : CMakeBuild },
510540 package_data = {
511- "dsf" : ["*.pyi" ],
541+ "dsf" : ["*.pyi" , "py.typed" , "**/*.pyi" ],
512542 "" : ["*.pyi" ],
513543 },
514544 include_package_data = True ,
0 commit comments