#26 Improvements to python module installation
Closed by mlichvar. Opened by ryandesign.
ryandesign/newt python  into  master

Download 26.patch

Hi, I'm the maintainer of newt in MacPorts and I recently added support for installing newt's "snack" python bindings. In the process I had to make several patches to your build system which I wanted to share with you. Please see the individual commit messages and let me know if you need clarification on why these changes were needed or if you want anything done differently. I will have further fixes to submit after this.

Nicely done. It works for me on Fedora.

Applied. Thanks!

Pull-Request has been closed by mlichvar

I've reverted the change that installs snack.py into purelib. It seems it's not recommended to split files of a single package like that, e.g.
https://peps.python.org/pep-0491/#what-s-the-deal-with-purelib-vs-platlib

And looking in /usr/lib64/python3.13/site-packages/ on Fedora, I see a large number of *.py files. It's not just compiled libraries.

It is technically fine to install to both. The major point is that it is mandatory to have only a single top-level import name in a single package, e.g.

  • foo._cext
  • foo.__init__
  • foo._implementation

You cannot do import foo and internally have it import foo._cext unless all files are in the same platlib, because the import system will only search for sub-imports of "foo" in the same location it initially found "foo".

The import system is fine with loading import snack and import _snack from different locations though. It's no different than having two different packages each provide their own different module.

I've reverted the change that installs snack.py into purelib. It seems it's not recommended to split files of a single package like that

Thank you; my knowledge of python is very limited so I didn't know.

Metadata