Jump to content


Photo

develop: python3 transition


  • Please log in to reply
371 replies to this topic

Re: develop: python3 transition #261 40H3X

  • Forum Moderator
    PLi® Contributor
  • 5,938 posts

+191
Excellent

Posted 11 January 2022 - 19:05

Thanks at @foxbox and @blzr, I could but an update of my local repositories would remove the patch?


Hardware: Vu+ Uno 4K SE - Vu+ Duo 4K  - Fuba 78 cm - Tripleblock LNB Quad 19.2/23.5/28.2 - DS918+
Software : OpenPLi - OSCam - Settings van Hans - Autotimer - EPGImport

---------------------------------------------------------------------------------------------------------------------------------------

Remember: Upvote with the rep_up.png button for any user/post you find to be helpful, informative, or deserving of recognition!

---------------------------------------------------------------------------------------------------------------------------------------

Many answers to your question can be found in our new and improved wiki

Note: I do not provide support via PM !.


Re: develop: python3 transition #262 blzr

  • PLi® Core member
  • 2,270 posts

+118
Excellent

Posted 11 January 2022 - 19:30

1) I suppose this plugin you'll build just once (unless you'd like to build image from scratch for some reason), so you can even patch sources in tmp/work directory
2) if you add a patch in your local vu bsp repo it won't be affected by openpli updates until vu bsp is updated upstream


True sarcasm doesn't need green font...

Re: develop: python3 transition #263 rantanplan

  • PLi® Contributor
  • 1,857 posts

+87
Good

Posted 11 January 2022 - 19:51

 

 

You need to patch your local source to fix py3 syntax errors...

Full 2to3 diff for this plugin attached

 

(not sure how we'll proceed with vendors specific plugins like this? additional branch in bsp?)

 

for py3 all bsp changed



Re: develop: python3 transition #264 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 21 January 2022 - 20:38

Yes, it makes sense to be unhappy, we used to compile all those years .py files to .pyo files.

 

With python3, now files are still compiled and moved to __pycache__ folder.

 

There is still a way to bring back py to pyc on same folder: python -m compileall -b .

 

https://stackoverflo...s-in-python-3-4

OE-A already used "compileall -b"

 

https://github.com/o...91066e69cb9fR25

 

Edit1. I guess we need a small patch to make legacy by default = True, that will force generating .pyc without big changes.

 

https://github.com/p...b/compileall.py


Edited by athoik, 21 January 2022 - 20:52.

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: develop: python3 transition #265 Huevos

  • PLi® Contributor
  • 4,621 posts

+161
Excellent

Posted 21 January 2022 - 20:50

Yes... :)

Attached Files

  • Attached File  5.jpg   129.99KB   6 downloads


Re: develop: python3 transition #266 WanWizard

  • PLi® Core member
  • 70,205 posts

+1,798
Excellent

Posted 21 January 2022 - 22:02

Funny to see that when I brought it up, I was beaten to within an inch of my life for such a stupid idea... :P :D


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: develop: python3 transition #267 Huevos

  • PLi® Contributor
  • 4,621 posts

+161
Excellent

Posted 21 January 2022 - 22:27

Funny to see that when I brought it up, I was beaten to within an inch of my life for such a stupid idea... :P :D

It has been done on OE-A so it is still possible to shoehorn the image into small flash boxes.

 

No idea how others have resources to build all those boxes. They must have a bank of build servers.



Re: develop: python3 transition #268 blzr

  • PLi® Core member
  • 2,270 posts

+118
Excellent

Posted 22 January 2022 - 00:46

Funny to see that when I brought it up, I was beaten to within an inch of my life for such a stupid idea... :P :D

yup, posts #67-#73 from this very thread come to mind somehow... B)

//anyway, all's well that ends well  :P 


True sarcasm doesn't need green font...

Re: develop: python3 transition #269 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 22 January 2022 - 11:34

Here is the patch for python3 to bring back the .pyc on the same folder.

 

diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index fe31f43..ba972c8 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -389,7 +389,7 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
     tag = sys.implementation.cache_tag
     if tag is None:
         raise NotImplementedError('sys.implementation.cache_tag is None')
-    almost_filename = ''.join([(base if base else rest), sep, tag])
+    almost_filename = ''.join([(base if base else rest)])
     if optimization is None:
         if sys.flags.optimize == 0:
             optimization = ''
@@ -426,7 +426,7 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
             head.lstrip(path_separators),
             filename,
         )
-    return _path_join(head, _PYCACHE, filename)
+    return _path_join(head, filename)


 def source_from_cache(path):

 

root@osmio4k:~/test# ls
libpython3.9-1.0_3.9.9-r0_armv7ahf-neon.ipk  python3-core_3.9.9-r0_armv7ahf-neon.ipk      test.py
root@osmio4k:~/test# python -c "import test"
hello
root@osmio4k:~/test# ls
libpython3.9-1.0_3.9.9-r0_armv7ahf-neon.ipk  python3-core_3.9.9-r0_armv7ahf-neon.ipk      test.py                                      test.pyc

 

I guess we can even change it to use .pyo instead of .pyc! But nope, let's keep .pyc to recognize 3or2 :)


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: develop: python3 transition #270 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 22 January 2022 - 16:06

Also need to bring back the default optimization level to 1 as we used to, because it seems that we are getting multiple files now.

 

Eg.

WARNING: enigma2-plugin-systemplugins-servicemp3-gitAUTOINC+aa60f9a1d0-r0 do_package: QA Issue: enigma2-plugin-systemplugins-servicemp3: Files/directories were installed but not shipped in any package:
  /usr/lib/enigma2/python/Plugins/SystemPlugins/ServiceMP3/__init__.pyc
  /usr/lib/enigma2/python/Plugins/SystemPlugins/ServiceMP3/__init__.opt-1.pyc

 

diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index fe31f43..6ce18db 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -389,13 +389,13 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
     tag = sys.implementation.cache_tag
     if tag is None:
         raise NotImplementedError('sys.implementation.cache_tag is None')
-    almost_filename = ''.join([(base if base else rest), sep, tag])
+    almost_filename = ''.join([(base if base else rest)])
     if optimization is None:
         if sys.flags.optimize == 0:
             optimization = ''
         else:
             optimization = sys.flags.optimize
-    optimization = str(optimization)
+    optimization = ''
     if optimization != '':
         if not optimization.isalnum():
             raise ValueError('{!r} is not alphanumeric'.format(optimization))
@@ -426,7 +426,7 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
             head.lstrip(path_separators),
             filename,
         )
-    return _path_join(head, _PYCACHE, filename)
+    return _path_join(head, filename)


 def source_from_cache(path):
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 116ee33..0e85d62 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -627,7 +627,7 @@ _PyConfig_InitCompatConfig(PyConfig *config)
     config->bytes_warning = -1;
     config->inspect = -1;
     config->interactive = -1;
-    config->optimization_level = -1;
+    config->optimization_level = 1;
     config->parser_debug= -1;
     config->write_bytecode = -1;
     config->verbose = -1;
@@ -658,7 +658,7 @@ config_init_defaults(PyConfig *config)
     config->bytes_warning = 0;
     config->inspect = 0;
     config->interactive = 0;
-    config->optimization_level = 0;
+    config->optimization_level = 1;
     config->parser_debug= 0;
     config->write_bytecode = 1;
     config->verbose = 0;
@@ -1996,7 +1996,7 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions,
         /* case 'J': reserved for Jython */

         case 'O':
-            config->optimization_level++;
+            config->optimization_level = 1;
             break;

         case 'B':

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: develop: python3 transition #271 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 23 January 2022 - 14:07

What will be the plan guys? Go for .pyc?


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: develop: python3 transition #272 WanWizard

  • PLi® Core member
  • 70,205 posts

+1,798
Excellent

Posted 23 January 2022 - 14:58

Instead of .py you mean?

 

Yes, absolutely, identical to how we do it now with the .pyo's in the image, and the .py's in a -src package.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: develop: python3 transition #273 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 23 January 2022 - 15:22

That means extra job for hardknott-py3 branch. From .pyo to .py and now back to .pyc

 

 

 

@Hains are you ok with that? Send the patch for .pyc ?


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: develop: python3 transition #274 WanWizard

  • PLi® Core member
  • 70,205 posts

+1,798
Excellent

Posted 23 January 2022 - 15:44

Why are those patches needed?

 

In the current  bb's (in develop) we already run a "compileall" to make the pyo's for python2, and split the py's off into a separate package. That would make pyc's for python3, so that part is covered.

 

Python3 will use the pyc by default, if no py exists in the same directory (and never is the py does exist, which is different from python2, but something I have no issue with, only developers need source on their box).


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: develop: python3 transition #275 Beeker

  • PLi® Contributor
  • 1,602 posts

+203
Excellent

Posted 23 January 2022 - 15:48

That means extra job for hardknott-py3 branch. From .pyo to .py and now back to .pyc

 

 

 

@Hains are you ok with that? Send the patch for .pyc ?

 

To save boxes with small flash memory I agree.


Dreambox dm920, Uclan Ustym4Kpro, Gigablue UHD TRIO 4K and Dreambox dm8000. Wavefrontier T55 13.0|19.2|23.5|28.2 + Ziggo.


Re: develop: python3 transition #276 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 23 January 2022 - 16:11

Why are those patches needed?

 

In the current  bb's (in develop) we already run a "compileall" to make the pyo's for python2, and split the py's off into a separate package. That would make pyc's for python3, so that part is covered.

 

Python3 will use the pyc by default, if no py exists in the same directory (and never is the py does exist, which is different from python2, but something I have no issue with, only developers need source on their box).

We already changed logic on several packages to include .py. Now we have to move .py back to -src and deploy .pyc files.

 

Also we need to change some plugins to check for .pyc file existance. Used to check .pyo, changed to .py and now to .pyc ;)

 

Also we used to delete them! So now we need them back.

        find ${D}${libdir}/enigma2/python/ -name '*.pyc' -exec rm {} \;

Edited by athoik, 23 January 2022 - 16:16.

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: develop: python3 transition #277 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 23 January 2022 - 18:37

@WanWizard, could you please create a python3 branch from current master and provide push,merge rights for Hains, Nautilus7, Athoik (me)  for the following:

 

https://github.com/O...enigma2-plugins

https://github.com/OpenPLi/servicemp3


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: develop: python3 transition #278 WanWizard

  • PLi® Core member
  • 70,205 posts

+1,798
Excellent

Posted 23 January 2022 - 18:55

Hains and you should have access now, I've send an invitation to Nautilus7.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: develop: python3 transition #279 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 23 January 2022 - 18:59

Great! Thanks!


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: develop: python3 transition #280 nautilus7

  • Senior Member
  • 229 posts

+6
Neutral

Posted 23 January 2022 - 20:30

Hains and you should have access now, I've send an invitation to Nautilus7.

 

 

Just accepted. Thanks! 




9 user(s) are reading this topic

0 members, 9 guests, 0 anonymous users