File: pyedit-products/unzipped/docetc/examples/RunCode-examples/stdlibs-test.py

# try to import stdlib modules not used by the subproc proxy itself;
# for source-code proxies (dirtro or custom py), these should be in lib;;
# for frozen apps and exes, these are forcibly included at freeze time

# these should work normally
import sys, os
print(sys)
print(os)

# mods not used by subprocprocy.py itself
import cgi, shelve, re, cmath
print(cgi)
print(shelve)
print(re)
print(cmath)

# more fun stuff
import distutils, urllib, email, json, html.parser, tkinter
print(distutils)
print(urllib)
print(email)
print(json)
print(html.parser)
print(tkinter)


# expected output (on Mac app)-------------------------------------------------
"""
<module 'sys' (built-in)>
<module 'os' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/os.pyc'>
<module 'cgi' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/cgi.pyc'>
<module 'shelve' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/shelve.pyc'>
<module 're' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/re.pyc'>
<module 'cmath' from '/Applications/PyEdit.app/Contents/Resources/lib/python3.5/lib-dynload/cmath.so'>
<module 'distutils' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/distutils/__init__.pyc'>
<module 'urllib' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/urllib/__init__.pyc'>
<module 'email' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/email/__init__.pyc'>
<module 'json' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/json/__init__.pyc'>
<module 'html.parser' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/html/parser.pyc'>
<module 'tkinter' from '/Applications/PyEdit.app/Contents/Resources/lib/python35.zip/tkinter/__init__.pyc'>
"""

# expected output (on Windows exe)---------------------------------------------
"""
<module 'sys' (built-in)>
<module 'os' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
<module 'cgi' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
<module 'shelve' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
<module 're' from 'C:\\Users\\mark\\AppData\\Local\\Temp\\_MEI74442\\base_library.zip\\re.pyc'>
<module 'cmath' (built-in)>
<module 'distutils' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
<module 'urllib' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
<module 'email' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
<module 'json' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
<module 'html.parser' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
<module 'tkinter' (<pyimod03_importers.FrozenImporter object at 0x0000000002882A90>)>
"""



[Home page] Books Code Blog Python Author Train Find ©M.Lutz