All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue
@ 2020-10-02 13:40 Peter Korsgaard
  2020-10-02 13:40 ` [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue Peter Korsgaard
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Peter Korsgaard @ 2020-10-02 13:40 UTC (permalink / raw)
  To: buildroot

Fixes:
http://autobuild.buildroot.net/results/4ca459d54545c0e20b0f0cdc63bd81844ecd7f36/

aenum has conditional logic to load python 3.x code located in test_v3.py:

if pyver >= 3.0:
    from aenum.test_v3 import TestEnumV3, TestOrderV3, TestNamedTupleV3

And contains logic in setup.py to drop that file during setup.py install if
building for python 2.x:

py3_only = ('aenum/test_v3.py', )
..
if __name__ == '__main__':
    if 'install' in sys.argv:
        import os, sys
	..
        if sys.version_info[0] != 3:
            for file in py3_only:
                try:
                    os.unlink(file)

But this doesn't work in Buildroot as pkg-python.dk first does setup.py
build (which copies test_v3.py to the build directory) before setup.py
install, so test_v3.py gets installed, leading to errors from pycompile:

error:   File "/usr/lib/python2.7/site-packages/aenum/test_v3.py", line 12
    class MagicAutoNumberEnum(Enum, settings=AutoNumber):
                                            ^
SyntaxError: invalid syntax

As a workaround, add a hook to drop it from the target directory when
building for python 2.x.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
 package/python-aenum/python-aenum.mk | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/package/python-aenum/python-aenum.mk b/package/python-aenum/python-aenum.mk
index 1d5322ef41..97fcbb5e86 100644
--- a/package/python-aenum/python-aenum.mk
+++ b/package/python-aenum/python-aenum.mk
@@ -11,4 +11,13 @@ PYTHON_AENUM_SETUP_TYPE = setuptools
 PYTHON_AENUM_LICENSE = BSD-3-Clause
 PYTHON_AENUM_LICENSE_FILES = aenum/LICENSE
 
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+# only needed/valid for python 3.x
+define PYTHON_AENUM_RM_PY3_FILE
+	rm -f $(TARGET_DIR)/usr/lib/python*/site-packages/aenum/test_v3.py
+endef
+
+PYTHON_AENUM_POST_INSTALL_TARGET_HOOKS += PYTHON_AENUM_RM_PY3_FILE
+endif
+
 $(eval $(python-package))
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue
  2020-10-02 13:40 [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue Peter Korsgaard
@ 2020-10-02 13:40 ` Peter Korsgaard
  2020-10-03  6:58   ` Peter Korsgaard
  2020-10-05  6:04   ` Peter Korsgaard
  2020-10-03  6:57 ` [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue Peter Korsgaard
  2020-10-05  6:04 ` Peter Korsgaard
  2 siblings, 2 replies; 6+ messages in thread
From: Peter Korsgaard @ 2020-10-02 13:40 UTC (permalink / raw)
  To: buildroot

Fixes:
http://autobuild.buildroot.net/results/72e0cc78194a1b93bf26a50742e59a1e93bde1d1/

fire has conditional logic to load test_components_py3.py when running under
Python 3.x:

if six.PY3:
  from fire import test_components_py3 as py3

pycompile unfortunately errors out on it:

../scripts/pycompile.py ..

