[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Best practice on how to package a python module along with a c++ program



On Sat, May 09, 2020 at 11:50:33AM +0200, Gregor Riepl wrote:
> >> I'm packaging a c++ program (horizon-eda) which also contains a
> >> python module written in c++. Upstream's Makefile has a target 'pymodule'
> >> and 'make pymodule' creates horizon.so in the build directory.
> >> According to upstream this has to be copied іnto python's sys.path
> >
> > The preferred mechanism would be to install the .so file into:
> > 
> > usr/lib/python3.X/dist-packages/ (where X is the python3 version you are 
> > building with)
> 
> "horizon.so" isn't multi-arch safe, so please ensure it gets a suitable
> filename on installation.
> 
> All CPython modules I can find on my system use one of these forms:
> /usr/lib/python3/dist-packages/package.cpython-38-x86_64-linux-gnu.so
> /usr/lib/python3/dist-packages/package/module.cpython-38-x86_64-linux-gnu.so
> /usr/lib/python3.8/dist-packages/package/module.cpython-38-x86_64-linux-gnu.so
> 
> I assume this would normally be done by distutils, or is it handled by
> dh_python3 automatically?
Looks like this is handled by dh_python3. I created a
<package-name>.pyinstall file with just a single line

horizon.so 3.8-

horizon.so is copied to usr/lib/python3/dist-packages/horizon.cpython-38-x86_64-linux-gnu.so

But there is still a problem. horizon.so is actually located in a
directory named 'build' and I had to move it out of there to be found
by dh_python3. If I leave it in 'build' and change the content of
the pyinstall file to 

build/horizon.so 3.8-

then horizon.so will end up in usr/lib/python3/dist-packages/build/

So I tried to set the namespace as documented in the man page of dh_python3

Syntax: path/to/file [VERSION_RANGE] [NAMESPACE]

Unfortunately the syntax doesn't quite match the examples in the man
page:

debian/*.py spam.egg 3.2

I suppose 'spam.egg' is the namespace which should be after the version
range. Anyway, neither way works. horizon.so ends up in a subdirectory
'build'

Do I need the pyinstall file at all? What other package could I look
at, which installs a .so file?

  Uwe

-- 
  MMK GmbH, Fleyer Str. 196, 58097 Hagen
  Uwe.Steinmann@mmk-hagen.de
  Tel: 02331 840446    Fax: 02331 843920

Attachment: signature.asc
Description: PGP signature


Reply to: