build: package alsaaudio as a typed Python package - #161
Conversation
|
looks sensible judging by a quick inspection. given the bullet list, it seem that this PR can be atomized into a series of self-contained commits. |
|
@Robolightning I have a question, since I authored #156, which supposedly tackled the same type-stubs issue. Is the approach in there not working? It's working totally fine for me with No "private" module trick was necessary, it follows the standard practice of providing a stubs companion package to a native module. Keen to know your thoughts :) |
Thanks for pointing this out. I re-tested the current #156 approach and agree that the companion The remaining issue I am trying to address here is narrower: the runtime module is still a native top-level extension module, so there is no real Python package source for I also rebuilt and installed the wheel locally against ALSA headers/libs and checked import, mypy, pyright, and stubtest. The package layout works. I found one remaining stubtest issue in the constructor stubs for the C extension classes, and amended the PR with that minimal fix. |
Thanks, that makes sense. I compared this again against current #156 already covers the companion-stubs approach, so I narrowed this PR to the packaging layout change that is still different: making I rebuilt the current PR wheel locally against ALSA headers/libs and verified import, mypy, pyright, and stubtest. The runtime package layout works, and the wheel no longer contains a duplicate top-level extension. I found one remaining issue in the stubs: |
This PR narrows the change to the part that is still not covered by #156.
#156 already made type information visible to downstream type checkers by shipping the
alsaaudio-stubscompanion package. This PR keeps that work intact, but changes the runtime packaging layout so thatalsaaudiois a real Python package with a private native extension module.Changes:
alsaaudiotoalsaaudio._alsaaudioalsaaudio/__init__.pyto preserve the existing public APIalsaaudio/__init__.pyinext to the runtime packagealsaaudio/py.typedPCMandMixersostubtestpasses for the C extension classesValidation:
import alsaaudioalsaaudio.asoundlib_version()alsaaudiomypy.stubtest alsaaudio