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

2020-05-12 Thread Uwe Steinmann
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
.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.steinm...@mmk-hagen.de
  Tel: 02331 840446Fax: 02331 843920


signature.asc
Description: PGP signature


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

2020-05-09 Thread Gregor Riepl
>> 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?



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

2020-05-08 Thread Scott Kitterman
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

signature.asc
Description: This is a digitally signed message part.