Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-17 Thread Michał Jaworski
I've looked into the details of the deb package that Cameron mentioned. It
may be the one that you Chris uss because it does indeed include a
pyscand.so file. Quick question to you Chris: the utilities
you've mentioned are the code that you've written yourself or utilities
from /usr/libexec/okimfputl that are shipped with the "driver package". In
the deb package I've found following files:
/usr/libexec/okimfputl/imgfilecv.py
/usr/libexec/okimfputl/pushconfig.py
/usr/libexec/okimfputl/pushass.py
/usr/libexec/okimfputl/mfpcfgfile.py
...

If that's the latter, I wouldn't even try to port that to Python 3. First,
it would be clearly against the licence agreement. Second, that would
probably result in total mess and take more time that it takes to earn for
a new printer. If you really want to keep the printer (I wouldn't) I would
do the following: upgrade your system, install Python 2.7 straight from
sources in a separate location (e.g. /opt/oki-python?) and modify all
shebang lines of the OKI python utilities from utilities to use that python
location instead of "/usr/bin/env python" or "/usr/bin/python". That would
make it totally independent of your system installation. The last thing
would be probably installing pygtk in that "isolated" python installation
as OKI utilities clearly rely on this. You could use venv for that or just
simply make sure that gtk for python2 is in that python's library path.
Whatever more convenient: you won't be using that python installation for
anything else than supporting the driver.

To be honest, what I would really do is to buy a new printer from a vendor
that is known to be supporting their hardware for long term on the system
you use. Printer vendors sucks. In the end, they always stop producing
printing supplies you need and render your hardware useless. I have a combo
that I can't refill with toner anymore which has used photoconductor drum
that I can't replace anymore. I keep it around because it has a working
scanner and haven't buyed a new printer because this one "almost works".

Cheers,
Michał

śr., 16 gru 2020 o 23:48 Cameron Simpson  napisał(a):

> On 16Dec2020 21:59, Chris Green  wrote:
> >Cameron Simpson  wrote:
> >> On 16Dec2020 18:51, Chris Green  wrote:
> >> >The specific problem that finally prevented me from managing to get it
> >> >to work was a (Linux) .so file that had been built for Python 2 and,
> >> >as I don't have the source, I can't build for Python 3.
> >>
> >> ChrisA I think suggested keeping a Python 2.7 install around for this.
> >>
> >Not possible really as there are other python conflicts that start
> >appearing if one tries to retain the libraries needed.
>
> Runtime python issues like you missing symbol error, or package conflict
> issues?
>
> i.e. can you keep the OKI stuff sitting around along with Python 2
> install without having trouble with the PPA?
>
> >> >I need to have another go at fixing this as otherwise the code that
> >> >I need to manage my printer will stop working as I update my Ubuntu
> >> >systems.
>
> I'm leaning towards ChrisA's JSON suggestion at this point (absent newer
> driver software). Keep a small Python 2 programme around which uses the
> printer driver in whatever _basic_ ways you need, and _invoke that_ from
> your modern Python 3 code as an external command, passing/receiving the
> necessary information in JSON form as input.output, or on its command
> line if that is more convenient.
>
> >> Have you considered keeping a legacy VM around as well? I have a few VMs
> >> sitting here I use for some legacy software.
> >>
> >That's not a lot of use.  The programs that I want to run (by
> >converting to Python 3) are utility programs for my printer, they
> >install with a handy 'app' in my toolbar.  Having them in a VM
> >wouldn't really do much good! :-)
>
> Fair enough. It seemed cumbersome to me too, but it is a viable way to
> keep something legacy around, particularly if that legacy thing requires
> a legacy OS.
>
> >I still have python 2.  The issue is that the programs need modules
> >which come from a PPA to support Python GTK, these conflict with
> >ongoing updates to Python.  The PPA works OK in Ubuntu 20.04 but
> >prevents some updates in 20.10.  I expect it will get worse as time
> >goes on.
> [...]
> >> Guessing from the library name, have you looked on the OKI.com site
> >> for current software? Maybe here? What's your printer model?
> >>
> https://www.oki.com/au/printing/support/drivers-and-utilities/index.html
> >>
> >>
> >It comes from OKI with the Linux utilities for the printer, it's an
> >MC342N.
>
> From here?
>
>
> https://www.oki.com/uk/printing/support/drivers-and-utilities/colour-multifunction/01331401/?os=ab33=ac2
>
> This driver?
>
>
> https://www.oki.com/uk/printing/support/drivers-and-utilities/?id=46252701FZ01=drivers-and-utilities=colour-multifunction=01331401=ab33=ac2
>
> I've just installed the .deb above on my Ubuntu 20.04.1 LTS system.
> Aside from whinging about systemd it 

Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-17 Thread Chris Green
Cameron Simpson  wrote:
> >> Guessing from the library name, have you looked on the OKI.com site 
> >> for current software? Maybe here? What's your printer model?
> >> 
> >> https://www.oki.com/au/printing/support/drivers-and-utilities/index.html
> >>
> >>
> >It comes from OKI with the Linux utilities for the printer, it's an
> >MC342N.
> 
> From here?
> 
> https://www.oki.com/uk/printing/support/drivers-and-utilities/colour-multifunction/01331401/?os=ab33=ac2
>  
> 
> 
> This driver?
> 
> https://www.oki.com/uk/printing/support/drivers-and-utilities/?id=46252701FZ01=drivers-and-utilities=colour-multifunction=01331401=ab33=ac2
>  
> 
> 
> I've just installed the .deb above on my Ubuntu 20.04.1 LTS system.  
> Aside from whinging about systemd it installed ok. How do I reproduce 
> your problems? (I've got no printer of course, but...)
> 
Try running scantool.py, that should pop up a little GUI.

It uses GTK which of course in itself makes migration tricky because
one has to move from the native Python 2 code to the 'introspection'
code on Python 3.  However I can do those code changes, the killer is
that several of the scripts import pyscand and that's the Python 2
library.

The issue basically is that you can't run Python 2 GTK in a modern
system that's mostly Python 3 because the GTK libraries conflict. Thus
I need to convert the code to Python 3 but I can't because of the
library.

I've extracted all the calls/uses of pyscand from the Python code:-

pyscand.ADF:
pyscand.BEGIN:
pyscand.EVENT_PUSHSCAN:
pyscand.EVENT_PUSHSCANCCL:
pyscand.E_BUSY
pyscand.E_BUSY:
pyscand.E_CANCELED:
pyscand.E_CONNECTION_REFUSED:
pyscand.E_ERROR
pyscand.E_IOERROR:
pyscand.E_NODATA:
pyscand.E_SUCCESS
pyscand.E_SUCCESS:
pyscand.FINISHED:
pyscand.O_HEIGHT
pyscand.O_PAPER_HEIGHT
pyscand.O_PAPER_WIDTH
pyscand.O_WIDTH
pyscand.PRM_ACTION
pyscand.PRM_DEVICE
pyscand.PRM_DEVICE
pyscand.PRM_PAGE
pyscand.PRM_PATH
pyscand.PRM_PROGRESS
pyscand.PRM_PUSHSCAN_ID
pyscand.PRM_SOURCE
pyscand.PRM_STATUS
pyscand.PROGRESS:
pyscand.TO_APPLICATION:
pyscand.TO_FOLDER:
pyscand.cancel_register_client()
pyscand.cancel_scan(device)
pyscand.exit_client()
pyscand.get_device_list(devicelist)
pyscand.is_registered()
pyscand.recv_client_event()
pyscand.register_client()
pyscand.scan(self._device, self._cfg, outpath, self._scan_callback,
self._pushscanid)
pyscand.strstatus(rc)))
pyscand.strstatus(status)
pyscandsupp.to_device_name_list(devicelist)