error:   File "/usr/lib/python2.7/site-packages/fire/test_components_py3.py", line 18
    def identity(arg1, arg2: int, arg3=10, arg4: int = 20, *arg5,
                           ^
SyntaxError: invalid syntax

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

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
 package/python-fire/python-fire.mk | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/package/python-fire/python-fire.mk b/package/python-fire/python-fire.mk
index 343abbca7d..f6a2e073f0 100644
--- a/package/python-fire/python-fire.mk
+++ b/package/python-fire/python-fire.mk
@@ -11,4 +11,13 @@ PYTHON_FIRE_SETUP_TYPE = setuptools
 PYTHON_FIRE_LICENSE = Apache-2.0
 PYTHON_FIRE_LICENSE_FILES = LICENSE
 
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+# only needed/valid for python 3.x
+define PYTHON_FIRE_RM_PY3_FILE
+	rm -f $(TARGET_DIR)/usr/lib/python*/site-packages/fire/test_components_py3.py
+endef
+
+PYTHON_FIRE_POST_INSTALL_TARGET_HOOKS += PYTHON_FIRE_RM_PY3_FILE
+endif
+
 $(eval $(python-package))
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue
  2020-10-02 13:40 [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue Peter Korsgaard
  2020-10-02 13:40 ` [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue Peter Korsgaard
@ 2020-10-03  6:57 ` Peter Korsgaard
  2020-10-05  6:04 ` Peter Korsgaard
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2020-10-03  6:57 UTC (permalink / raw)
  To: buildroot

>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:

 > Fixes:
 > http://autobuild.buildroot.net/results/4ca459d54545c0e20b0f0cdc63bd81844ecd7f36/

 > aenum has conditional logic to load python 3.x code located in test_v3.py:

 > if pyver >= 3.0:
 >     from aenum.test_v3 import TestEnumV3, TestOrderV3, TestNamedTupleV3

 > And contains logic in setup.py to drop that file during setup.py install if
 > building for python 2.x:

 > py3_only = ('aenum/test_v3.py', )
 > ..
 > if __name__ == '__main__':
 >     if 'install' in sys.argv:
 >         import os, sys
 > 	..
 >         if sys.version_info[0] != 3:
 >             for file in py3_only:
 >                 try:
 >                     os.unlink(file)

 > But this doesn't work in Buildroot as pkg-python.dk first does setup.py
 > build (which copies test_v3.py to the build directory) before setup.py
 > install, so test_v3.py gets installed, leading to errors from pycompile:

 > error:   File "/usr/lib/python2.7/site-packages/aenum/test_v3.py", line 12
 >     class MagicAutoNumberEnum(Enum, settings=AutoNumber):
 >                                             ^
 > SyntaxError: invalid syntax

 > As a workaround, add a hook to drop it from the target directory when
 > building for python 2.x.

 > Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue
  2020-10-02 13:40 ` [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue Peter Korsgaard
@ 2020-10-03  6:58   ` Peter Korsgaard
  2020-10-05  6:04   ` Peter Korsgaard
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2020-10-03  6:58 UTC (permalink / raw)
  To: buildroot

>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:

 > Fixes:
 > http://autobuild.buildroot.net/results/72e0cc78194a1b93bf26a50742e59a1e93bde1d1/

 > fire has conditional logic to load test_components_py3.py when running under
 > Python 3.x:

 > if six.PY3:
 >   from fire import test_components_py3 as py3

 > pycompile unfortunately errors out on it:

 > ../scripts/pycompile.py ..

 > error:   File "/usr/lib/python2.7/site-packages/fire/test_components_py3.py", line 18
 >     def identity(arg1, arg2: int, arg3=10, arg4: int = 20, *arg5,
 >                            ^
 > SyntaxError: invalid syntax

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

 > Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue
  2020-10-02 13:40 [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue Peter Korsgaard
  2020-10-02 13:40 ` [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue Peter Korsgaard
  2020-10-03  6:57 ` [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue Peter Korsgaard
@ 2020-10-05  6:04 ` Peter Korsgaard
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2020-10-05  6:04 UTC (permalink / raw)
  To: buildroot

>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:

 > Fixes:
 > http://autobuild.buildroot.net/results/4ca459d54545c0e20b0f0cdc63bd81844ecd7f36/

 > aenum has conditional logic to load python 3.x code located in test_v3.py:

 > if pyver >= 3.0:
 >     from aenum.test_v3 import TestEnumV3, TestOrderV3, TestNamedTupleV3

 > And contains logic in setup.py to drop that file during setup.py install if
 > building for python 2.x:

 > py3_only = ('aenum/test_v3.py', )
 > ..
 > if __name__ == '__main__':
 >     if 'install' in sys.argv:
 >         import os, sys
 > 	..
 >         if sys.version_info[0] != 3:
 >             for file in py3_only:
 >                 try:
 >                     os.unlink(file)

 > But this doesn't work in Buildroot as pkg-python.dk first does setup.py
 > build (which copies test_v3.py to the build directory) before setup.py
 > install, so test_v3.py gets installed, leading to errors from pycompile:

 > error:   File "/usr/lib/python2.7/site-packages/aenum/test_v3.py", line 12
 >     class MagicAutoNumberEnum(Enum, settings=AutoNumber):
 >                                             ^
 > SyntaxError: invalid syntax

 > As a workaround, add a hook to drop it from the target directory when
 > building for python 2.x.

 > Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Committed to 2020.02.x, 2020.05.x and 2020.08.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue
  2020-10-02 13:40 ` [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue Peter Korsgaard
  2020-10-03  6:58   ` Peter Korsgaard
@ 2020-10-05  6:04   ` Peter Korsgaard
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2020-10-05  6:04 UTC (permalink / raw)
  To: buildroot

>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:

 > Fixes:
 > http://autobuild.buildroot.net/results/72e0cc78194a1b93bf26a50742e59a1e93bde1d1/

 > fire has conditional logic to load test_components_py3.py when running under
 > Python 3.x:

 > if six.PY3:
 >   from fire import test_components_py3 as py3

 > pycompile unfortunately errors out on it:

 > ../scripts/pycompile.py ..

 > error:   File "/usr/lib/python2.7/site-packages/fire/test_components_py3.py", line 18
 >     def identity(arg1, arg2: int, arg3=10, arg4: int = 20, *arg5,
 >                            ^
 > SyntaxError: invalid syntax

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

 > Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Committed to 2020.02.x, 2020.05.x and 2020.08.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-05  6:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02 13:40 [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue Peter Korsgaard
2020-10-02 13:40 ` [Buildroot] [PATCH 2/2] package/python-fire.mk: drop test_components_py3.py file for python 2.x to fix pyfile issue Peter Korsgaard
2020-10-03  6:58   ` Peter Korsgaard
2020-10-05  6:04   ` Peter Korsgaard
2020-10-03  6:57 ` [Buildroot] [PATCH 1/2] package/python-aenum: drop test_v3.py file for python 2.x to fix pycompile issue Peter Korsgaard
2020-10-05  6:04 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.