Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.7 breaks on subprocess import when building with flask-1.0.2 #361

Closed
s1113950 opened this issue Feb 16, 2019 · 5 comments
Closed

Comments

@s1113950
Copy link

s1113950 commented Feb 16, 2019

2019-02-16 15:50:07.479090-0800 piles[19529:317747] [framework] CUIThemeStore: No theme registered with id=0
2019-02-16 15:50:07.554809-0800 piles[19529:317747] Available orientation: KIVY_ORIENTATION=LandscapeLeft LandscapeRight Portrait PortraitUpsideDown
2019-02-16 15:50:07.554959-0800 piles[19529:317747] Initializing python
/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/piles:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
2019-02-16 15:50:07.640055-0800 piles[19529:317747] Running main.py: /Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/YourApp/main.pyc
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.1 (default, Feb  4 2019, 20:11:34) 
[Clang 10.0.0 (clang-1000.11.45.5)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_imageio, img_tex (img_dds, img_sdl2, img_ffpyplayer, img_pil, img_gif ignored)
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <sdl2>
[INFO   ] [GL          ] OpenGL version <b'OpenGL ES 2.0 APPLE-17.0.37'>
[INFO   ] [GL          ] OpenGL vendor <b'Apple Inc.'>
[INFO   ] [GL          ] OpenGL renderer <b'Apple Software Renderer'>
[INFO   ] [GL          ] OpenGL parsed version: 2, 0
[INFO   ] [GL          ] Shading version <b'OpenGL ES GLSL ES 1.00'>
[INFO   ] [GL          ] Texture max size <4096>
[INFO   ] [GL          ] Texture max units <8>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Text        ] Provider: sdl2
 Traceback (most recent call last):
   File "<string>", line 39, in load_module
   File "/Users/robertso/kivy-ios/dist/root/python3/lib/python3.7/imp.py", line 342, in load_dynamic
     return _load(spec)
   File "<frozen importlib._bootstrap>", line 696, in _load
   File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
   File "<frozen importlib._bootstrap>", line 583, in module_from_spec
   File "<frozen importlib._bootstrap_external>", line 1043, in create_module
   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
 ImportError: dynamic module does not define module export function (PyInit_markupsafe__speedups)
 Traceback (most recent call last):
   File "/Users/robertso/kivy-ios/piles-ios/YourApp/main.py", line 31, in <module>
   File "/Users/robertso/kivy-ios/piles-ios/YourApp/screens/__init__.py", line 3, in <module>
     =======
   File "/Users/robertso/kivy-ios/piles-ios/YourApp/screens/player_screen.py", line 13, in <module>
   File "/Users/robertso/kivy-ios/piles-ios/YourApp/web/client.py", line 6, in <module>
   File "/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/lib/python3.7/site-packages/flask/__init__.py", line 19, in <module>
     from jinja2 import Markup, escape
   File "/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/lib/python3.7/site-packages/jinja2/__init__.py", line 82, in <module>
     _patch_async()
   File "/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/lib/python3.7/site-packages/jinja2/__init__.py", line 78, in _patch_async
     from jinja2.asyncsupport import patch_all
   File "/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 13, in <module>
     import asyncio
   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
   File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
   File "/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/lib/python37.zip/asyncio/__init__.py", line 8, in <module>
     * :class:`~kivy.modules.touchring`: Draw a circle around each touch.
   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
   File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
   File "/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/lib/python37.zip/asyncio/base_events.py", line 39, in <module>
   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
   File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
   File "/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/lib/python37.zip/asyncio/events.py", line 210, in <module>
   File "/Users/robertso/Library/Developer/CoreSimulator/Devices/E3E15AFA-1777-445E-B46F-64FEB987A460/data/Containers/Bundle/Application/BF994DCB-8F60-4209-ABA2-D991AB906FEF/piles.app/lib/python37.zip/asyncio/events.py", line 486, in AbstractEventLoop
 AttributeError: module 'subprocess' has no attribute 'PIPE'
2019-02-16 15:50:08.947387-0800 piles[19529:317747] Application quit abnormally!
2019-02-16 15:50:08.969560-0800 piles[19529:317747] Leaving

Possibly related to namespace clash?
adamchainz/django-mysql#396
xmikos/qspectrumanalyzer#49

This works locally when I just run python main.py and don't build an iOS app first 🤔

I'm running Mojave with Xcode 10.1

I tried a direct import of it before the failing line and got as expected:

ImportError: cannot import name 'PIPE' from
'subprocess' (unknown location)

I then tried at the top of my main.py file before anything else was imported and got the same error

@s1113950
Copy link
Author

Ahh dang it:

robertso@robertso-mac02:~/piles/app-piles$ python3
Python 3.7.2 (default, Feb  4 2019, 20:01:21)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> asyncio.subprocess
<module 'asyncio.subprocess' from '/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/subprocess.py'>
>>>

subprocess is redefined here. I'm not entirely sure but it might not be a kivy-ios issue after all...

@s1113950
Copy link
Author

Pulling the tip of jinja2 fixed this for me. I noticed that the tip of that doesn't import asyncio anymore.
./toolchain.py pip install https://github.com/pallets/jinja/zipball/master was the fix

@s1113950
Copy link
Author

I needed to use a different module that includes asyncio so I ran into this issue again, and did more digging:

It turns out that asyncio does have its own subprocess module but it also just imports the regular subprocess library here: https://github.com/python/asyncio/blob/master/asyncio/subprocess.py#L3

I think this is a kivy-ios issue after all because I'm able to run my app just fine via python main.py on my Mac, but when I compile with ./toolchain.py and run it through Xcode it somehow gets redefined to be nothing but this:

{'__name__': 'subprocess', '__doc__': None, '__package__': None, '__loader__': None, '__spec__': None}

@s1113950 s1113950 reopened this May 14, 2019
@tito
Copy link
Member

tito commented Sep 16, 2019

Yes, subprocess is a fake module because it doesn't work on iOS (yet or not at all i don't remember).

@tito
Copy link
Member

tito commented Sep 16, 2019

See the related issue: #372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants