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


Groups > linux.debian.maint.python > #12560 > unrolled thread

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

Started byUwe Steinmann <uwe@steinmann.cx>
First post2020-05-08 14:10 +0200
Last post2020-05-12 14:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.debian.maint.python


Contents

  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

#12560 — Best practice on how to package a python module along with a c++ program

FromUwe Steinmann <uwe@steinmann.cx>
Date2020-05-08 14:10 +0200
SubjectBest practice on how to package a python module along with a c++ program
Message-ID<A49Zg-2WX-3@gated-at.bofh.it>

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

Hi,

not sure if this is the right list, but it was my closes guess.

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

I thought about overriding dh_auto_build with

override_dh_auto_build:
  make pymodule
  dh_auto_build

which should at least build the module. But it still needs to be
installed at the right place. What would be the preferred way?

  Uwe

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

[toc] | [next] | [standalone]


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

FromScott Kitterman <debian@kitterman.com>
Date2020-05-08 16:20 +0200
SubjectRe: Best practice on how to package a python module along with a c++ program
Message-ID<A4c13-48X-3@gated-at.bofh.it>
In reply to#12560

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

On Friday, May 8, 2020 6:59:08 AM EDT Uwe Steinmann wrote:
> Hi,
> 
> not sure if this is the right list, but it was my closes guess.
> 
> 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
> 
> I thought about overriding dh_auto_build with
> 
> override_dh_auto_build:
>   make pymodule
>   dh_auto_build
> 
> which should at least build the module. But it still needs to be
> installed at the right place. What would be the preferred way?

First, you don't specify, but assuming this is python3:

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)

Then use dh_python3 and ${python3:Depends} to install it in the correct final 
location and generate appropriate Python interpreter dependencies.

Scott K

[toc] | [prev] | [next] | [standalone]


#12579

FromUwe Steinmann <uwe@steinmann.cx>
Date2020-05-12 14:20 +0200
Message-ID<A5C37-BT-5@gated-at.bofh.it>
In reply to#12561

[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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.maint.python


csiph-web