Skip to contentSkip to conversation

package/python-txtorcon.mk: drop _py3 file for python 2.x to fix pycompile issue

PATCH Superseded Peter Korsgaard 2 participants 3 messages Sep 30, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/python-txtorcon.mk: drop _py3 file for python 2.x to fix pycompile issue

Fixes:
http://autobuild.buildroot.net/results/76b580000e6311e88584874f942517badd6fadf6/

python-txtorcon DOES support python 2.x, but it contains some optional python 3 / async code in controller_py3.py which is conditionally used from controller.py:

try:
from .controller_py3 import _AsyncOnionAuthContext HAVE_ASYNC = True
except Exception:
HAVE_ASYNC = False

pycompile unfortunately errors out on the async code:

../scripts/pycompile.py ..
error: File "/usr/lib/python2.7/site-packages/txtorcon/controller_py3.py", line 13

    async def __aenter__(self):
            ^

SyntaxError: invalid syntax

As a workaround, simply drop the unusable _py3 file from TARGET_DIR if building for python 2.x.

---
 package/python-txtorcon/python-txtorcon.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
package/python-txtorcon/python-txtorcon.mk +9 -0
index a01c0b2511..e25ce8ba38 100644
@@ -11,4 +11,13 @@ PYTHON_TXTORCON_SETUP_TYPE = setuptools
 PYTHON_TXTORCON_LICENSE = MIT
 PYTHON_TXTORCON_LICENSE_FILES = LICENSE
 
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+# only needed/valid for python 3.x
+define PYTHON_TXTORCON_RM_PY3_FILE
+	rm -f $(TARGET_DIR)//usr/lib/python*/site-packages/txtorcon/controller_py3.py
+endef
+
+PYTHON_TXTORCON_POST_INSTALL_TARGET_HOOKS += PYTHON_TXTORCON_RM_PY3_FILE
+endif
+
 $(eval $(python-package))
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 package/python-txtorcon.mk: drop _py3 file for python 2.x to fix pycompile issue

Hi Peter,

Quoted 34 lines · Peter Korsgaard

Fixes:
http://autobuild.buildroot.net/results/76b580000e6311e88584874f942517badd6fadf6/

python-txtorcon DOES support python 2.x, but it contains some optional python 3 / async code in controller_py3.py which is conditionally used from controller.py:

try:
from .controller_py3 import _AsyncOnionAuthContext HAVE_ASYNC = True
except Exception:
HAVE_ASYNC = False

pycompile unfortunately errors out on the async code:

../scripts/pycompile.py ..
error: File "/usr/lib/python2.7/site-packages/txtorcon/controller_py3.py", line 13

    async def __aenter__(self):
            ^

SyntaxError: invalid syntax

As a workaround, simply drop the unusable _py3 file from TARGET_DIR if building for python 2.x.

---
 package/python-txtorcon/python-txtorcon.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
package/python-txtorcon/python-txtorcon.mk +0 -0
index a01c0b2511..e25ce8ba38 100644

package/python-txtorcon/python-txtorcon.mk PYTHON_TXTORCON_SETUP_TYPE = setuptools · line 17

Quoted 7 lines
package/python-txtorcon/python-txtorcon.mk +4 -0
@@ -11,4 +11,13 @@ PYTHON_TXTORCON_SETUP_TYPE = setuptools
 PYTHON_TXTORCON_LICENSE = MIT
 PYTHON_TXTORCON_LICENSE_FILES = LICENSE
 
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+# only needed/valid for python 3.x
+define PYTHON_TXTORCON_RM_PY3_FILE
+	rm -f $(TARGET_DIR)//usr/lib/python*/site-packages/txtorcon/controller_py3.py

Redundant '/' before 'usr/'.

baruch

Quoted 6 lines
package/python-txtorcon/python-txtorcon.mk +5 -0
+endef
+
+PYTHON_TXTORCON_POST_INSTALL_TARGET_HOOKS += PYTHON_TXTORCON_RM_PY3_FILE
+endif
+
 $(eval $(python-package))
Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#2 lore raw

PATCH 1/1 package/python-txtorcon.mk: drop _py3 file for python 2.x to fix pycompile issue

Quoted 41 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

Hi Peter,

Quoted 37 lines · Peter Korsgaard

Fixes:
http://autobuild.buildroot.net/results/76b580000e6311e88584874f942517badd6fadf6/

python-txtorcon DOES support python 2.x, but it contains some optional python 3 / async code in controller_py3.py which is conditionally used from controller.py:

try:
from .controller_py3 import _AsyncOnionAuthContext HAVE_ASYNC = True
except Exception:
HAVE_ASYNC = False

pycompile unfortunately errors out on the async code:

../scripts/pycompile.py ..
error: File "/usr/lib/python2.7/site-packages/txtorcon/controller_py3.py", line 13
async def __aenter__(self):
^
SyntaxError: invalid syntax

As a workaround, simply drop the unusable _py3 file from TARGET_DIR if building for python 2.x.

---
package/python-txtorcon/python-txtorcon.mk | 9 +++++++++

1 file changed, 9 insertions(+)
package/python-txtorcon/python-txtorcon.mk +0 -0
index a01c0b2511..e25ce8ba38 100644
@@ -11,4 +11,13 @@ PYTHON_TXTORCON_SETUP_TYPE = setuptools

PYTHON_TXTORCON_LICENSE = MIT
PYTHON_TXTORCON_LICENSE_FILES = LICENSE

Quoted 6 lines

package/python-txtorcon/python-txtorcon.mk PYTHON_TXTORCON_SETUP_TYPE = setuptools · line 17

Quoted 4 lines
package/python-txtorcon/python-txtorcon.mk +4 -0
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+# only needed/valid for python 3.x
+define PYTHON_TXTORCON_RM_PY3_FILE
+	rm -f $(TARGET_DIR)//usr/lib/python*/site-packages/txtorcon/controller_py3.py

Redundant '/' before 'usr/'.

Ups, indeed - Will fix.

Signature · 1 line
Bye, Peter Korsgaard