Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.maint.python > #12579

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

From Uwe Steinmann <uwe@steinmann.cx>
Newsgroups linux.debian.maint.python
Subject Re: Best practice on how to package a python module along with a c++ program
Date 2020-05-12 14:20 +0200
Message-ID <A5C37-BT-5@gated-at.bofh.it> (permalink)
References <A49Zg-2WX-3@gated-at.bofh.it> <A4c13-48X-3@gated-at.bofh.it> <A5C37-BT-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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

Back to linux.debian.maint.python | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Best practice on how to package a python module along with a c++  program Uwe Steinmann <uwe@steinmann.cx> - 2020-05-08 14:10 +0200
  Re: Best practice on how to package a python module along with a c++ program Scott Kitterman <debian@kitterman.com> - 2020-05-08 16:20 +0200
    Re: Best practice on how to package a python module along with a c++  program Uwe Steinmann <uwe@steinmann.cx> - 2020-05-12 14:20 +0200

csiph-web