[Kde-bindings] Installing python __init__.py file from multiple KF5 frameworks

Luca Beltrame lbeltrame at kde.org
Tue May 17 23:04:57 UTC 2016


In data mercoledì 18 maggio 2016 00:09:46 CEST, Stephen Kelly ha scritto:

(I added the kde-bindings list to the CC, just in case).

> https://www.python.org/dev/peps/pep-0420/
> but I'm not certain what to do with the information there. If guidance
> can be provided, I can probably change what we install if needed.

Depends on which Python version the bindings build against. If it's 3, the 
idea would be to make a "namespaced package" which provides the PyKF5 
namespace and ensure that each binding is namespaced properly.

This means in practice that  installing pykf5.itemmodels (for example) will 
ensure that it'll belong to pykf5 without having issues with overlapping 
__init__.py files.

It is described as "Native support for package directories that don’t require 
__init__.py marker files and can automatically span multiple path segments " 
and requires Python 3.3 as minimum. 

From this stackoverflow answer[1] (the second answer is more correct than the 
first one, bear that in mind!):

"On Python 3.3 you don't have to do anything, just don't put any __init__.py 
in your namespace package directories and it will just work. "

IOW make a pykf5.itemmodels package with this setup

pykf5/
	itemmodels/
		__init__.py
		<rest of files>

notice that the pykf5 dir has no __init__.py file.

As for the rest, CMake's FindPythonInterp or FindPythonLibrary provides 
PYTHON_SITE_PACKAGES_DIR, I think, and that should be IMO used for installing 
files. "dist-packages" is a Debianism, as I said on IRC. Neither Fedora nor 
openSUSE, for example (I doubt Arch as well) use that.

Have a look at the current PyKDE4 implementation for some hints, I think.

[1] https://stackoverflow.com/questions/1675734/how-do-i-create-a-namespace-package-in-python

-- 
Luca Beltrame - KDE Forums team
GPG key ID: A29D259B


More information about the Kde-bindings mailing list