Skip to content

Commit da1ebc2

Browse files
authored
Merge pull request #394 from physycom/fixpypi
Fixpypi
2 parents bf4ee06 + 37292ab commit da1ebc2

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include CMakeLists.txt
44
include Doxyfile
55
recursive-include src *
66
recursive-include dsf *.pyi
7+
include src/dsf/py.typed
78
global-exclude *.pyc
89
global-exclude __pycache__
910
global-exclude *.so

setup.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
453483
LONG_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,

src/dsf/dsf.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
static constexpr uint8_t DSF_VERSION_MAJOR = 4;
88
static constexpr uint8_t DSF_VERSION_MINOR = 7;
9-
static constexpr uint8_t DSF_VERSION_PATCH = 3;
9+
static constexpr uint8_t DSF_VERSION_PATCH = 4;
1010

1111
static auto const DSF_VERSION =
1212
std::format("{}.{}.{}", DSF_VERSION_MAJOR, DSF_VERSION_MINOR, DSF_VERSION_PATCH);

src/dsf/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)