Re: Python installation paths

2022-06-02 Thread Andrey Rahmatullin
On Thu, Jun 02, 2022 at 09:15:40PM +0200, Alec Leamas wrote:
> > > I try handle a package which installs a partly compiled,
> > > architecture-dependent python module. Until now  this has been done in
> > > /usr/lib/triplet/python3.10/site-packages. This scheme has basically 
> > > worked
> > > fine.
> > > 
> > > However, here is an Ubuntu bug [1] where a user runs into problems because
> > > this installation path is not in sys.path by default.
> > > 
> > > I have been trying to look in the python policy docs, but cannot find the
> > > exact way to install code like this, in the policy [2]
> > > parlance an "extension module".
> > Not sure where is this documented but you can easily check on your system.
> > It should be /usr/lib/python3/dist-packages/*.cpython-3*-x86_64-linux-gnu.so
> 
> 
> Hm...this is not what I have. Did I get get the term "Extension module"
> wrong?
Well, we don't know what do you have.
Extension modules are ones you import.

> That aside, what I have is some python3 scripts and a compiled .so library
> invoked form the python code. The whole thing designed to be in the same
> directory. And the question is how this should be installed...
Invoked how?

-- 
WBR, wRAR


signature.asc
Description: PGP signature


Re: Python installation paths

2022-06-02 Thread julien . puydt
Le jeudi 02 juin 2022 à 14:31 -0500, Richard Laager a écrit :
> 
> There are a couple different ways to do Python to C. I think the
> terms are CFFI (or FFI or ctypes, maybe some of those are different
> though?) vs CPython extension, but I'm not 100% certain of that.

May I suggest debian-pyt...@lists.debian.org as a better venue to
discuss packaging Python software for Debian ?

Cheers,

J.Puydt



Re: Python installation paths

2022-06-02 Thread Richard Laager

On 6/2/22 14:15, Alec Leamas wrote:

Hi Audrey

On 02/06/2022 20:16, Andrey Rahmatullin wrote:

On Thu, Jun 02, 2022 at 07:19:56PM +0200, Alec Leamas wrote:

Dear list,

I try handle a package which installs a partly compiled,
architecture-dependent python module. Until now  this has been done in
/usr/lib/triplet/python3.10/site-packages. This scheme has basically 
worked

fine.

However, here is an Ubuntu bug [1] where a user runs into problems 
because

this installation path is not in sys.path by default.

I have been trying to look in the python policy docs, but cannot find 
the

exact way to install code like this, in the policy [2]
parlance an "extension module".
Not sure where is this documented but you can easily check on your 
system.
It should be 
/usr/lib/python3/dist-packages/*.cpython-3*-x86_64-linux-gnu.so



Hm...this is not what I have. Did I get get the term "Extension module" 
wrong?


There are a couple different ways to do Python to C. I think the terms 
are CFFI (or FFI or ctypes, maybe some of those are different though?) 
vs CPython extension, but I'm not 100% certain of that.


I maintain the ntpsec package. IIRC, upstream is transitioning (but I 
think still supports both at the moment).


On an older version, I had this (from the python3-ntp binary package):

/usr/lib/python3/dist-packages/ntp
/usr/lib/python3/dist-packages/ntp/__init__.py
(other .py files omitted)
/usr/lib/python3/dist-packages/ntp/ntpc.cpython-38-x86_64-linux-gnu.so

I believe that is the extension approach. I think the way this works is 
that if you import ntpc, it imports the .so. Note that there is no ntpc.py.


On newer python3-ntp, using the FFI approach, I have this:

/usr/lib/python3/dist-packages/ntp/__init__.py
/usr/lib/python3/dist-packages/ntp/ntpc.py
(other .py files omitted)
/usr/lib/x86_64-linux-gnu/ntp/libntpc.so
/usr/lib/x86_64-linux-gnu/ntp/libntpc.so.1
/usr/lib/x86_64-linux-gnu/ntp/libntpc.so.1.1.0

In this approach, ntpc.py has explicit code to load libntpc.so from 
/usr/lib/x86_64-linux-gnu/ntp/ (that path being subst'ed in to ntpc.py 
by the build process).


I hope that helps.

--
Richard


OpenPGP_signature
Description: OpenPGP digital signature


Re: Python installation paths

2022-06-02 Thread Alec Leamas

Hi Audrey

On 02/06/2022 20:16, Andrey Rahmatullin wrote:

On Thu, Jun 02, 2022 at 07:19:56PM +0200, Alec Leamas wrote:

Dear list,

I try handle a package which installs a partly compiled,
architecture-dependent python module. Until now  this has been done in
/usr/lib/triplet/python3.10/site-packages. This scheme has basically worked
fine.

However, here is an Ubuntu bug [1] where a user runs into problems because
this installation path is not in sys.path by default.

I have been trying to look in the python policy docs, but cannot find the
exact way to install code like this, in the policy [2]
parlance an "extension module".

Not sure where is this documented but you can easily check on your system.
It should be /usr/lib/python3/dist-packages/*.cpython-3*-x86_64-linux-gnu.so



Hm...this is not what I have. Did I get get the term "Extension module" 
 wrong?



That aside, what I have is some python3 scripts and a compiled .so 
library invoked form the python code. The whole thing designed to be in 
the same directory. And the question is how this should be installed...


Cheers!
--aled



Re: Python installation paths

2022-06-02 Thread Andrey Rahmatullin
On Thu, Jun 02, 2022 at 07:19:56PM +0200, Alec Leamas wrote:
> Dear list,
> 
> I try handle a package which installs a partly compiled,
> architecture-dependent python module. Until now  this has been done in
> /usr/lib/triplet/python3.10/site-packages. This scheme has basically worked
> fine.
> 
> However, here is an Ubuntu bug [1] where a user runs into problems because
> this installation path is not in sys.path by default.
> 
> I have been trying to look in the python policy docs, but cannot find the
> exact way to install code like this, in the policy [2]
> parlance an "extension module".
Not sure where is this documented but you can easily check on your system.
It should be /usr/lib/python3/dist-packages/*.cpython-3*-x86_64-linux-gnu.so


-- 
WBR, wRAR


signature.asc
Description: PGP signature


Python installation paths

2022-06-02 Thread Alec Leamas

Dear list,

I try handle a package which installs a partly compiled, 
architecture-dependent python module. Until now  this has been done in 
/usr/lib/triplet/python3.10/site-packages. This scheme has basically 
worked fine.


However, here is an Ubuntu bug [1] where a user runs into problems 
because this installation path is not in sys.path by default.


I have been trying to look in the python policy docs, but cannot find 
the exact way to install code like this, in the policy [2]

parlance an "extension module".

Any thoughts out there?

Cheers!
--alec






[1] https://bugs.launchpad.net/ubuntu/+source/lirc/+bug/1843988
[2] https://www.debian.org/doc/packaging-manuals/python-policy/