As you can see it's mostly constants but there's that pyscand.scan()
at the bottom which I suspect is the fundamental scanning software.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread Cameron Simpson
On 16Dec2020 21:59, Chris Green  wrote:
>Cameron Simpson  wrote:
>> On 16Dec2020 18:51, Chris Green  wrote:
>> >The specific problem that finally prevented me from managing to get it
>> >to work was a (Linux) .so file that had been built for Python 2 and,
>> >as I don't have the source, I can't build for Python 3.
>>
>> ChrisA I think suggested keeping a Python 2.7 install around for this.
>>
>Not possible really as there are other python conflicts that start
>appearing if one tries to retain the libraries needed.

Runtime python issues like you missing symbol error, or package conflict 
issues?

i.e. can you keep the OKI stuff sitting around along with Python 2 
install without having trouble with the PPA?

>> >I need to have another go at fixing this as otherwise the code that 
>> >I need to manage my printer will stop working as I update my Ubuntu
>> >systems.

I'm leaning towards ChrisA's JSON suggestion at this point (absent newer 
driver software). Keep a small Python 2 programme around which uses the 
printer driver in whatever _basic_ ways you need, and _invoke that_ from 
your modern Python 3 code as an external command, passing/receiving the 
necessary information in JSON form as input.output, or on its command 
line if that is more convenient.

>> Have you considered keeping a legacy VM around as well? I have a few VMs
>> sitting here I use for some legacy software.
>>
>That's not a lot of use.  The programs that I want to run (by
>converting to Python 3) are utility programs for my printer, they
>install with a handy 'app' in my toolbar.  Having them in a VM
>wouldn't really do much good! :-)

Fair enough. It seemed cumbersome to me too, but it is a viable way to 
keep something legacy around, particularly if that legacy thing requires 
a legacy OS.

>I still have python 2.  The issue is that the programs need modules
>which come from a PPA to support Python GTK, these conflict with
>ongoing updates to Python.  The PPA works OK in Ubuntu 20.04 but
>prevents some updates in 20.10.  I expect it will get worse as time
>goes on.
[...]
>> Guessing from the library name, have you looked on the OKI.com site 
>> for current software? Maybe here? What's your printer model?
>> https://www.oki.com/au/printing/support/drivers-and-utilities/index.html
>>
>>
>It comes from OKI with the Linux utilities for the printer, it's an
>MC342N.

>From here?


https://www.oki.com/uk/printing/support/drivers-and-utilities/colour-multifunction/01331401/?os=ab33=ac2

This driver?


https://www.oki.com/uk/printing/support/drivers-and-utilities/?id=46252701FZ01=drivers-and-utilities=colour-multifunction=01331401=ab33=ac2

I've just installed the .deb above on my Ubuntu 20.04.1 LTS system.  
Aside from whinging about systemd it installed ok. How do I reproduce 
your problems? (I've got no printer of course, but...)

>I have tried asking them for a Python 3 version, maybe I should try
>again.

Can't hurt, but may not be necessary if you are prepared to split your 
Python 3 code form the Python 2 stuff that ships with the .deb.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread Chris Angelico
On Thu, Dec 17, 2020 at 9:06 AM Chris Green  wrote:
> > Also, make note of the specific Python 2 version where your software
> > works - the CPython API does change somewhat sometimes.
> >
> I still have python 2.  The issue is that the programs need modules
> which come from a PPA to support Python GTK, these conflict with
> ongoing updates to Python.  The PPA works OK in Ubuntu 20.04 but
> prevents some updates in 20.10.  I expect it will get worse as time
> goes on.
>

Try getting JUST the printer info in Python 2, and then outputting
that to stdout in JSON format. Then your Python 3 script can run your
Python 2 script, read what it sends on stdout, and do whatever it
needs to.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread Chris Green
Cameron Simpson  wrote:
> On 16Dec2020 18:51, Chris Green  wrote:
> >The specific problem that finally prevented me from managing to get it
> >to work was a (Linux) .so file that had been built for Python 2 and,
> >as I don't have the source, I can't build for Python 3.
> 
> ChrisA I think suggested keeping a Python 2.7 install around for this.
> 
Not possible really as there are other python conflicts that start
appearing if one tries to retain the libraries needed.


> >I need to have another go at fixing this as otherwise the code that I
> >need to manage my printer will stop working as I update my Ubuntu
> >systems.
> 
> Have you considered keeping a legacy VM around as well? I have a few VMs 
> sitting here I use for some legacy software.
> 
That's not a lot of use.  The programs that I want to run (by
converting to Python 3) are utility programs for my printer, they
install with a handy 'app' in my toolbar.  Having them in a VM
wouldn't really do much good! :-)


> Have you checked an upgraded Ubuntu to failure to run your software 
> using Python 2? Python 2 won't be installed by default, but I'm pretty 
> sure you can add it in. It is just the "system Python" which is moving 
> to Python 3.
> 
> Also, make note of the specific Python 2 version where your software 
> works - the CPython API does change somewhat sometimes.
> 
I still have python 2.  The issue is that the programs need modules
which come from a PPA to support Python GTK, these conflict with
ongoing updates to Python.  The PPA works OK in Ubuntu 20.04 but
prevents some updates in 20.10.  I expect it will get worse as time
goes on.


> >The specific error I'm getting is as follows:-
> >File "/usr/libexec/okimfputl.new/guicom.py", line 66, in  import 
> > pyscand
> >ImportError: /usr/libexec/okimfpdrv/pyscand.so: undefined symbol: 
> > _Py_ZeroStruct
> 
> 
> Guessing from the library name, have you looked on the OKI.com site for 
> current software? Maybe here? What's your printer model?
> 
> https://www.oki.com/au/printing/support/drivers-and-utilities/index.html
> 
> Not that I've found anything helpful...
> 
> What Ubuntu package supplies that .so file?
> 
It comes from OKI with the Linux utilities for the printer, it's an
MC342N.

I have tried asking them for a Python 3 version, maybe I should try
again.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread Chris Angelico
On Thu, Dec 17, 2020 at 8:26 AM Cameron Simpson  wrote:
>
> On 16Dec2020 18:51, Chris Green  wrote:
> >The specific problem that finally prevented me from managing to get it
> >to work was a (Linux) .so file that had been built for Python 2 and,
> >as I don't have the source, I can't build for Python 3.
>
> ChrisA I think suggested keeping a Python 2.7 install around for this.

(MRAB did, but I agree with it.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread Cameron Simpson
On 16Dec2020 18:51, Chris Green  wrote:
>The specific problem that finally prevented me from managing to get it
>to work was a (Linux) .so file that had been built for Python 2 and,
>as I don't have the source, I can't build for Python 3.

ChrisA I think suggested keeping a Python 2.7 install around for this.

>I need to have another go at fixing this as otherwise the code that I
>need to manage my printer will stop working as I update my Ubuntu
>systems.

Have you considered keeping a legacy VM around as well? I have a few VMs 
sitting here I use for some legacy software.

Have you checked an upgraded Ubuntu to failure to run your software 
using Python 2? Python 2 won't be installed by default, but I'm pretty 
sure you can add it in. It is just the "system Python" which is moving 
to Python 3.

Also, make note of the specific Python 2 version where your software 
works - the CPython API does change somewhat sometimes.

>The specific error I'm getting is as follows:-
>File "/usr/libexec/okimfputl.new/guicom.py", line 66, in  import 
> pyscand
>ImportError: /usr/libexec/okimfpdrv/pyscand.so: undefined symbol: 
> _Py_ZeroStruct


Guessing from the library name, have you looked on the OKI.com site for 
current software? Maybe here? What's your printer model?

https://www.oki.com/au/printing/support/drivers-and-utilities/index.html

Not that I've found anything helpful...

What Ubuntu package supplies that .so file?

>Is there *any* other way around this, like a 'compatibility module' to
>use Python 2 .so files in Python 3 or anything like it?  I have all
>the Python code and have (up to hitting this problem) converted it to
>Python 3.

Almost certainly not. I think ChrisA's Python 2 suggestion is the go 
here.

You may need to manually copy the requisite .so files if the package is 
about to vanish.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread Chris Angelico
On Thu, Dec 17, 2020 at 7:27 AM MRAB  wrote:
>
> On 2020-12-16 19:16, Chris Angelico wrote:
> > On Thu, Dec 17, 2020 at 6:06 AM Chris Green  wrote:
> >>
> >> Some time ago (in July) I asked some questions here
> >> about problems migrating some code from Python 2 to Python 3.
> >>
> >> The specific problem that finally prevented me from managing to get it
> >> to work was a (Linux) .so file that had been built for Python 2 and,
> >> as I don't have the source, I can't build for Python 3.
> >>
> >> I need to have another go at fixing this as otherwise the code that I
> >> need to manage my printer will stop working as I update my Ubuntu
> >> systems.
> >>
> >> The specific error I'm getting is as follows:-
> >>
> >> File "/usr/libexec/okimfputl.new/guicom.py", line 66, in  
> >> import pyscand
> >> ImportError: /usr/libexec/okimfpdrv/pyscand.so: undefined symbol: 
> >> _Py_ZeroStruct
> >>
> >> I know this is because the extension module is compiled for Python 2
> >> and _Py_ZeroStruct is only available in Python 2.  I don't have the C
> >> code for the module.
> >>
> >> Is there *any* other way around this, like a 'compatibility module' to
> >> use Python 2 .so files in Python 3 or anything like it?  I have all
> >> the Python code and have (up to hitting this problem) converted it to
> >> Python 3.
> >>
> >
> > Basically no. The error you're seeing is a nice noisy one, but even if
> > you got past that, there'll be a LOT of incompatibilities.
> > Unfortunately, a quick google search for 'pyscand' showed up
> > places where you've asked this question, suggesting that nobody else
> > uses this library. It looks like you're going to have to take a big
> > step back and figure out what the library is doing for you, and
> > reimplement that somehow. :(
> >
> > Good luck.
> >
> Alternatively, run something in Python 2.7 that can import it and talk
> to the main Python 3 code, at least until you have a long-term solution.

Yes, that's a possibility. A hack, but a definite hack. But this is
one of the places where the universality of stdin/stdout is extremely
handy.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread MRAB

On 2020-12-16 19:16, Chris Angelico wrote:

On Thu, Dec 17, 2020 at 6:06 AM Chris Green  wrote:


Some time ago (in July) I asked some questions here
about problems migrating some code from Python 2 to Python 3.

The specific problem that finally prevented me from managing to get it
to work was a (Linux) .so file that had been built for Python 2 and,
as I don't have the source, I can't build for Python 3.

I need to have another go at fixing this as otherwise the code that I
need to manage my printer will stop working as I update my Ubuntu
systems.

The specific error I'm getting is as follows:-

File "/usr/libexec/okimfputl.new/guicom.py", line 66, in  import 
pyscand
ImportError: /usr/libexec/okimfpdrv/pyscand.so: undefined symbol: 
_Py_ZeroStruct

I know this is because the extension module is compiled for Python 2
and _Py_ZeroStruct is only available in Python 2.  I don't have the C
code for the module.

Is there *any* other way around this, like a 'compatibility module' to
use Python 2 .so files in Python 3 or anything like it?  I have all
the Python code and have (up to hitting this problem) converted it to
Python 3.



Basically no. The error you're seeing is a nice noisy one, but even if
you got past that, there'll be a LOT of incompatibilities.
Unfortunately, a quick google search for 'pyscand' showed up
places where you've asked this question, suggesting that nobody else
uses this library. It looks like you're going to have to take a big
step back and figure out what the library is doing for you, and
reimplement that somehow. :(

Good luck.

Alternatively, run something in Python 2.7 that can import it and talk 
to the main Python 3 code, at least until you have a long-term solution.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread Chris Angelico
On Thu, Dec 17, 2020 at 6:06 AM Chris Green  wrote:
>
> Some time ago (in July) I asked some questions here
> about problems migrating some code from Python 2 to Python 3.
>
> The specific problem that finally prevented me from managing to get it
> to work was a (Linux) .so file that had been built for Python 2 and,
> as I don't have the source, I can't build for Python 3.
>
> I need to have another go at fixing this as otherwise the code that I
> need to manage my printer will stop working as I update my Ubuntu
> systems.
>
> The specific error I'm getting is as follows:-
>
> File "/usr/libexec/okimfputl.new/guicom.py", line 66, in  import 
> pyscand
> ImportError: /usr/libexec/okimfpdrv/pyscand.so: undefined symbol: 
> _Py_ZeroStruct
>
> I know this is because the extension module is compiled for Python 2
> and _Py_ZeroStruct is only available in Python 2.  I don't have the C
> code for the module.
>
> Is there *any* other way around this, like a 'compatibility module' to
> use Python 2 .so files in Python 3 or anything like it?  I have all
> the Python code and have (up to hitting this problem) converted it to
> Python 3.
>

Basically no. The error you're seeing is a nice noisy one, but even if
you got past that, there'll be a LOT of incompatibilities.
Unfortunately, a quick google search for 'pyscand' showed up
places where you've asked this question, suggesting that nobody else
uses this library. It looks like you're going to have to take a big
step back and figure out what the library is doing for you, and
reimplement that somehow. :(

Good luck.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 2 to Python 3 .so library incompatibility - need help

2020-12-16 Thread Chris Green
Some time ago (in July) I asked some questions here
about problems migrating some code from Python 2 to Python 3.  

The specific problem that finally prevented me from managing to get it
to work was a (Linux) .so file that had been built for Python 2 and,
as I don't have the source, I can't build for Python 3.

I need to have another go at fixing this as otherwise the code that I
need to manage my printer will stop working as I update my Ubuntu
systems.

The specific error I'm getting is as follows:-

File "/usr/libexec/okimfputl.new/guicom.py", line 66, in  import 
pyscand
ImportError: /usr/libexec/okimfpdrv/pyscand.so: undefined symbol: 
_Py_ZeroStruct

I know this is because the extension module is compiled for Python 2
and _Py_ZeroStruct is only available in Python 2.  I don't have the C
code for the module. 

Is there *any* other way around this, like a 'compatibility module' to
use Python 2 .so files in Python 3 or anything like it?  I have all
the Python code and have (up to hitting this problem) converted it to
Python 3.


-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list