python - py2exe not recognizing jsonschema -


i've been attempting build windows executable py2exe python program uses jsonschema package, every time try run executable fails following error:

file "jsonschema\__init__.pyc", line 18, in <module> file "jsonschema\validators.pyc", line 163, in <module> file "jsonschema\_utils.pyc", line 57, in load_schema file "pkgutil.pyc", line 591, in get_data ioerror: [errno 0] error: 'jsonschema\\schemas\\draft3.json' 

i've tried adding json , jsonschema package options py2exe in setup.py , tried manually copying jsonschema directory location in python27\libs\site-packages library.zip, neither of work. attempted use solution found here (http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html) suggests extending py2exe able copy files zip file, did not seem work either.

i'm assuming happens because py2exe includes python files in library.zip, wondering if there way work without having convert draft3.json , draft4.json .py files in original location.

thank in advance

well after more googling (i hate ugly) got working without patching build_exe.py file. key whole thing recipe @ http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html. collector class looks this:

from py2exe.build_exe import py2exe build_exe  class jsonschemacollector(build_exe):    """        class adds jsonschema files draft3.json , draft4.json        list of compiled files included in zipfile.    """      def copy_extensions(self, extensions):         build_exe.copy_extensions(self, extensions)          # define data path files reside.         data_path = os.path.join(jsonschema.__path__[0], 'schemas')          # create subdir json files collected.         media = os.path.join('jsonschema', 'schemas')         full = os.path.join(self.collect_dir, media)         self.mkpath(full)          # copy json files collection dir. add copied file         # list of compiled files included in zipfile.         name in os.listdir(data_path):             file_name = os.path.join(data_path, name)             self.copy_file(file_name, os.path.join(full, name))             self.compiled_files.append(os.path.join(media, name)) 

what's left add core setup this:

options = {"bundle_files": 1,    # bundle files inside exe            "compressed": 2,      # compress library archive            "optimize": 2,        # python -oo            "packages": packages, # packages needed lxml.            "excludes": excludes, # com stuff don't want            "dll_excludes": skip} # exclude unused dlls  distutils.core.setup(     cmdclass={"py2exe": jsonschemacollector},     options={"py2exe": options},     zipfile=none,     console=[prog]) 

some of code omitted since it's not relevant in context think drift.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -