Re: I'm finally disentangled from Python 2, thank you everyone

2020-12-30 Thread Christian Gollwitzer

Am 30.12.20 um 11:58 schrieb Chris Green:

Could I ask you to write up a post on what you did here? I've never used
cx-freeze but it sounds like a useful thing for keeping legacy stuff
functioning. A writeup from someone who's actually used it for that
would be welcome.


Of course, here is what I wrote in my 'self help' Dokuwiki wiki about it. It 
refers
specifically to the OKI software I wanted to keep using but it should be fairly
easy to apply a similar process to other software.


 I asked on the Python newsgroup and the one suggestion that seemed 
feasible was to
 package the OKI software with all its dependencies on a system which still 
has Gtk2
 and Python 2 and then install the whole package on esprimo.

 After a bit of looking around at Snap, Appimage and such I found cx_freeze 
which is
 aimed specifically at Python.  The latest version doesn't support Python 2 
but 5.1.1
 does, so this is how I've have done it

   * Install xubuntu 18.04 on my old Revo system (has to be 64-bit), 18.04 
is still in support. (has to be 64-bit simply because the final target is 
64-bit)
   * Install cx_freeze 5.1.1 on Revo
   * Install the Oki software on Revo, check that it works, pulls in lots 
of libraries and packages.
   * Run 'cxfreeze /usr/libexec/okimfputl/scantool.py' (scantool.py is the 
utility I want to run on systems without Python 2)
   * Copy the resulting 'dist' directory to the target system, name isn't 
critical

 Then the fun starts.  There's quite a few more libraries and packages are 
required
 and the scan daemon needs to be runnable.  (The scan daemon was, 
fortunately, just
 a compiled program so ran 'as is' without issues)

 Files needed in /usr/libexec/okimfputl and /usr/libexec/okimfpdrv
 "
 There are a lot of hard coded references to /usr/libexec/okimfputl and
 /usr/libexec/okimfpdrv, it **might** be possible to change all these but
 I decided it would be less painful to use a couple of symbolic links
 to locations in /usr/local/libexec and put the required files in
 /usr/local/libexec/okimfputl and /usr/local/libexec/okimfpdrv.

 I discovered what files are needed in these directories by simply running
 scantool on the target and fixing each error as it arose.

 Other Python package and library files
 "
 I have installed the "dist" created by cxfreeze in 
/usr/local/libexec/okicxfreeze. The executable to run is thus 
/usr/local/libexec/okicxfreeze/scantool.

 There are also a few .so libraries and Python packages needed, as above I
 just found these by running scantool and fixing each error as it appeared.
 The system library files are put in /usr/local/lib, you have to run 
ldconfig
 after each file is put there.  The Python packages (including the dreaded
 pyscand.so) have to be put in the working directory when scantool is run,
 so I have put them in /usr/local/libexec/okicxfreeze where the scantool
 executable is.


I hope the above is useful.  As I said it refers specifically to the scantool.py
that I needed for my Oki scanner but I think the description is general enough 
to
be useful.

The basic process is:-

 Find (or create) a system where the software you want to run works OK.

 Install cx-freeze 5.1.1 on that system and run 'cxfreeze '

 Check that the executable created by cxfreeze works on the system you 
built it on

 Copy the executable (and its 'dist' environment) to the target where you 
want to run it

 Try and run it on the target

 Iteratively work through the errors it throws up when you run it, in my 
case these were:-

 Missing .so system library files, copy them from the build system to 
somewhere
 they will be found on the target.  You could put them in a 'private to 
the
 package' directory and set LD_LIBRARY_PATH or do as I did and put them 
in
 a standard library location (and run ldconfig after adding each).



I've used pyinstaller in the past, and it seems to do a better job with 
that. It usually copies all the sytem libraries, too, but would fail 
with /usr/libexec/okimfputl  & friends


Christian

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


Re: I'm finally disentangled from Python 2, thank you everyone

2020-12-30 Thread Chris Green
> Could I ask you to write up a post on what you did here? I've never used 
> cx-freeze but it sounds like a useful thing for keeping legacy stuff 
> functioning. A writeup from someone who's actually used it for that 
> would be welcome.
> 
Of course, here is what I wrote in my 'self help' Dokuwiki wiki about it. It 
refers
specifically to the OKI software I wanted to keep using but it should be fairly
easy to apply a similar process to other software.


I asked on the Python newsgroup and the one suggestion that seemed feasible 
was to
package the OKI software with all its dependencies on a system which still 
has Gtk2
and Python 2 and then install the whole package on esprimo.

After a bit of looking around at Snap, Appimage and such I found cx_freeze 
which is
aimed specifically at Python.  The latest version doesn't support Python 2 
but 5.1.1
does, so this is how I've have done it

  * Install xubuntu 18.04 on my old Revo system (has to be 64-bit), 18.04 
is still in support. (has to be 64-bit simply because the final target is 
64-bit)
  * Install cx_freeze 5.1.1 on Revo
  * Install the Oki software on Revo, check that it works, pulls in lots of 
libraries and packages.
  * Run 'cxfreeze /usr/libexec/okimfputl/scantool.py' (scantool.py is the 
utility I want to run on systems without Python 2)
  * Copy the resulting 'dist' directory to the target system, name isn't 
critical

Then the fun starts.  There's quite a few more libraries and packages are 
required
and the scan daemon needs to be runnable.  (The scan daemon was, 
fortunately, just
a compiled program so ran 'as is' without issues)

Files needed in /usr/libexec/okimfputl and /usr/libexec/okimfpdrv
"
There are a lot of hard coded references to /usr/libexec/okimfputl and
/usr/libexec/okimfpdrv, it **might** be possible to change all these but
I decided it would be less painful to use a couple of symbolic links
to locations in /usr/local/libexec and put the required files in
/usr/local/libexec/okimfputl and /usr/local/libexec/okimfpdrv.

I discovered what files are needed in these directories by simply running
scantool on the target and fixing each error as it arose.

Other Python package and library files
"
I have installed the "dist" created by cxfreeze in 
/usr/local/libexec/okicxfreeze. The executable to run is thus 
/usr/local/libexec/okicxfreeze/scantool.

There are also a few .so libraries and Python packages needed, as above I
just found these by running scantool and fixing each error as it appeared.
The system library files are put in /usr/local/lib, you have to run ldconfig
after each file is put there.  The Python packages (including the dreaded
pyscand.so) have to be put in the working directory when scantool is run,
so I have put them in /usr/local/libexec/okicxfreeze where the scantool
executable is.


I hope the above is useful.  As I said it refers specifically to the scantool.py
that I needed for my Oki scanner but I think the description is general enough 
to
be useful.

The basic process is:-

Find (or create) a system where the software you want to run works OK.

Install cx-freeze 5.1.1 on that system and run 'cxfreeze '

Check that the executable created by cxfreeze works on the system you built 
it on

Copy the executable (and its 'dist' environment) to the target where you 
want to run it

Try and run it on the target

Iteratively work through the errors it throws up when you run it, in my 
case these were:-

Missing .so system library files, copy them from the build system to 
somewhere
they will be found on the target.  You could put them in a 'private to 
the
package' directory and set LD_LIBRARY_PATH or do as I did and put them 
in
a standard library location (and run ldconfig after adding each).

Missing Python packages, in my case this included the dreaded 
pyscand.so, I
just put them in the 'package' directory with the executable and in the
script that calls the executable set the directory so they are found.

Data files.  In my case these had locations which were hard coded into 
all
the various scripts along with scantool.py.  I *could* have changed all 
the
code before building but that would have been a bit messy and error 
prone
and there was no guarantee that there weren't some addresses hard coded 
in
the executable files and libraries so I just (as you can see above) set 
up
the required directories and put the required files there.  In my case 
this
was just three or four configuration files and four .png image files.

Note: It seems that what cxfreeze does is to create the *Python* 
environment needed
to run a program.  It assumes 

Re: I'm finally disentangled from Python 2, thank you everyone

2020-12-29 Thread Cameron Simpson
On 29Dec2020 21:20, Chris Green  wrote:
>Well, it has taken me a while, but I now seem to have finally detached
>myself from any Python 2 dependencies on my various systems.
[...]
>On my desktop machine it was a bit more difficult because of the Oki
>scanner utility which I have asked about quite a lot here.  It has a
>.so file built for Python 2 which I couldn't convert.  In the end
>(following ideas from here) I have packaged it using cx-freeze so that
>the utility and all the libraries etc. that it needs are run 'as a
>package' with all the old Python 2 dependencies inside the package.  
>[...]

Could I ask you to write up a post on what you did here? I've never used 
cx-freeze but it sounds like a useful thing for keeping legacy stuff 
functioning. A writeup from someone who's actually used it for that 
would be welcome.

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


I'm finally disentangled from Python 2, thank you everyone

2020-12-29 Thread Chris Green
Well, it has taken me a while, but I now seem to have finally detached
myself from any Python 2 dependencies on my various systems.

Firstly may I say thank you to everyone who has helped me with this
(and with other issues) here on the Python list, you are a friendly
and helpful group of people.

I run (mostly) xubuntu systems and, as of xubuntu 20.04 Python 2
should have gone.

First I changed all of my code to use Python 3, this was mostly pretty
trivial (like my code in many ways!), the only slightly difficult
areas were the changes to Gtk and the string->bytes thing which I had
a problem with but, with help from here, was sorted fairly easily.

As regards installed software on my laptop it was easy, I don't quite
know when it all went but I didn't have to do anything, the current
xubuntu 20.10 installation has no Python 2 on it at all.

On my desktop machine it was a bit more difficult because of the Oki
scanner utility which I have asked about quite a lot here.  It has a
.so file built for Python 2 which I couldn't convert.  In the end
(following ideas from here) I have packaged it using cx-freeze so that
the utility and all the libraries etc. that it needs are run 'as a
package' with all the old Python 2 dependencies inside the package. It
took me a while to get it all packaged but it is now done and the
utility runs successfully on my desktop which is 'Python 2 free'
(except of course for files within the Oki utility package).

Phew! :-)


... and thanks again for all the help and support here.

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